]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/chrome: cros_ec_sysfs: introduce to_cros_ec_dev define.
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>
Fri, 23 Mar 2018 17:42:43 +0000 (18:42 +0100)
committerBenson Leung <bleung@chromium.org>
Wed, 11 Apr 2018 05:22:49 +0000 (22:22 -0700)
Add a define to get the cros_ec_dev from device and use it.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Benson Leung <bleung@chromium.org>
drivers/platform/chrome/cros_ec_sysfs.c

index c03621e523a3e73e1e4d0b76b98ce8ad983bb5fa..85bb9580439eb1cafdb3da37fd530e90a38af860 100644 (file)
@@ -34,6 +34,8 @@
 #include <linux/types.h>
 #include <linux/uaccess.h>
 
+#define to_cros_ec_dev(dev)  container_of(dev, struct cros_ec_dev, class_dev)
+
 /* Accessor functions */
 
 static ssize_t show_ec_reboot(struct device *dev,
@@ -70,8 +72,7 @@ static ssize_t store_ec_reboot(struct device *dev,
        int got_cmd = 0, offset = 0;
        int i;
        int ret;
-       struct cros_ec_dev *ec = container_of(dev,
-                                             struct cros_ec_dev, class_dev);
+       struct cros_ec_dev *ec = to_cros_ec_dev(dev);
 
        msg = kmalloc(sizeof(*msg) + sizeof(*param), GFP_KERNEL);
        if (!msg)
@@ -132,8 +133,7 @@ static ssize_t show_ec_version(struct device *dev,
        struct cros_ec_command *msg;
        int ret;
        int count = 0;
-       struct cros_ec_dev *ec = container_of(dev,
-                                             struct cros_ec_dev, class_dev);
+       struct cros_ec_dev *ec = to_cros_ec_dev(dev);
 
        msg = kmalloc(sizeof(*msg) + EC_HOST_PARAM_SIZE, GFP_KERNEL);
        if (!msg)
@@ -231,8 +231,7 @@ static ssize_t show_ec_flashinfo(struct device *dev,
        struct ec_response_flash_info *resp;
        struct cros_ec_command *msg;
        int ret;
-       struct cros_ec_dev *ec = container_of(dev,
-                                             struct cros_ec_dev, class_dev);
+       struct cros_ec_dev *ec = to_cros_ec_dev(dev);
 
        msg = kmalloc(sizeof(*msg) + sizeof(*resp), GFP_KERNEL);
        if (!msg)