Skip to contentSkip to conversation

nvme-core: Switch to using the new API kobj_to_dev()

PATCH In review Yang Li 3 participants 3 messages Feb 20, 2021 – Feb 22, 2021 NVMe

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 nvme-core: Switch to using the new API kobj_to_dev()

fixed the following coccicheck:
./drivers/nvme/host/core.c:3440:60-61: WARNING opportunity for kobj_to_dev()
./drivers/nvme/host/core.c:3679:60-61: WARNING opportunity for kobj_to_dev()

---
 drivers/nvme/host/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +2 -2
index f13eb4d..d56590f 100644
@@ -3437,7 +3437,7 @@ static ssize_t nsid_show(struct device *dev, struct device_attribute *attr,
 static umode_t nvme_ns_id_attrs_are_visible(struct kobject *kobj,
 		struct attribute *a, int n)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nvme_ns_ids *ids = &dev_to_ns_head(dev)->ids;
 
 	if (a == &dev_attr_uuid.attr) {
@@ -3676,7 +3676,7 @@ static DEVICE_ATTR(reconnect_delay, S_IRUGO | S_IWUSR,
 static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
 		struct attribute *a, int n)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
 
 	if (a == &dev_attr_delete_controller.attr && !ctrl->ops->delete_ctrl)
Signature · 7 lines
1.8.3.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Yang Li

fixed the following coccicheck:
./drivers/nvme/host/core.c:3440:60-61: WARNING opportunity for kobj_to_dev()
./drivers/nvme/host/core.c:3679:60-61: WARNING opportunity for kobj_to_dev()

Looks good.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer
#2 lore raw
In reply to Yang Li
Quoted 8 lines · Yang Li

fixed the following coccicheck:
./drivers/nvme/host/core.c:3440:60-61: WARNING opportunity for kobj_to_dev()
./drivers/nvme/host/core.c:3679:60-61: WARNING opportunity for kobj_to_dev()

This was rejected the last time it posted 6 months ago:

http://lists.infradead.org/pipermail/linux-nvme/2020-September/019463.html

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme