Skip to content

Commit 67c1ba5

Browse files
committed
driver core: module: make module_[add|remove]_driver take a const *
The functions module_add_driver() and module_remove_driver() do not modify the struct device_driver structure directly, so they are safe to be marked as a constant pointer type. Cc: "Rafael J. Wysocki" <[email protected]> Link: https://lore.kernel.org/r/2024070850-entering-grandson-205e@gregkh Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f8fb469 commit 67c1ba5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/base/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ extern struct kset *devices_kset;
192192
void devices_kset_move_last(struct device *dev);
193193

194194
#if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS)
195-
int module_add_driver(struct module *mod, struct device_driver *drv);
196-
void module_remove_driver(struct device_driver *drv);
195+
int module_add_driver(struct module *mod, const struct device_driver *drv);
196+
void module_remove_driver(const struct device_driver *drv);
197197
#else
198198
static inline int module_add_driver(struct module *mod,
199199
struct device_driver *drv)

drivers/base/module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/string.h>
1010
#include "base.h"
1111

12-
static char *make_driver_name(struct device_driver *drv)
12+
static char *make_driver_name(const struct device_driver *drv)
1313
{
1414
char *driver_name;
1515

@@ -30,7 +30,7 @@ static void module_create_drivers_dir(struct module_kobject *mk)
3030
mutex_unlock(&drivers_dir_mutex);
3131
}
3232

33-
int module_add_driver(struct module *mod, struct device_driver *drv)
33+
int module_add_driver(struct module *mod, const struct device_driver *drv)
3434
{
3535
char *driver_name;
3636
struct module_kobject *mk = NULL;
@@ -89,7 +89,7 @@ int module_add_driver(struct module *mod, struct device_driver *drv)
8989
return ret;
9090
}
9191

92-
void module_remove_driver(struct device_driver *drv)
92+
void module_remove_driver(const struct device_driver *drv)
9393
{
9494
struct module_kobject *mk = NULL;
9595
char *driver_name;

0 commit comments

Comments
 (0)