lkml.org 
[lkml]   [2021]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 1/2] platform/chrome: Use dev_groups to set device sysfs attributes
Date
Instead of manually call sysfs_create_group()/sysfs_remove_group(), set
.dev_groups driver data structure, and let the bus base code create
sysfs attributes.

Fixes: 6fd7f2bbd442 ("mfd / platform: cros_ec: Move device sysfs attributes to its own driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gwendal Grignou <gwendal@google.com>
---
New in v2.

drivers/platform/chrome/cros_ec_sysfs.c | 28 +++++--------------------
1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index f07eabcf9494c..114b9dbe981e7 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -335,34 +335,16 @@ static const struct attribute_group cros_ec_attr_group = {
.is_visible = cros_ec_ctrl_visible,
};

-static int cros_ec_sysfs_probe(struct platform_device *pd)
-{
- struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
- struct device *dev = &pd->dev;
- int ret;
-
- ret = sysfs_create_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group);
- if (ret < 0)
- dev_err(dev, "failed to create attributes. err=%d\n", ret);
-
- return ret;
-}
-
-static int cros_ec_sysfs_remove(struct platform_device *pd)
-{
- struct cros_ec_dev *ec_dev = dev_get_drvdata(pd->dev.parent);
-
- sysfs_remove_group(&ec_dev->class_dev.kobj, &cros_ec_attr_group);
-
- return 0;
-}
+static const struct attribute_group *cros_ec_attr_groups[] = {
+ &cros_ec_attr_group,
+ NULL,
+};

static struct platform_driver cros_ec_sysfs_driver = {
.driver = {
.name = DRV_NAME,
+ .dev_groups = cros_ec_attr_groups,
},
- .probe = cros_ec_sysfs_probe,
- .remove = cros_ec_sysfs_remove,
};

module_platform_driver(cros_ec_sysfs_driver);
--
2.31.0.208.g409f899ff0-goog
\
 
 \ /
  Last update: 2021-04-05 22:30    [W:0.067 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site