* [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups
2026-03-16 22:08 [PATCH 0/3] driver core: make struct device_driver and bus_type groups members constant arrays Heiner Kallweit
@ 2026-03-16 22:09 ` Heiner Kallweit
2026-04-02 15:11 ` Greg Kroah-Hartman
2026-03-16 22:10 ` [PATCH 2/3] driver core: make struct bus_type groups members constant arrays Heiner Kallweit
2026-03-16 22:11 ` [PATCH 3/3] device core: make struct device_driver " Heiner Kallweit
2 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2026-03-16 22:09 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich; +Cc: driver-core
Constify the groups array argument in driver_add_groups and
driver_remove_groups. This allows to pass constant arrays as
arguments.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/base/base.h | 6 ++++--
drivers/base/driver.c | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 3bc8e6fd0..747530465 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -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)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 8ab010ddf..c5ebf1fda 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);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups
2026-03-16 22:09 ` [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups Heiner Kallweit
@ 2026-04-02 15:11 ` Greg Kroah-Hartman
2026-04-02 16:25 ` Heiner Kallweit
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2026-04-02 15:11 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: Rafael J. Wysocki, Danilo Krummrich, driver-core
On Mon, Mar 16, 2026 at 11:09:37PM +0100, Heiner Kallweit wrote:
> Constify the groups array argument in driver_add_groups and
> driver_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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups
2026-04-02 15:11 ` Greg Kroah-Hartman
@ 2026-04-02 16:25 ` Heiner Kallweit
0 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2026-04-02 16:25 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Rafael J. Wysocki, Danilo Krummrich, driver-core
On 02.04.2026 17:11, Greg Kroah-Hartman wrote:
> On Mon, Mar 16, 2026 at 11:09:37PM +0100, Heiner Kallweit wrote:
>> Constify the groups array argument in driver_add_groups and
>> driver_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.
> 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.
> thanks,
>
> greg k-h
Heiner
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] driver core: make struct bus_type groups members constant arrays
2026-03-16 22:08 [PATCH 0/3] driver core: make struct device_driver and bus_type groups members constant arrays Heiner Kallweit
2026-03-16 22:09 ` [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups Heiner Kallweit
@ 2026-03-16 22:10 ` Heiner Kallweit
2026-03-16 22:11 ` [PATCH 3/3] device core: make struct device_driver " Heiner Kallweit
2 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2026-03-16 22:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich; +Cc: driver-core
Constify the groups arrays, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/device/bus.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 63de5f053..c6a3e16b7 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -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);
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] device core: make struct device_driver groups members constant arrays
2026-03-16 22:08 [PATCH 0/3] driver core: make struct device_driver and bus_type groups members constant arrays Heiner Kallweit
2026-03-16 22:09 ` [PATCH 1/3] driver core: constify group arrays arguments in driver_add_groups and driver_remove_groups Heiner Kallweit
2026-03-16 22:10 ` [PATCH 2/3] driver core: make struct bus_type groups members constant arrays Heiner Kallweit
@ 2026-03-16 22:11 ` Heiner Kallweit
2 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2026-03-16 22:11 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich; +Cc: driver-core
Constify the groups arrays, allowing to assign constant arrays.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/device/driver.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index bbc67ec51..c882daaef 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -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);
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread