Skip to contentSkip to conversation

drivers/dax/bus: Use kobj_to_dev() API

PATCH In review Shuai He 3 participants 3 messages May 29, 2020 – Jun 2, 2020

Subsystems (2)
lore
Share & tools
lore

Shuai He

author
#0 lore raw

PATCH 1/1 drivers/dax/bus: Use kobj_to_dev() API

Use kobj_to_dev() API instead of container_of().

---
 drivers/dax/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/bus.c +1 -1
index df238c8..24625d2 100644
@@ -331,7 +331,7 @@ static DEVICE_ATTR_RO(numa_node);
 
 static umode_t dev_dax_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 dev_dax *dev_dax = to_dev_dax(dev);
 
 	if (a == &dev_attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
Signature · 4 lines
2.7.4
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Shuai He

Use kobj_to_dev() API instead of container_of().

Seems reasonable:

Quoted 22 lines
---
 drivers/dax/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/bus.c +1 -1
index df238c8..24625d2 100644
@@ -331,7 +331,7 @@ static DEVICE_ATTR_RO(numa_node);
 
 static umode_t dev_dax_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 dev_dax *dev_dax = to_dev_dax(dev);
 
 	if (a == &dev_attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
Signature · 4 lines
2.7.4
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Reviewed-by on v1 1/1
#2 lore raw
In reply to Shuai He
Quoted 12 lines

Use kobj_to_dev() API instead of container_of().

---
 drivers/dax/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/bus.c +0 -0
index df238c8..24625d2 100644

drivers/dax/bus.c static DEVICE_ATTR_RO(numa_node); · line 337

Quoted 8 lines
drivers/dax/bus.c +1 -1
@@ -331,7 +331,7 @@ static DEVICE_ATTR_RO(numa_node);
 
 static umode_t dev_dax_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 dev_dax *dev_dax = to_dev_dax(dev);
 
        if (a == &dev_attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)