[PATCH RFC 07/10] driver core: make struct bus_type groups members constant arrays

Heiner Kallweit posted 10 patches 1 month, 2 weeks ago
[PATCH RFC 07/10] driver core: make struct bus_type groups members constant arrays
Posted by Heiner Kallweit 1 month, 2 weeks ago
Constify the groupss arrays, allowing to assign constant arrays.
As a prerequisite this requires to constify the groups array argument
in few functions.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/base/base.h        | 6 ++++--
 drivers/base/driver.c      | 4 ++--
 include/linux/device/bus.h | 6 +++---
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index 8c2175820da..b6852ba45cd 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -202,8 +202,10 @@ static inline void dev_sync_state(struct device *dev)
 		dev->driver->sync_state(dev);
 }
 
-int driver_add_groups(const struct device_driver *drv, const struct attribute_group **groups);
-void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups);
+int driver_add_groups(const struct device_driver *drv,
+		      const struct attribute_group *const *groups);
+void driver_remove_groups(const struct device_driver *drv,
+			  const struct attribute_group *const *groups);
 void device_driver_detach(struct device *dev);
 
 static inline void device_set_driver(struct device *dev, const struct device_driver *drv)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 8ab010ddf70..c5ebf1fdad7 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -203,13 +203,13 @@ void driver_remove_file(const struct device_driver *drv,
 EXPORT_SYMBOL_GPL(driver_remove_file);
 
 int driver_add_groups(const struct device_driver *drv,
-		      const struct attribute_group **groups)
+		      const struct attribute_group *const *groups)
 {
 	return sysfs_create_groups(&drv->p->kobj, groups);
 }
 
 void driver_remove_groups(const struct device_driver *drv,
-			  const struct attribute_group **groups)
+			  const struct attribute_group *const *groups)
 {
 	sysfs_remove_groups(&drv->p->kobj, groups);
 }
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 99c3c83ea52..00d8a080f93 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -78,9 +78,9 @@ struct fwnode_handle;
 struct bus_type {
 	const char		*name;
 	const char		*dev_name;
-	const struct attribute_group **bus_groups;
-	const struct attribute_group **dev_groups;
-	const struct attribute_group **drv_groups;
+	const struct attribute_group *const *bus_groups;
+	const struct attribute_group *const *dev_groups;
+	const struct attribute_group *const *drv_groups;
 
 	int (*match)(struct device *dev, const struct device_driver *drv);
 	int (*uevent)(const struct device *dev, struct kobj_uevent_env *env);
-- 
2.53.0