Skip to content

Commit

Permalink
driver core: module: make module_[add|remove]_driver take a const *
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gregkh committed Jul 10, 2024
1 parent f8fb469 commit 67c1ba5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions drivers/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ extern struct kset *devices_kset;
void devices_kset_move_last(struct device *dev);

#if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS)
int module_add_driver(struct module *mod, struct device_driver *drv);
void module_remove_driver(struct device_driver *drv);
int module_add_driver(struct module *mod, const struct device_driver *drv);
void module_remove_driver(const struct device_driver *drv);
#else
static inline int module_add_driver(struct module *mod,
struct device_driver *drv)
Expand Down
6 changes: 3 additions & 3 deletions drivers/base/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/string.h>
#include "base.h"

static char *make_driver_name(struct device_driver *drv)
static char *make_driver_name(const struct device_driver *drv)
{
char *driver_name;

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

int module_add_driver(struct module *mod, struct device_driver *drv)
int module_add_driver(struct module *mod, const struct device_driver *drv)
{
char *driver_name;
struct module_kobject *mk = NULL;
Expand Down Expand Up @@ -89,7 +89,7 @@ int module_add_driver(struct module *mod, struct device_driver *drv)
return ret;
}

void module_remove_driver(struct device_driver *drv)
void module_remove_driver(const struct device_driver *drv)
{
struct module_kobject *mk = NULL;
char *driver_name;
Expand Down

0 comments on commit 67c1ba5

Please sign in to comment.