Skip to contentSkip to conversation

platform/x86/asus-wmi: using dev_get_drvdata directly

PATCH In review Fuqian Huang 2 participants 2 messages Jul 4, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 10/10 platform/x86/asus-wmi: using dev_get_drvdata directly

Several drivers cast a struct device pointer to a struct platform_device pointer only to then call platform_get_drvdata(). To improve readability, these constructs can be simplified by using dev_get_drvdata() directly.

---
Changes in v2:
- Make the commit message more clearly.

 drivers/platform/x86/asus-wmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +1 -2
index 9b18a184e0aa..49049b02a015 100644
@@ -1353,8 +1353,7 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
 					  struct attribute *attr, int idx)
 {
 	struct device *dev = container_of(kobj, struct device, kobj);
-	struct platform_device *pdev = to_platform_device(dev->parent);
-	struct asus_wmi *asus = platform_get_drvdata(pdev);
+	struct asus_wmi *asus = dev_get_drvdata(dev->parent);
 	int dev_id = -1;
 	int fan_attr = -1;
 	u32 value = ASUS_WMI_UNSUPPORTED_METHOD;
Signature · 1 line
2.11.0
#1 lore raw
Quoted 5 lines · Fuqian Huang

Several drivers cast a struct device pointer to a struct platform_device pointer only to then call platform_get_drvdata(). To improve readability, these constructs can be simplified by using dev_get_drvdata() directly.

v1 had been applied.

Quoted 25 lines

---
Changes in v2:
- Make the commit message more clearly.

 drivers/platform/x86/asus-wmi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +1 -3
index 9b18a184e0aa..49049b02a015 100644
@@ -1353,8 +1353,7 @@ static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
                                          struct attribute *attr, int idx)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
-       struct platform_device *pdev = to_platform_device(dev->parent);
-       struct asus_wmi *asus = platform_get_drvdata(pdev);
+       struct asus_wmi *asus = dev_get_drvdata(dev->parent);
        int dev_id = -1;
        int fan_attr = -1;
        u32 value = ASUS_WMI_UNSUPPORTED_METHOD;
--

2.11.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko