Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver core: make struct device_type.uevent() take a const *

The uevent() callback in struct device_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Chaitanya Kulkarni <kch@nvidia.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Mark Gross <markgross@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Maximilian Luz <luzmaximilian@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: Sean Young <sean@mess.org>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Won Chung <wonchung@google.com>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Vinod Koul <vkoul@kernel.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-6-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+53 -54
+2 -2
block/partitions/core.c
··· 254 254 iput(dev_to_bdev(dev)->bd_inode); 255 255 } 256 256 257 - static int part_uevent(struct device *dev, struct kobj_uevent_env *env) 257 + static int part_uevent(const struct device *dev, struct kobj_uevent_env *env) 258 258 { 259 - struct block_device *part = dev_to_bdev(dev); 259 + const struct block_device *part = dev_to_bdev(dev); 260 260 261 261 add_uevent_var(env, "PARTN=%u", part->bd_partno); 262 262 if (part->bd_meta_info && part->bd_meta_info->volname[0])
+4 -4
drivers/acpi/device_sysfs.c
··· 133 133 * -EINVAL: output error 134 134 * -ENOMEM: output is truncated 135 135 */ 136 - static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias, 136 + static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalias, 137 137 int size) 138 138 { 139 139 int len; ··· 191 191 * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of 192 192 * ACPI/PNP IDs. 193 193 */ 194 - static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias, 194 + static int create_of_modalias(const struct acpi_device *acpi_dev, char *modalias, 195 195 int size) 196 196 { 197 197 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; ··· 239 239 return len; 240 240 } 241 241 242 - int __acpi_device_uevent_modalias(struct acpi_device *adev, 242 + int __acpi_device_uevent_modalias(const struct acpi_device *adev, 243 243 struct kobj_uevent_env *env) 244 244 { 245 245 int len; ··· 277 277 * Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with 278 278 * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001". 279 279 */ 280 - int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) 280 + int acpi_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env) 281 281 { 282 282 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env); 283 283 }
+1 -1
drivers/acpi/internal.h
··· 120 120 Device Matching and Notification 121 121 -------------------------------------------------------------------------- */ 122 122 struct acpi_device *acpi_companion_match(const struct device *dev); 123 - int __acpi_device_uevent_modalias(struct acpi_device *adev, 123 + int __acpi_device_uevent_modalias(const struct acpi_device *adev, 124 124 struct kobj_uevent_env *env); 125 125 126 126 /* --------------------------------------------------------------------------
+4 -4
drivers/firewire/core-device.c
··· 133 133 } 134 134 } 135 135 136 - static void get_modalias_ids(struct fw_unit *unit, int *id) 136 + static void get_modalias_ids(const struct fw_unit *unit, int *id) 137 137 { 138 138 get_ids(&fw_parent_device(unit)->config_rom[5], id); 139 139 get_ids(unit->directory, id); ··· 195 195 driver->remove(fw_unit(dev)); 196 196 } 197 197 198 - static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) 198 + static int get_modalias(const struct fw_unit *unit, char *buffer, size_t buffer_size) 199 199 { 200 200 int id[] = {0, 0, 0, 0}; 201 201 ··· 206 206 id[0], id[1], id[2], id[3]); 207 207 } 208 208 209 - static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) 209 + static int fw_unit_uevent(const struct device *dev, struct kobj_uevent_env *env) 210 210 { 211 - struct fw_unit *unit = fw_unit(dev); 211 + const struct fw_unit *unit = fw_unit(dev); 212 212 char modalias[64]; 213 213 214 214 get_modalias(unit, modalias, sizeof(modalias));
+1 -1
drivers/gpu/drm/display/drm_dp_aux_bus.c
··· 161 161 kfree(aux_ep_with_data); 162 162 } 163 163 164 - static int dp_aux_ep_dev_modalias(struct device *dev, struct kobj_uevent_env *env) 164 + static int dp_aux_ep_dev_modalias(const struct device *dev, struct kobj_uevent_env *env) 165 165 { 166 166 return of_device_uevent_modalias(dev, env); 167 167 }
+2 -2
drivers/i2c/i2c-core-base.c
··· 136 136 return 0; 137 137 } 138 138 139 - static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env) 139 + static int i2c_device_uevent(const struct device *dev, struct kobj_uevent_env *env) 140 140 { 141 - struct i2c_client *client = to_i2c_client(dev); 141 + const struct i2c_client *client = to_i2c_client(dev); 142 142 int rc; 143 143 144 144 rc = of_device_uevent_modalias(dev, env);
+1 -1
drivers/i3c/device.c
··· 78 78 * 79 79 * Retrieve I3C dev info. 80 80 */ 81 - void i3c_device_get_info(struct i3c_device *dev, 81 + void i3c_device_get_info(const struct i3c_device *dev, 82 82 struct i3c_device_info *info) 83 83 { 84 84 if (!info)
+2 -2
drivers/i3c/master.c
··· 273 273 }; 274 274 ATTRIBUTE_GROUPS(i3c_device); 275 275 276 - static int i3c_device_uevent(struct device *dev, struct kobj_uevent_env *env) 276 + static int i3c_device_uevent(const struct device *dev, struct kobj_uevent_env *env) 277 277 { 278 - struct i3c_device *i3cdev = dev_to_i3cdev(dev); 278 + const struct i3c_device *i3cdev = dev_to_i3cdev(dev); 279 279 struct i3c_device_info devinfo; 280 280 u16 manuf, part, ext; 281 281
+8 -8
drivers/input/input.c
··· 1372 1372 INPUT_DEV_STRING_ATTR_SHOW(uniq); 1373 1373 1374 1374 static int input_print_modalias_bits(char *buf, int size, 1375 - char name, unsigned long *bm, 1375 + char name, const unsigned long *bm, 1376 1376 unsigned int min_bit, unsigned int max_bit) 1377 1377 { 1378 1378 int len = 0, i; ··· 1384 1384 return len; 1385 1385 } 1386 1386 1387 - static int input_print_modalias(char *buf, int size, struct input_dev *id, 1387 + static int input_print_modalias(char *buf, int size, const struct input_dev *id, 1388 1388 int add_cr) 1389 1389 { 1390 1390 int len; ··· 1432 1432 } 1433 1433 static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); 1434 1434 1435 - static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, 1435 + static int input_print_bitmap(char *buf, int buf_size, const unsigned long *bitmap, 1436 1436 int max, int add_cr); 1437 1437 1438 1438 static ssize_t input_dev_show_properties(struct device *dev, ··· 1524 1524 .attrs = input_dev_id_attrs, 1525 1525 }; 1526 1526 1527 - static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, 1527 + static int input_print_bitmap(char *buf, int buf_size, const unsigned long *bitmap, 1528 1528 int max, int add_cr) 1529 1529 { 1530 1530 int i; ··· 1621 1621 * device bitfields. 1622 1622 */ 1623 1623 static int input_add_uevent_bm_var(struct kobj_uevent_env *env, 1624 - const char *name, unsigned long *bitmap, int max) 1624 + const char *name, const unsigned long *bitmap, int max) 1625 1625 { 1626 1626 int len; 1627 1627 ··· 1639 1639 } 1640 1640 1641 1641 static int input_add_uevent_modalias_var(struct kobj_uevent_env *env, 1642 - struct input_dev *dev) 1642 + const struct input_dev *dev) 1643 1643 { 1644 1644 int len; 1645 1645 ··· 1677 1677 return err; \ 1678 1678 } while (0) 1679 1679 1680 - static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) 1680 + static int input_dev_uevent(const struct device *device, struct kobj_uevent_env *env) 1681 1681 { 1682 - struct input_dev *dev = to_input_dev(device); 1682 + const struct input_dev *dev = to_input_dev(device); 1683 1683 1684 1684 INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x", 1685 1685 dev->id.bustype, dev->id.vendor,
+1 -1
drivers/media/rc/rc-main.c
··· 1614 1614 kfree(dev); 1615 1615 } 1616 1616 1617 - static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) 1617 + static int rc_dev_uevent(const struct device *device, struct kobj_uevent_env *env) 1618 1618 { 1619 1619 struct rc_dev *dev = to_rc_dev(device); 1620 1620 int ret = 0;
+2 -2
drivers/platform/surface/aggregator/bus.c
··· 35 35 }; 36 36 ATTRIBUTE_GROUPS(ssam_device); 37 37 38 - static int ssam_device_uevent(struct device *dev, struct kobj_uevent_env *env) 38 + static int ssam_device_uevent(const struct device *dev, struct kobj_uevent_env *env) 39 39 { 40 - struct ssam_device *sdev = to_ssam_device(dev); 40 + const struct ssam_device *sdev = to_ssam_device(dev); 41 41 42 42 return add_uevent_var(env, "MODALIAS=ssam:d%02Xc%02Xt%02Xi%02Xf%02X", 43 43 sdev->uid.domain, sdev->uid.category,
+2 -2
drivers/soundwire/bus_type.c
··· 58 58 slave->id.sdw_version, slave->id.class_id); 59 59 } 60 60 61 - int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env) 61 + int sdw_slave_uevent(const struct device *dev, struct kobj_uevent_env *env) 62 62 { 63 - struct sdw_slave *slave = dev_to_sdw_dev(dev); 63 + const struct sdw_slave *slave = dev_to_sdw_dev(dev); 64 64 char modalias[32]; 65 65 66 66 sdw_slave_modalias(slave, modalias, sizeof(modalias));
+2 -2
drivers/thunderbolt/switch.c
··· 2176 2176 kfree(sw); 2177 2177 } 2178 2178 2179 - static int tb_switch_uevent(struct device *dev, struct kobj_uevent_env *env) 2179 + static int tb_switch_uevent(const struct device *dev, struct kobj_uevent_env *env) 2180 2180 { 2181 - struct tb_switch *sw = tb_to_switch(dev); 2181 + const struct tb_switch *sw = tb_to_switch(dev); 2182 2182 const char *type; 2183 2183 2184 2184 if (sw->config.thunderbolt_version == USB4_VERSION_1_0) {
+1 -1
drivers/thunderbolt/tb.h
··· 815 815 return dev->type == &tb_switch_type; 816 816 } 817 817 818 - static inline struct tb_switch *tb_to_switch(struct device *dev) 818 + static inline struct tb_switch *tb_to_switch(const struct device *dev) 819 819 { 820 820 if (tb_is_switch(dev)) 821 821 return container_of(dev, struct tb_switch, dev);
+3 -3
drivers/thunderbolt/xdomain.c
··· 881 881 } 882 882 static DEVICE_ATTR_RO(key); 883 883 884 - static int get_modalias(struct tb_service *svc, char *buf, size_t size) 884 + static int get_modalias(const struct tb_service *svc, char *buf, size_t size) 885 885 { 886 886 return snprintf(buf, size, "tbsvc:k%sp%08Xv%08Xr%08X", svc->key, 887 887 svc->prtcid, svc->prtcvers, svc->prtcrevs); ··· 953 953 NULL, 954 954 }; 955 955 956 - static int tb_service_uevent(struct device *dev, struct kobj_uevent_env *env) 956 + static int tb_service_uevent(const struct device *dev, struct kobj_uevent_env *env) 957 957 { 958 - struct tb_service *svc = container_of(dev, struct tb_service, dev); 958 + const struct tb_service *svc = container_of_const(dev, struct tb_service, dev); 959 959 char modalias[64]; 960 960 961 961 get_modalias(svc, modalias, sizeof(modalias));
+1 -1
drivers/tty/serdev/core.c
··· 42 42 }; 43 43 ATTRIBUTE_GROUPS(serdev_device); 44 44 45 - static int serdev_device_uevent(struct device *dev, struct kobj_uevent_env *env) 45 + static int serdev_device_uevent(const struct device *dev, struct kobj_uevent_env *env) 46 46 { 47 47 int rc; 48 48
+4 -4
drivers/usb/core/message.c
··· 1819 1819 } 1820 1820 } 1821 1821 1822 - static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) 1822 + static int usb_if_uevent(const struct device *dev, struct kobj_uevent_env *env) 1823 1823 { 1824 - struct usb_device *usb_dev; 1825 - struct usb_interface *intf; 1826 - struct usb_host_interface *alt; 1824 + const struct usb_device *usb_dev; 1825 + const struct usb_interface *intf; 1826 + const struct usb_host_interface *alt; 1827 1827 1828 1828 intf = to_usb_interface(dev); 1829 1829 usb_dev = interface_to_usbdev(intf);
+2 -2
drivers/usb/core/usb.c
··· 423 423 kfree(udev); 424 424 } 425 425 426 - static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) 426 + static int usb_dev_uevent(const struct device *dev, struct kobj_uevent_env *env) 427 427 { 428 - struct usb_device *usb_dev; 428 + const struct usb_device *usb_dev; 429 429 430 430 usb_dev = to_usb_device(dev); 431 431
+3 -3
drivers/usb/phy/phy.c
··· 80 80 return ERR_PTR(-EPROBE_DEFER); 81 81 } 82 82 83 - static struct usb_phy *__device_to_usb_phy(struct device *dev) 83 + static struct usb_phy *__device_to_usb_phy(const struct device *dev) 84 84 { 85 85 struct usb_phy *usb_phy; 86 86 ··· 145 145 kobject_uevent(&usb_phy->dev->kobj, KOBJ_CHANGE); 146 146 } 147 147 148 - static int usb_phy_uevent(struct device *dev, struct kobj_uevent_env *env) 148 + static int usb_phy_uevent(const struct device *dev, struct kobj_uevent_env *env) 149 149 { 150 - struct usb_phy *usb_phy; 150 + const struct usb_phy *usb_phy; 151 151 char uchger_state[50] = { 0 }; 152 152 char uchger_type[50] = { 0 }; 153 153 unsigned long flags;
+1 -2
drivers/usb/roles/class.c
··· 274 274 NULL, 275 275 }; 276 276 277 - static int 278 - usb_role_switch_uevent(struct device *dev, struct kobj_uevent_env *env) 277 + static int usb_role_switch_uevent(const struct device *dev, struct kobj_uevent_env *env) 279 278 { 280 279 int ret; 281 280
+1 -1
drivers/usb/typec/class.c
··· 1737 1737 NULL 1738 1738 }; 1739 1739 1740 - static int typec_uevent(struct device *dev, struct kobj_uevent_env *env) 1740 + static int typec_uevent(const struct device *dev, struct kobj_uevent_env *env) 1741 1741 { 1742 1742 int ret; 1743 1743
+2 -2
include/linux/acpi.h
··· 723 723 const void *acpi_device_get_match_data(const struct device *dev); 724 724 extern bool acpi_driver_match_device(struct device *dev, 725 725 const struct device_driver *drv); 726 - int acpi_device_uevent_modalias(struct device *, struct kobj_uevent_env *); 726 + int acpi_device_uevent_modalias(const struct device *, struct kobj_uevent_env *); 727 727 int acpi_device_modalias(struct device *, char *, int); 728 728 729 729 struct platform_device *acpi_create_platform_device(struct acpi_device *, ··· 958 958 return NULL; 959 959 } 960 960 961 - static inline int acpi_device_uevent_modalias(struct device *dev, 961 + static inline int acpi_device_uevent_modalias(const struct device *dev, 962 962 struct kobj_uevent_env *env) 963 963 { 964 964 return -ENODEV;
+1 -1
include/linux/device.h
··· 88 88 struct device_type { 89 89 const char *name; 90 90 const struct attribute_group **groups; 91 - int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 91 + int (*uevent)(const struct device *dev, struct kobj_uevent_env *env); 92 92 char *(*devnode)(struct device *dev, umode_t *mode, 93 93 kuid_t *uid, kgid_t *gid); 94 94 void (*release)(struct device *dev);
+1 -1
include/linux/i3c/device.h
··· 303 303 304 304 int i3c_device_do_setdasa(struct i3c_device *dev); 305 305 306 - void i3c_device_get_info(struct i3c_device *dev, struct i3c_device_info *info); 306 + void i3c_device_get_info(const struct i3c_device *dev, struct i3c_device_info *info); 307 307 308 308 struct i3c_ibi_payload { 309 309 unsigned int len;
+1 -1
include/linux/soundwire/sdw_type.h
··· 21 21 int __sdw_register_driver(struct sdw_driver *drv, struct module *owner); 22 22 void sdw_unregister_driver(struct sdw_driver *drv); 23 23 24 - int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env); 24 + int sdw_slave_uevent(const struct device *dev, struct kobj_uevent_env *env); 25 25 26 26 /** 27 27 * module_sdw_driver() - Helper macro for registering a Soundwire driver