Skip to content

Commit 957961b

Browse files
Samsagaxgroeck
authored andcommitted
hwmon: (oxp-sensors) Move tt_toggle attribute to dev_groups
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 will allow for removal of the devm_device_add_groups() function. Signed-off-by: Joaquín Ignacio Aramendía <[email protected]> Fixes: be144ee ("hwmon: (oxp-sensors) Add tt_toggle attribute on supported boards") Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent a746b36 commit 957961b

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

drivers/hwmon/oxp-sensors.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@ static int tt_toggle_disable(void)
220220
}
221221

222222
/* Callbacks for turbo toggle attribute */
223+
static umode_t tt_toggle_is_visible(struct kobject *kobj,
224+
struct attribute *attr, int n)
225+
{
226+
switch (board) {
227+
case aok_zoe_a1:
228+
case oxp_mini_amd_a07:
229+
case oxp_mini_amd_pro:
230+
return attr->mode;
231+
default:
232+
break;
233+
}
234+
return 0;
235+
}
236+
223237
static ssize_t tt_toggle_store(struct device *dev,
224238
struct device_attribute *attr, const char *buf,
225239
size_t count)
@@ -396,7 +410,15 @@ static struct attribute *oxp_ec_attrs[] = {
396410
NULL
397411
};
398412

399-
ATTRIBUTE_GROUPS(oxp_ec);
413+
static struct attribute_group oxp_ec_attribute_group = {
414+
.is_visible = tt_toggle_is_visible,
415+
.attrs = oxp_ec_attrs,
416+
};
417+
418+
static const struct attribute_group *oxp_ec_groups[] = {
419+
&oxp_ec_attribute_group,
420+
NULL
421+
};
400422

401423
static const struct hwmon_ops oxp_ec_hwmon_ops = {
402424
.is_visible = oxp_ec_hwmon_is_visible,
@@ -415,7 +437,6 @@ static int oxp_platform_probe(struct platform_device *pdev)
415437
const struct dmi_system_id *dmi_entry;
416438
struct device *dev = &pdev->dev;
417439
struct device *hwdev;
418-
int ret;
419440

420441
/*
421442
* Have to check for AMD processor here because DMI strings are the
@@ -430,18 +451,6 @@ static int oxp_platform_probe(struct platform_device *pdev)
430451

431452
board = (enum oxp_board)(unsigned long)dmi_entry->driver_data;
432453

433-
switch (board) {
434-
case aok_zoe_a1:
435-
case oxp_mini_amd_a07:
436-
case oxp_mini_amd_pro:
437-
ret = devm_device_add_groups(dev, oxp_ec_groups);
438-
if (ret)
439-
return ret;
440-
break;
441-
default:
442-
break;
443-
}
444-
445454
hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL,
446455
&oxp_ec_chip_info, NULL);
447456

@@ -451,6 +460,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
451460
static struct platform_driver oxp_platform_driver = {
452461
.driver = {
453462
.name = "oxp-platform",
463+
.dev_groups = oxp_ec_groups,
454464
},
455465
.probe = oxp_platform_probe,
456466
};

0 commit comments

Comments
 (0)