Skip to content

Commit b503627

Browse files
andy-shevlag-linaro
authored andcommitted
mfd: kempld: Use device core to create driver-specific device attributes
Instead of creating driver-specific device attributes with sysfs_create_group() have device core do this by setting up dev_groups pointer in the driver structure. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240223195113.880121-3-andriy.shevchenko@linux.intel.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 392654a commit b503627

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

drivers/mfd/kempld-core.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/dmi.h>
1616
#include <linux/io.h>
1717
#include <linux/delay.h>
18+
#include <linux/sysfs.h>
1819

1920
#define MAX_ID_LEN 4
2021
static char force_device_id[MAX_ID_LEN + 1] = "";
@@ -373,16 +374,13 @@ static DEVICE_ATTR_RO(pld_version);
373374
static DEVICE_ATTR_RO(pld_specification);
374375
static DEVICE_ATTR_RO(pld_type);
375376

376-
static struct attribute *pld_attributes[] = {
377+
static struct attribute *pld_attrs[] = {
377378
&dev_attr_pld_version.attr,
378379
&dev_attr_pld_specification.attr,
379380
&dev_attr_pld_type.attr,
380381
NULL
381382
};
382-
383-
static const struct attribute_group pld_attr_group = {
384-
.attrs = pld_attributes,
385-
};
383+
ATTRIBUTE_GROUPS(pld);
386384

387385
static int kempld_detect_device(struct kempld_device_data *pld)
388386
{
@@ -415,15 +413,7 @@ static int kempld_detect_device(struct kempld_device_data *pld)
415413
pld->info.version, kempld_get_type_string(pld),
416414
pld->info.spec_major, pld->info.spec_minor);
417415

418-
ret = sysfs_create_group(&pld->dev->kobj, &pld_attr_group);
419-
if (ret)
420-
return ret;
421-
422-
ret = kempld_register_cells(pld);
423-
if (ret)
424-
sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
425-
426-
return ret;
416+
return kempld_register_cells(pld);
427417
}
428418

429419
static int kempld_probe(struct platform_device *pdev)
@@ -489,8 +479,6 @@ static void kempld_remove(struct platform_device *pdev)
489479
struct kempld_device_data *pld = platform_get_drvdata(pdev);
490480
const struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
491481

492-
sysfs_remove_group(&pld->dev->kobj, &pld_attr_group);
493-
494482
mfd_remove_devices(&pdev->dev);
495483
pdata->release_hardware_mutex(pld);
496484
}
@@ -506,6 +494,7 @@ static struct platform_driver kempld_driver = {
506494
.driver = {
507495
.name = "kempld",
508496
.acpi_match_table = kempld_acpi_table,
497+
.dev_groups = pld_groups,
509498
},
510499
.probe = kempld_probe,
511500
.remove_new = kempld_remove,

0 commit comments

Comments
 (0)