Commit 0766fcaa authored by Bart Van Assche's avatar Bart Van Assche Committed by Leon Romanovsky

RDMA/srp: Remove the srp_host.released completion

Move the kfree(host) calls into srp_release_dev(). Convert a
device_unregister() call into a device_del() and a device_put() call.
Remove the host->released completion object. This patch prepares for
handling dev_set_name() failure in srp_add_port().

Link: https://lore.kernel.org/r/20220825213900.864587-3-bvanassche@acm.orgSigned-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent c8e4c239
...@@ -3178,7 +3178,7 @@ static void srp_release_dev(struct device *dev) ...@@ -3178,7 +3178,7 @@ static void srp_release_dev(struct device *dev)
struct srp_host *host = struct srp_host *host =
container_of(dev, struct srp_host, dev); container_of(dev, struct srp_host, dev);
complete(&host->released); kfree(host);
} }
static struct class srp_class = { static struct class srp_class = {
...@@ -3898,7 +3898,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) ...@@ -3898,7 +3898,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
INIT_LIST_HEAD(&host->target_list); INIT_LIST_HEAD(&host->target_list);
spin_lock_init(&host->target_lock); spin_lock_init(&host->target_lock);
init_completion(&host->released);
mutex_init(&host->add_target_mutex); mutex_init(&host->add_target_mutex);
host->srp_dev = device; host->srp_dev = device;
host->port = port; host->port = port;
...@@ -3922,8 +3921,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port) ...@@ -3922,8 +3921,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
put_host: put_host:
device_del(&host->dev); device_del(&host->dev);
put_device(&host->dev); put_device(&host->dev);
kfree(host);
return NULL; return NULL;
} }
...@@ -4029,12 +4026,11 @@ static void srp_remove_one(struct ib_device *device, void *client_data) ...@@ -4029,12 +4026,11 @@ static void srp_remove_one(struct ib_device *device, void *client_data)
srp_dev = client_data; srp_dev = client_data;
list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
device_unregister(&host->dev);
/* /*
* Wait for the sysfs entry to go away, so that no new * Remove the add_target sysfs entry so that no new target ports
* target ports can be created. * can be created.
*/ */
wait_for_completion(&host->released); device_del(&host->dev);
/* /*
* Remove all target ports. * Remove all target ports.
...@@ -4052,7 +4048,7 @@ static void srp_remove_one(struct ib_device *device, void *client_data) ...@@ -4052,7 +4048,7 @@ static void srp_remove_one(struct ib_device *device, void *client_data)
*/ */
flush_workqueue(srp_remove_wq); flush_workqueue(srp_remove_wq);
kfree(host); put_device(&host->dev);
} }
ib_dealloc_pd(srp_dev->pd); ib_dealloc_pd(srp_dev->pd);
......
...@@ -124,7 +124,6 @@ struct srp_host { ...@@ -124,7 +124,6 @@ struct srp_host {
struct device dev; struct device dev;
struct list_head target_list; struct list_head target_list;
spinlock_t target_lock; spinlock_t target_lock;
struct completion released;
struct list_head list; struct list_head list;
struct mutex add_target_mutex; struct mutex add_target_mutex;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment