net/can: using dev_get_drvdata directly
authorFuqian Huang <huangfq.daxian@gmail.com>
Thu, 4 Jul 2019 02:36:33 +0000 (10:36 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 Jul 2019 22:24:41 +0000 (15:24 -0700)
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.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/can/softing/softing_main.c

index 68bb58a57f3b3b56661626d47a73202953f878f4..8242fb287cbbe2c5039388de249006629636f12a 100644 (file)
@@ -683,7 +683,7 @@ static void softing_netdev_cleanup(struct net_device *netdev)
 static ssize_t show_##name(struct device *dev, \
                struct device_attribute *attr, char *buf) \
 { \
-       struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
+       struct softing *card = dev_get_drvdata(dev); \
        return sprintf(buf, "%u\n", card->member); \
 } \
 static DEVICE_ATTR(name, 0444, show_##name, NULL)
@@ -692,7 +692,7 @@ static DEVICE_ATTR(name, 0444, show_##name, NULL)
 static ssize_t show_##name(struct device *dev, \
                struct device_attribute *attr, char *buf) \
 { \
-       struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
+       struct softing *card = dev_get_drvdata(dev); \
        return sprintf(buf, "%s\n", card->member); \
 } \
 static DEVICE_ATTR(name, 0444, show_##name, NULL)