From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-hwmon@vger.kernel.org
Cc: linux@roeck-us.net, samsagax@gmail.com,
linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 2/3] hwmon: (oxp-sensors): move to use dev_groups from platform device
Date: Tue, 4 Jul 2023 14:17:18 +0100 [thread overview]
Message-ID: <20230704131715.44454-7-gregkh@linuxfoundation.org> (raw)
In-Reply-To: <20230704131715.44454-5-gregkh@linuxfoundation.org>
A driver should not be manually adding groups in its probe function (it
will race with userspace), so replace the call to
devm_device_add_groups() to use the platform dev_groups callback
instead.
This is the last in-kernel user of devm_device_add_groups(), so it can
be successfully removed at this point in time.
Cc: Joaquín Ignacio Aramendía <samsagax@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/oxp-sensors.c | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c
index 3bcba0c476c4..34e561ba9e8b 100644
--- a/drivers/hwmon/oxp-sensors.c
+++ b/drivers/hwmon/oxp-sensors.c
@@ -408,12 +408,33 @@ static const struct hwmon_channel_info * const oxp_platform_sensors[] = {
NULL,
};
+static umode_t oxp_ec_is_visible(struct kobject *kobj, struct attribute *attr, int n)
+{
+ switch (get_board_type()) {
+ case aok_zoe_a1:
+ case oxp_mini_amd_a07:
+ case oxp_mini_amd_pro:
+ return attr->mode;
+ default:
+ break;
+ }
+ return 0;
+}
+
static struct attribute *oxp_ec_attrs[] = {
&dev_attr_tt_toggle.attr,
NULL
};
-ATTRIBUTE_GROUPS(oxp_ec);
+static struct attribute_group oxp_ec_attribute_group = {
+ .is_visible = oxp_ec_is_visible,
+ .attrs = oxp_ec_attrs,
+};
+
+static const struct attribute_group *oxp_ec_groups[] = {
+ &oxp_ec_attribute_group,
+ NULL
+};
static const struct hwmon_ops oxp_ec_hwmon_ops = {
.is_visible = oxp_ec_hwmon_is_visible,
@@ -431,19 +452,6 @@ static int oxp_platform_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device *hwdev;
- int ret;
-
- switch (get_board_type()) {
- case aok_zoe_a1:
- case oxp_mini_amd_a07:
- case oxp_mini_amd_pro:
- ret = devm_device_add_groups(dev, oxp_ec_groups);
- if (ret)
- return ret;
- break;
- default:
- break;
- }
hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL,
&oxp_ec_chip_info, NULL);
@@ -454,6 +462,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
static struct platform_driver oxp_platform_driver = {
.driver = {
.name = "oxp-platform",
+ .dev_groups = oxp_ec_groups,
},
.probe = oxp_platform_probe,
};
--
2.41.0
next prev parent reply other threads:[~2023-07-04 13:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 13:17 [PATCH 0/3] driver core: remove final user of devm_device_add_groups() Greg Kroah-Hartman
2023-07-04 13:17 ` [PATCH 1/3] hwmon: (oxp-sensors): remove static board variable Greg Kroah-Hartman
2023-07-04 13:39 ` Guenter Roeck
2023-07-04 13:44 ` Greg Kroah-Hartman
2023-07-04 14:14 ` Guenter Roeck
2023-07-04 16:14 ` Greg Kroah-Hartman
2023-07-04 16:43 ` Guenter Roeck
2023-07-04 16:52 ` Greg Kroah-Hartman
2023-07-04 19:44 ` Joaquin Aramendia
2023-07-04 13:17 ` Greg Kroah-Hartman [this message]
2023-07-04 13:17 ` [PATCH 3/3] driver core: remove devm_device_add_groups() Greg Kroah-Hartman
2023-07-04 16:05 ` Rafael J. Wysocki
2023-07-05 18:50 ` Dmitry Torokhov
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=20230704131715.44454-7-gregkh@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=samsagax@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.