[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210405202857.1265308-2-gwendal@google.com>
Date: Mon, 5 Apr 2021 13:28:56 -0700
From: Gwendal Grignou <gwendal@...omium.org>
To: bleung@...omium.org, enric.balletbo@...labora.com,
groeck@...omium.org
Cc: linux-kernel@...r.kernel.org, Gwendal Grignou <gwendal@...gle.com>,
stable@...r.kernel.org
Subject: [PATCH v2 1/2] platform/chrome: Use dev_groups to set device sysfs attributes
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@...r.kernel.org
Signed-off-by: Gwendal Grignou <gwendal@...gle.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
Powered by blists - more mailing lists