mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gwendal Grignou <gwendal@chromium.org>
To: bleung@chromium.org, enric.balletbo@collabora.com, groeck@chromium.org
Cc: linux-kernel@vger.kernel.org,
	Gwendal Grignou <gwendal@google.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 1/2] platform/chrome: Use dev_groups to set device sysfs attributes
Date: Mon,  5 Apr 2021 13:28:56 -0700	[thread overview]
Message-ID: <20210405202857.1265308-2-gwendal@google.com> (raw)
In-Reply-To: <20210405202857.1265308-1-gwendal@google.com>

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


  reply	other threads:[~2021-04-05 20:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 20:28 [PATCH v2 0/2] platform/chrome: Update cros_ec sysfs attribute after sensors are found Gwendal Grignou
2021-04-05 20:28 ` Gwendal Grignou [this message]
2021-04-05 20:28 ` [PATCH v2 2/2] platform/chrome: Update cros_ec sysfs attributes on sensors discovery Gwendal Grignou
2021-05-27 21:01 ` [PATCH v2 0/2] platform/chrome: Update cros_ec sysfs attribute after sensors are found Gwendal Grignou
2021-05-31  5:36   ` Dmitry Torokhov
2021-08-04 21:09     ` Gwendal Grignou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210405202857.1265308-2-gwendal@google.com \
    --to=gwendal@chromium.org \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=gwendal@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®