Skip to contentSkip to conversation

banalabs: Switch to using the new API kobj_to_dev()

PATCH Applied Yang Li 2 participants 2 messages Feb 23, 2021 – Feb 28, 2021 Char and misc drivers

lore
Share & tools
lore

Yang Li

author
#0 lore raw

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

fixed the following coccicheck:
./drivers/misc/habanalabs/common/sysfs.c:347:60-61: WARNING opportunity for kobj_to_dev()

---
 drivers/misc/habanalabs/common/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/sysfs.c +1 -1
index 4366d8f..79c1ddf 100644
@@ -344,7 +344,7 @@ static ssize_t eeprom_read_handler(struct file *filp, struct kobject *kobj,
 			struct bin_attribute *attr, char *buf, loff_t offset,
 			size_t max_size)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct hl_device *hdev = dev_get_drvdata(dev);
 	char *data;
 	int rc;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 25 lines · Yang Li

fixed the following coccicheck:
./drivers/misc/habanalabs/common/sysfs.c:347:60-61: WARNING opportunity for kobj_to_dev()

---
 drivers/misc/habanalabs/common/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/sysfs.c +1 -2
index 4366d8f..79c1ddf 100644
@@ -344,7 +344,7 @@ static ssize_t eeprom_read_handler(struct file *filp, struct kobject *kobj,
                        struct bin_attribute *attr, char *buf, loff_t offset,
                        size_t max_size)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct hl_device *hdev = dev_get_drvdata(dev);
        char *data;
        int rc;
--
Quoted 2 lines

1.8.3.1

Applied to -next.

Thanks,
Oded