Skip to content

Commit d7228c7

Browse files
mwilczyrafaeljw
authored andcommitted
ACPI: acpi_pad: Use dev groups for sysfs
Change the way sysfs files are created. Use dev_groups, as it's a better approach - it allows to declare attributes, and the core code would take care of the lifecycle of those objects. Suggested-by: Andy Shevchenko <[email protected]> Signed-off-by: Michal Wilczynski <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent dd0261b commit d7228c7

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

drivers/acpi/acpi_pad.c

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -337,33 +337,14 @@ static ssize_t idlecpus_show(struct device *dev,
337337

338338
static DEVICE_ATTR_RW(idlecpus);
339339

340-
static int acpi_pad_add_sysfs(struct acpi_device *device)
341-
{
342-
int result;
343-
344-
result = device_create_file(&device->dev, &dev_attr_idlecpus);
345-
if (result)
346-
return -ENODEV;
347-
result = device_create_file(&device->dev, &dev_attr_idlepct);
348-
if (result) {
349-
device_remove_file(&device->dev, &dev_attr_idlecpus);
350-
return -ENODEV;
351-
}
352-
result = device_create_file(&device->dev, &dev_attr_rrtime);
353-
if (result) {
354-
device_remove_file(&device->dev, &dev_attr_idlecpus);
355-
device_remove_file(&device->dev, &dev_attr_idlepct);
356-
return -ENODEV;
357-
}
358-
return 0;
359-
}
340+
static struct attribute *acpi_pad_attrs[] = {
341+
&dev_attr_idlecpus.attr,
342+
&dev_attr_idlepct.attr,
343+
&dev_attr_rrtime.attr,
344+
NULL
345+
};
360346

361-
static void acpi_pad_remove_sysfs(struct acpi_device *device)
362-
{
363-
device_remove_file(&device->dev, &dev_attr_idlecpus);
364-
device_remove_file(&device->dev, &dev_attr_idlepct);
365-
device_remove_file(&device->dev, &dev_attr_rrtime);
366-
}
347+
ATTRIBUTE_GROUPS(acpi_pad);
367348

368349
/*
369350
* Query firmware how many CPUs should be idle
@@ -439,15 +420,10 @@ static int acpi_pad_probe(struct platform_device *pdev)
439420
strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
440421
strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS);
441422

442-
if (acpi_pad_add_sysfs(device))
443-
return -ENODEV;
444-
445423
status = acpi_install_notify_handler(device->handle,
446424
ACPI_DEVICE_NOTIFY, acpi_pad_notify, device);
447-
if (ACPI_FAILURE(status)) {
448-
acpi_pad_remove_sysfs(device);
425+
if (ACPI_FAILURE(status))
449426
return -ENODEV;
450-
}
451427

452428
return 0;
453429
}
@@ -462,7 +438,6 @@ static void acpi_pad_remove(struct platform_device *pdev)
462438

463439
acpi_remove_notify_handler(device->handle,
464440
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
465-
acpi_pad_remove_sysfs(device);
466441
}
467442

468443
static const struct acpi_device_id pad_device_ids[] = {
@@ -475,6 +450,7 @@ static struct platform_driver acpi_pad_driver = {
475450
.probe = acpi_pad_probe,
476451
.remove_new = acpi_pad_remove,
477452
.driver = {
453+
.dev_groups = acpi_pad_groups,
478454
.name = "processor_aggregator",
479455
.acpi_match_table = pad_device_ids,
480456
},

0 commit comments

Comments
 (0)