[PATCH v1] ACPI: TAD: Use dev_groups in struct device_driver

Rafael J. Wysocki posted 1 patch 4 weeks ago
drivers/acpi/acpi_tad.c |   15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
[PATCH v1] ACPI: TAD: Use dev_groups in struct device_driver
Posted by Rafael J. Wysocki 4 weeks ago
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Instead of creating and removing the device sysfs attributes directly
during probe and remove of the driver, respectively, use dev_groups in
struct device_driver to point to the attribute definitions and let the
core take care of creating and removing them.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This is on top of linux-next.

---
 drivers/acpi/acpi_tad.c |   15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -586,6 +586,11 @@ static const struct attribute_group acpi
 	.is_visible = acpi_tad_attr_is_visible,
 };
 
+static const struct attribute_group *acpi_tad_attr_groups[] = {
+	&acpi_tad_attr_group,
+	NULL,
+};
+
 #ifdef CONFIG_RTC_CLASS
 /* RTC class device interface */
 
@@ -663,8 +668,6 @@ static void acpi_tad_remove(struct platf
 
 	device_init_wakeup(dev, false);
 
-	sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group);
-
 	scoped_guard(pm_runtime_noresume, dev) {
 		if (dd->capabilities & ACPI_TAD_AC_WAKE) {
 			acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
@@ -687,7 +690,6 @@ static int acpi_tad_probe(struct platfor
 	struct acpi_tad_driver_data *dd;
 	acpi_status status;
 	unsigned long long caps;
-	int ret;
 
 	/*
 	 * Initialization failure messages are mostly about firmware issues, so
@@ -731,12 +733,6 @@ static int acpi_tad_probe(struct platfor
 	pm_runtime_enable(dev);
 	pm_runtime_suspend(dev);
 
-	ret = sysfs_create_group(&dev->kobj, &acpi_tad_attr_group);
-	if (ret) {
-		acpi_tad_remove(pdev);
-		return ret;
-	}
-
 	if (caps & ACPI_TAD_RT)
 		acpi_tad_register_rtc(dev);
 
@@ -752,6 +748,7 @@ static struct platform_driver acpi_tad_d
 	.driver = {
 		.name = "acpi-tad",
 		.acpi_match_table = acpi_tad_ids,
+		.dev_groups = acpi_tad_attr_groups,
 	},
 	.probe = acpi_tad_probe,
 	.remove = acpi_tad_remove,