diff options
author | Bin Meng | 2017-08-22 08:15:15 -0700 |
---|---|---|
committer | Tom Rini | 2017-08-28 07:17:14 -0400 |
commit | d5b7ee9c6e19993b10b549ac763aa7db8dbacee0 (patch) | |
tree | 94e7f8eccb9f67285afb7ebb4f3b084ee5b3a02d /drivers/nvme | |
parent | 704e040a51d2456a6c56e79363279b230d37cef7 (diff) |
nvme: Use blk_create_devicef() API
The codes in nvme_uclass_post_probe() can be replaced to call the
blk_create_devicef() API directly.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/nvme-uclass.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/nvme/nvme-uclass.c b/drivers/nvme/nvme-uclass.c index 0895bc9c249..334628cebfc 100644 --- a/drivers/nvme/nvme-uclass.c +++ b/drivers/nvme/nvme-uclass.c @@ -26,28 +26,22 @@ static int nvme_info_init(struct uclass *uc) static int nvme_uclass_post_probe(struct udevice *udev) { char name[20]; - char *str; struct udevice *ns_udev; int i, ret; struct nvme_dev *ndev = dev_get_priv(udev); /* Create a blk device for each namespace */ for (i = 0; i < ndev->nn; i++) { - sprintf(name, "nvme-blk#%d", nvme_info->ns_num); - str = strdup(name); - if (!str) - return -ENOMEM; + sprintf(name, "blk#%d", nvme_info->ns_num); /* The real blksz and size will be set by nvme_blk_probe() */ - ret = blk_create_device(udev, "nvme-blk", str, IF_TYPE_NVME, - nvme_info->ns_num++, 512, 0, &ns_udev); + ret = blk_create_devicef(udev, "nvme-blk", name, IF_TYPE_NVME, + nvme_info->ns_num++, 512, 0, &ns_udev); if (ret) { - free(str); nvme_info->ns_num--; return ret; } - device_set_name_alloced(ns_udev); } return 0; |