mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
usb: core: constify the struct device_type usage
Since commit aed65af1cc
("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
usb_device_type, usb_if_device_type, usb_ep_device_type and
usb_port_device_type variables to be constant structures as well, placing
it into read-only memory which can not be modified at runtime.
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240218-device_cleanup-usb-v1-4-77423c4da262@marliere.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3e383260df
commit
1ab40abcdb
@ -141,7 +141,7 @@ static void ep_device_release(struct device *dev)
|
||||
kfree(ep_dev);
|
||||
}
|
||||
|
||||
struct device_type usb_ep_device_type = {
|
||||
const struct device_type usb_ep_device_type = {
|
||||
.name = "usb_endpoint",
|
||||
.release = ep_device_release,
|
||||
};
|
||||
|
@ -1849,7 +1849,7 @@ static int usb_if_uevent(const struct device *dev, struct kobj_uevent_env *env)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct device_type usb_if_device_type = {
|
||||
const struct device_type usb_if_device_type = {
|
||||
.name = "usb_interface",
|
||||
.release = usb_release_interface,
|
||||
.uevent = usb_if_uevent,
|
||||
|
@ -429,7 +429,7 @@ static const struct dev_pm_ops usb_port_pm_ops = {
|
||||
#endif
|
||||
};
|
||||
|
||||
struct device_type usb_port_device_type = {
|
||||
const struct device_type usb_port_device_type = {
|
||||
.name = "usb_port",
|
||||
.release = usb_port_device_release,
|
||||
.pm = &usb_port_pm_ops,
|
||||
|
@ -592,7 +592,7 @@ static char *usb_devnode(const struct device *dev,
|
||||
usb_dev->bus->busnum, usb_dev->devnum);
|
||||
}
|
||||
|
||||
struct device_type usb_device_type = {
|
||||
const struct device_type usb_device_type = {
|
||||
.name = "usb_device",
|
||||
.release = usb_release_dev,
|
||||
.uevent = usb_dev_uevent,
|
||||
|
@ -144,10 +144,10 @@ static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
|
||||
extern const struct class usbmisc_class;
|
||||
extern const struct bus_type usb_bus_type;
|
||||
extern struct mutex usb_port_peer_mutex;
|
||||
extern struct device_type usb_device_type;
|
||||
extern struct device_type usb_if_device_type;
|
||||
extern struct device_type usb_ep_device_type;
|
||||
extern struct device_type usb_port_device_type;
|
||||
extern const struct device_type usb_device_type;
|
||||
extern const struct device_type usb_if_device_type;
|
||||
extern const struct device_type usb_ep_device_type;
|
||||
extern const struct device_type usb_port_device_type;
|
||||
extern struct usb_device_driver usb_generic_driver;
|
||||
|
||||
static inline int is_usb_device(const struct device *dev)
|
||||
|
Loading…
Reference in New Issue
Block a user