* [PATCH v2] scsi: zfcp: move the position of put_device
@ 2020-12-01 2:47 Qinglang Miao
2020-12-14 12:49 ` Benjamin Block
0 siblings, 1 reply; 2+ messages in thread
From: Qinglang Miao @ 2020-12-01 2:47 UTC (permalink / raw)
To: Steffen Maier, Benjamin Block, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger
Cc: linux-s390, linux-kernel, Qinglang Miao
Have the `put_device()` call after `device_unregister()` in both
`zfcp_unit_remove()` and `zfcp_sysfs_port_remove_store()` to make
it more natural, for put_device() ought to be the last time we
touch the object in both functions.
And add comments after put_device to make codes clearer.
Suggested-by: Steffen Maier <maier@linux.ibm.com>
Suggested-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
v2: add comments after put_device as Steffen suggested.
drivers/s390/scsi/zfcp_sysfs.c | 4 ++--
drivers/s390/scsi/zfcp_unit.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 8d9662e8b..ef6d35a37 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -327,10 +327,10 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
list_del(&port->list);
write_unlock_irq(&adapter->port_list_lock);
- put_device(&port->dev);
-
zfcp_erp_port_shutdown(port, 0, "syprs_1");
device_unregister(&port->dev);
+
+ put_device(&port->dev); /* undo zfcp_get_port_by_wwpn() */
out:
zfcp_ccw_adapter_put(adapter);
return retval ? retval : (ssize_t) count;
diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index e67bf7388..59333f025 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -255,9 +255,9 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
scsi_device_put(sdev);
}
- put_device(&unit->dev);
-
device_unregister(&unit->dev);
+ put_device(&unit->dev); /* undo _zfcp_unit_find() */
+
return 0;
}
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] scsi: zfcp: move the position of put_device
2020-12-01 2:47 [PATCH v2] scsi: zfcp: move the position of put_device Qinglang Miao
@ 2020-12-14 12:49 ` Benjamin Block
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Block @ 2020-12-14 12:49 UTC (permalink / raw)
To: Qinglang Miao
Cc: Steffen Maier, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, linux-s390, linux-kernel
On Tue, Dec 01, 2020 at 10:47:16AM +0800, Qinglang Miao wrote:
> Have the `put_device()` call after `device_unregister()` in both
> `zfcp_unit_remove()` and `zfcp_sysfs_port_remove_store()` to make
> it more natural, for put_device() ought to be the last time we
> touch the object in both functions.
>
> And add comments after put_device to make codes clearer.
>
> Suggested-by: Steffen Maier <maier@linux.ibm.com>
> Suggested-by: Benjamin Block <bblock@linux.ibm.com>
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
> v2: add comments after put_device as Steffen suggested.
>
> drivers/s390/scsi/zfcp_sysfs.c | 4 ++--
> drivers/s390/scsi/zfcp_unit.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
Got a bit delayed.
Looks good, I queue it, and we send it with the changes for 5.12 once
the merge window for 5.11 is over.
Thanks.
--
Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen / Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-14 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 2:47 [PATCH v2] scsi: zfcp: move the position of put_device Qinglang Miao
2020-12-14 12:49 ` Benjamin Block
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).