Skip to content

Commit a4735d4

Browse files
rbmarlieredtor
authored andcommitted
Input: make input_class constant
Since commit 43a7206 ("driver core: class: make class_register() take a const *"), the driver core allows for struct class to be in read-only memory, so move the input_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> Link: https://lore.kernel.org/r/20240305-class_cleanup-input-v1-1-0c3d950c25db@marliere.net Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 1099a04 commit a4735d4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/input/input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ static char *input_devnode(const struct device *dev, umode_t *mode)
19181918
return kasprintf(GFP_KERNEL, "input/%s", dev_name(dev));
19191919
}
19201920

1921-
struct class input_class = {
1921+
const struct class input_class = {
19221922
.name = "input",
19231923
.devnode = input_devnode,
19241924
};

include/linux/input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void input_enable_softrepeat(struct input_dev *dev, int delay, int period);
514514

515515
bool input_device_enabled(struct input_dev *dev);
516516

517-
extern struct class input_class;
517+
extern const struct class input_class;
518518

519519
/**
520520
* struct ff_device - force-feedback part of an input device

0 commit comments

Comments
 (0)