Skip to content

Commit

Permalink
driver core: class: make class_register() take a const *
Browse files Browse the repository at this point in the history
Now that the class code is cleaned up to not modify the class pointer
registered with it, change class_register() to take a const * to allow
the structure to be placed into read-only memory.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/2023040248-customary-release-4aec@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Greg Kroah-Hartman committed Apr 3, 2023
1 parent 979207c commit 43a7206
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct subsys_private {
struct device *dev_root;

struct kset glue_dirs;
struct class *class;
const struct class *class;

struct lock_class_key lock_key;
};
Expand Down
6 changes: 3 additions & 3 deletions drivers/base/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
static void class_release(struct kobject *kobj)
{
struct subsys_private *cp = to_subsys_private(kobj);
struct class *class = cp->class;
const struct class *class = cp->class;

pr_debug("class '%s': release.\n", class->name);

Expand All @@ -110,7 +110,7 @@ static void class_release(struct kobject *kobj)
static const struct kobj_ns_type_operations *class_child_ns_type(const struct kobject *kobj)
{
const struct subsys_private *cp = to_subsys_private(kobj);
struct class *class = cp->class;
const struct class *class = cp->class;

return class->ns_type;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ static void klist_class_dev_put(struct klist_node *n)
put_device(dev);
}

int class_register(struct class *cls)
int class_register(const struct class *cls)
{
struct subsys_private *cp;
struct lock_class_key *key;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/device/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct class_dev_iter {
const struct device_type *type;
};

int __must_check class_register(struct class *class);
int __must_check class_register(const struct class *class);
void class_unregister(const struct class *class);
bool class_is_registered(const struct class *class);

Expand Down

0 comments on commit 43a7206

Please sign in to comment.