diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-12-07 15:05:35 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-12-08 15:31:14 -0500 |
commit | d4c80bad59dbc69a989ca2c4efbcc0fb772a713b (patch) | |
tree | 32a168ea64dfca42b7c603c55d6e07f8baa3b292 /drivers/staging/greybus/hd.c | |
parent | 0bf1f2441979e290945f4e5af40d76582c61da1e (diff) |
greybus: hd: initialise device last
Initialise the struct device last when creating the host device.
After device_initialize(), or rather dev_set_name(), we must use
put_device to release the host device. Initialising last will allow for
a simpler release callback.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/hd.c')
-rw-r--r-- | drivers/staging/greybus/hd.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c index 74569a38698a..e38c41c31f04 100644 --- a/drivers/staging/greybus/hd.c +++ b/drivers/staging/greybus/hd.c @@ -72,20 +72,12 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, if (!hd) return ERR_PTR(-ENOMEM); - hd->dev.parent = parent; - hd->dev.bus = &greybus_bus_type; - hd->dev.type = &greybus_hd_type; - hd->dev.dma_mask = hd->dev.parent->dma_mask; - device_initialize(&hd->dev); - ret = ida_simple_get(&gb_hd_bus_id_map, 1, 0, GFP_KERNEL); if (ret < 0) { kfree(hd); return ERR_PTR(ret); } - hd->bus_id = ret; - dev_set_name(&hd->dev, "greybus%d", hd->bus_id); hd->driver = driver; INIT_LIST_HEAD(&hd->interfaces); @@ -94,6 +86,13 @@ struct gb_host_device *gb_hd_create(struct gb_hd_driver *driver, hd->buffer_size_max = buffer_size_max; hd->num_cports = num_cports; + hd->dev.parent = parent; + hd->dev.bus = &greybus_bus_type; + hd->dev.type = &greybus_hd_type; + hd->dev.dma_mask = hd->dev.parent->dma_mask; + device_initialize(&hd->dev); + dev_set_name(&hd->dev, "greybus%d", hd->bus_id); + return hd; } EXPORT_SYMBOL_GPL(gb_hd_create); |