driver core: make struct device_driver and bus_type groups members constant arrays
cover driver core: make struct device_driver and bus_type groups members constant arrays
This series constifies the attribute group groups arrays in struct device_driver and bus_type, allowing to assign constant arrays.
Heiner Kallweit (3):
driver core: constify group arrays arguments in driver_add_groups and
driver_remove_groups
driver core: make struct bus_type groups members constant arrays device core: make struct device_driver groups members constant arrays
drivers/base/base.h | 6 ++++-- drivers/base/driver.c | 4 ++-- include/linux/device/bus.h | 6 +++--- include/linux/device/driver.h | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups
Constify the groups array argument in driver_add_groups and driver_remove_groups. This allows to pass constant arrays as arguments.
--- drivers/base/base.h | 6 ++++-- drivers/base/driver.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/base/base.h +4 -2
@@ -196,8 +196,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)
drivers/base/driver.c +2 -2
@@ -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); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerRe: [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups
Quoted 3 lines · Heiner Kallweit
Constify the groups array argument in
driver_add_groupsanddriver_remove_groups. This allows to pass constant arrays as arguments.
But do we? How down the * const depth do we want to go? :)
And does any of this series require any other fixups? If not, does it actually do anything?
thanks,
greg k-h
Re: [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups
Quoted 7 lines · Greg Kroah-Hartman
Quoted 3 lines · Heiner Kallweit
Constify the groups array argument in
driver_add_groupsanddriver_remove_groups. This allows to pass constant arrays as arguments.But do we? How down the * const depth do we want to go? :)
Not yet, but this is the next step. __ATTRIBUTE_GROUPS() would be complemented by a version creating a constant array. If something that de-facto is constant, lives in .rodata, then that's a good thing IMO.
Quoted 3 lines
And does any of this series require any other fixups? If not, does it actually do anything?
According to my checks no fixups are needed. And so far no CI complained about the series, what I interpret as a positive sign. This series doesn't do anything, it's a prerequisite for changes like the one described in aforementioned comment.
Quoted 3 lines
thanks,
greg k-h
Heiner
PATCH 2/3 driver core: make struct bus_type groups members constant arrays
In reply to Heiner KallweitConstify the groups arrays, allowing to assign constant arrays.
--- include/linux/device/bus.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/device/bus.h +3 -3
@@ -80,9 +80,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);
Signature · 1 line
2.53.0
PATCH 3/3 device core: make struct device_driver groups members constant arrays
In reply to Heiner KallweitConstify the groups arrays, allowing to assign constant arrays.
--- include/linux/device/driver.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/device/driver.h +2 -2
@@ -114,8 +114,8 @@ struct device_driver {void (*shutdown) (struct device *dev);int (*suspend) (struct device *dev,pm_message_t state);int (*resume) (struct device *dev); -const struct attribute_group **groups; -const struct attribute_group **dev_groups; +const struct attribute_group *const *groups; +const struct attribute_group *const *dev_groups;const struct dev_pm_ops *pm;void (*coredump) (struct device *dev);
Signature · 1 line
2.53.0