Skip to contentSkip to conversation

hwmon: Switch to using the new API kobj_to_dev()

PATCH Applied Yang Li 2 participants 2 messages Feb 23, 2021 – Mar 11, 2021 Hardware monitoring

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 hwmon: Switch to using the new API kobj_to_dev()

fixed the following coccicheck:
./drivers/hwmon/hwmon.c:82:60-61: WARNING opportunity for kobj_to_dev()

---
 drivers/hwmon/hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/hwmon.c +1 -1
index 6c68405..fd47ab4 100644
@@ -79,7 +79,7 @@ struct hwmon_thermal_data {
 static umode_t hwmon_dev_name_is_visible(struct kobject *kobj,
 					 struct attribute *attr, int n)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 
 	if (to_hwmon_device(dev)->name == NULL)
 		return 0;
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Yang Li

fixed the following coccicheck:
./drivers/hwmon/hwmon.c:82:60-61: WARNING opportunity for kobj_to_dev()

Applied.

Thanks,
Guenter

Quoted 17 lines
---
 drivers/hwmon/hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/hwmon.c +1 -1
index 6c68405..fd47ab4 100644
@@ -79,7 +79,7 @@ struct hwmon_thermal_data {
 static umode_t hwmon_dev_name_is_visible(struct kobject *kobj,
 					 struct attribute *attr, int n)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 
 	if (to_hwmon_device(dev)->name == NULL)
 		return 0;