diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2017-08-22 08:15:16 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-08-28 07:17:14 -0400 |
commit | 18aa5a4134e8179c7c3e38675822284a2718a3d8 (patch) | |
tree | 17cd715b07568c52883f6ac7d71f8f1eee9e1b08 /drivers/nvme/nvme-uclass.c | |
parent | d5b7ee9c6e19993b10b549ac763aa7db8dbacee0 (diff) | |
download | u-boot-18aa5a4134e8179c7c3e38675822284a2718a3d8.tar.gz |
nvme: Get rid of the global variable nvme_info
At present the NVMe uclass driver uses a global variable nvme_info
to store global information like namespace id, and NVMe controller
driver's priv struct has a blk_dev_start that is used to calculate
the namespace id based on the global information from nvme_info.
This is not a good design in the DM world and can be replaced with
the following changes:
- Encode the namespace id in the NVMe block device name during
the NVMe uclass post probe
- Extract the namespace id from the device name during the NVMe
block device probe
- Let BLK uclass calculate the devnum for us by passing -1 to
blk_create_devicef() as the devnum
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/nvme/nvme-uclass.c')
-rw-r--r-- | drivers/nvme/nvme-uclass.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/drivers/nvme/nvme-uclass.c b/drivers/nvme/nvme-uclass.c index 334628cebf..56a6171876 100644 --- a/drivers/nvme/nvme-uclass.c +++ b/drivers/nvme/nvme-uclass.c @@ -11,18 +11,6 @@ #include <dm/device.h> #include "nvme.h" -static int nvme_info_init(struct uclass *uc) -{ - struct nvme_info *info = (struct nvme_info *)uc->priv; - - info->ns_num = 0; - info->ndev_num = 0; - INIT_LIST_HEAD(&info->dev_list); - nvme_info = info; - - return 0; -} - static int nvme_uclass_post_probe(struct udevice *udev) { char name[20]; @@ -32,16 +20,17 @@ static int nvme_uclass_post_probe(struct udevice *udev) /* Create a blk device for each namespace */ for (i = 0; i < ndev->nn; i++) { - sprintf(name, "blk#%d", nvme_info->ns_num); + /* + * Encode the namespace id to the device name so that + * we can extract it when doing the probe. + */ + sprintf(name, "blk#%d", i); /* The real blksz and size will be set by nvme_blk_probe() */ ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME, - nvme_info->ns_num++, 512, 0, &ns_udev); - if (ret) { - nvme_info->ns_num--; - + -1, 512, 0, &ns_udev); + if (ret) return ret; - } } return 0; @@ -50,7 +39,5 @@ static int nvme_uclass_post_probe(struct udevice *udev) UCLASS_DRIVER(nvme) = { .name = "nvme", .id = UCLASS_NVME, - .init = nvme_info_init, .post_probe = nvme_uclass_post_probe, - .priv_auto_alloc_size = sizeof(struct nvme_info), }; |