[PATCH 02/13] platform: add a dev_groups pointer to struct platform_driver

From: Greg Kroah-Hartman
Date: Thu Jul 25 2019 - 09:54:24 EST


As the driver core now provides the ability to directly add/remove
device groups when a driver is bound/unbound to a device, just pass that
pointer along to the driver core.

This allows us to fix up platform drivers to not need to create/remove
groups "by hand" anymore.

Cc: Richard Gong <richard.gong@xxxxxxxxxxxxxxx>
Cc: Romain Izard <romain.izard.pro@xxxxxxxxx>
Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Cc: Mans Rullgard <mans@xxxxxxxxx>
Cc: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/base/platform.c | 1 +
include/linux/platform_device.h | 1 +
2 files changed, 2 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 506a0175a5a7..21b3817569cd 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -667,6 +667,7 @@ int __platform_driver_register(struct platform_driver *drv,
drv->driver.probe = platform_drv_probe;
drv->driver.remove = platform_drv_remove;
drv->driver.shutdown = platform_drv_shutdown;
+ drv->driver.dev_groups = drv->dev_groups;

return driver_register(&drv->driver);
}
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 9bc36b589827..9945a08b872a 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -189,6 +189,7 @@ struct platform_driver {
int (*resume)(struct platform_device *);
struct device_driver driver;
const struct platform_device_id *id_table;
+ const struct attribute_group **dev_groups;
bool prevent_deferred_probe;
};

--
2.22.0