HID: make hid_bus_type const
Subsystems (2)
PATCH 2/3 HID: make ishtp_cl_bus_type const
In reply to Greg Kroah-HartmanNow that the driver core can properly handle constant struct bus_type, move the ishtp_cl_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.
--- drivers/hid/intel-ish-hid/ishtp/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/intel-ish-hid/ishtp/bus.c +1 -1
@@ -378,7 +378,7 @@ static const struct dev_pm_ops ishtp_cl_bus_dev_pm_ops = { .restore = ishtp_cl_device_resume, }; -static struct bus_type ishtp_cl_bus_type = { +static const struct bus_type ishtp_cl_bus_type = { .name ="ishtp" , .dev_groups = ishtp_cl_dev_groups, .probe = ishtp_cl_device_probe,
Signature · 1 line
2.43.0
PATCH 1/3 HID: make hid_bus_type const
Now that the driver core can properly handle constant struct bus_type, move the hid_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.
--- drivers/hid/hid-core.c | 2 +- include/linux/hid.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-core.c +1 -1
@@ -2749,7 +2749,7 @@ static int hid_uevent(const struct device *dev, struct kobj_uevent_env *env)return 0 ; } -struct bus_type hid_bus_type = { +const struct bus_type hid_bus_type = { .name ="hid" , .dev_groups = hid_dev_groups, .drv_groups = hid_drv_groups,
include/linux/hid.h +1 -1
@@ -912,7 +912,7 @@ extern bool hid_ignore(struct hid_device *);extern int hid_add_device (struct hid_device *);extern void hid_destroy_device (struct hid_device *); -extern struct bus_type hid_bus_type; +extern const struct bus_type hid_bus_type;extern int __must_check __hid_register_driver (struct hid_driver *,struct module *,const char *mod_name);
Signature · 1 line
2.43.0
PATCH 3/3 HID: bpf: make bus_type const in struct hid_bpf_ops
The struct bus_type pointer in hid_bpf_ops just passes the pointer to the driver core, and the driver core can handle, and expects, a constant pointer, so also make the pointer constant in hid_bpf_ops.
Part of the process of moving all usages of struct bus_type to be constant to move them all to read-only memory.
--- include/linux/hid_bpf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/hid_bpf.h +1 -1
@@ -115,7 +115,7 @@ struct hid_bpf_ops { size_t len, enum hid_report_type rtype, enum hid_class_request reqtype);struct module *owner; -struct bus_type *bus_type; +const struct bus_type *bus_type; };extern struct hid_bpf_ops *hid_bpf_ops;
Signature · 1 line
2.43.0
Re: [PATCH 2/3] HID: make ishtp_cl_bus_type const
In reply to Greg Kroah-HartmanQuoted 7 lines · Greg Kroah-Hartman
Now that the driver core can properly handle constant struct
bus_type,
move theishtp_cl_bus_typevariable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.
Quoted 5 lines
Cc Srinivas Pandruvada <[email protected]>Cc Jiri Kosina <[email protected]>Cc Benjamin Tissoires <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 19 lines
---
drivers/hid/intel-ish-hid/ishtp/bus.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/intel-ish-hid/ishtp/bus.c +0
-0@@ -378,7 +378,7 @@ static const struct dev_pm_ops ishtp_cl_bus_dev_pm_ops = { .restore = ishtp_cl_device_resume, };drivers/hid/intel-ish-hid/ishtp/bus.c +1
-1-static struct bus_type ishtp_cl_bus_type = { +static const struct bus_type ishtp_cl_bus_type = {.name = "ishtp",
.dev_groups =ishtp_cl_dev_groups,
.probe =ishtp_cl_device_probe,
Jiri Kosina
AppliedQuoted 3 lines · Greg Kroah-Hartman
Now that the driver core can properly handle constant struct
bus_type, move thehid_bus_typevariable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.
I have applied all three patches to hid.git now. Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 7 lines · Jiri Kosina
Quoted 3 lines · Greg Kroah-Hartman
Now that the driver core can properly handle constant struct
bus_type, move thehid_bus_typevariable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.I have applied all three patches to hid.git now. Thanks,
Thanks!