driver core: make struct class.dev_uevent() take a const *
Subsystems (55)
Greg Kroah-Hartman
maintainerPATCH 1/5 driver core: make struct class.dev_uevent() take a const *
The dev_uevent() in struct class 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.
--- block/genhd.c | 4 ++-- drivers/base/firmware_loader/sysfs.c | 6 +++--- drivers/base/firmware_loader/sysfs.h | 2 +- drivers/firmware/dmi-id.c | 2 +- drivers/gnss/core.c | 6 +++--- drivers/infiniband/core/device.c | 2 +- drivers/isdn/mISDN/core.c | 4 ++-- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/nvme/host/core.c | 4 ++-- drivers/pcmcia/cs.c | 4 ++-- drivers/power/supply/power_supply.h | 2 +- drivers/power/supply/power_supply_sysfs.c | 8 ++++---- drivers/usb/gadget/udc/core.c | 4 ++-- include/linux/device/class.h | 2 +- include/linux/mISDNif.h | 2 +- net/atm/atm_sysfs.c | 4 ++-- net/core/net-sysfs.c | 4 ++-- net/rfkill/core.c | 2 +- 18 files changed, 33 insertions(+), 33 deletions(-)
block/genhd.c +2 -2
@@ -1181,9 +1181,9 @@ static void disk_release(struct device *dev)iput (disk->part0->bd_inode);/* frees the disk */ } -static int block_uevent (struct device *dev,struct kobj_uevent_env *env) +static int block_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gendisk *disk =dev_to_disk (dev); +const struct gendisk *disk =dev_to_disk (dev);return add_uevent_var (env,"DISKSEQ=%llu" , disk->diskseq); }
drivers/base/firmware_loader/sysfs.c +3 -3
@@ -64,7 +64,7 @@ static struct attribute *firmware_class_attrs[] = { };ATTRIBUTE_GROUPS (firmware_class); -static int do_firmware_uevent (struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) +static int do_firmware_uevent (const struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) {if (add_uevent_var (env,"FIRMWARE=%s" , fw_sysfs->fw_priv->fw_name))return -ENOMEM ;
@@ -76,9 +76,9 @@ static int do_firmware_uevent(struct fw_sysfs *fw_sysfs, struct kobj_uevent_envreturn 0 ; } -static int firmware_uevent (struct device *dev,struct kobj_uevent_env *env) +static int firmware_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev); +const struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev);int err =0 ;mutex_lock (&fw_lock);
drivers/base/firmware_loader/sysfs.h +1 -1
@@ -81,7 +81,7 @@ struct fw_sysfs {void *fw_upload_priv; }; -static inline struct fw_sysfs *to_fw_sysfs (struct device *dev) +static inline struct fw_sysfs *to_fw_sysfs (const struct device *dev) { return container_of(dev, struct fw_sysfs, dev); }
drivers/firmware/dmi-id.c +1 -1
@@ -155,7 +155,7 @@ static const struct attribute_group* sys_dmi_attribute_groups[] = { NULL }; -static int dmi_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dmi_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {ssize_t len;
drivers/gnss/core.c +3 -3
@@ -337,7 +337,7 @@ static const char * const gnss_type_names[GNSS_TYPE_COUNT] = { [GNSS_TYPE_MTK] = "MTK", }; -static const char *gnss_type_name (struct gnss_device *gdev) +static const char *gnss_type_name (const struct gnss_device *gdev) {const char *name =NULL ;
@@ -365,9 +365,9 @@ static struct attribute *gnss_attrs[] = { };ATTRIBUTE_GROUPS (gnss); -static int gnss_uevent (struct device *dev,struct kobj_uevent_env *env) +static int gnss_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gnss_device *gdev =to_gnss_device (dev); +const struct gnss_device *gdev =to_gnss_device (dev);int ret; ret =add_uevent_var (env,"GNSS_TYPE=%s" ,gnss_type_name (gdev));
drivers/infiniband/core/device.c +1 -1
@@ -511,7 +511,7 @@ static void ib_device_release(struct device *device)kfree_rcu (dev, rcu_head); } -static int ib_device_uevent (struct device *device, +static int ib_device_uevent (const struct device *device,struct kobj_uevent_env *env) {if (add_uevent_var (env,"NAME=%s" ,dev_name (device)))
drivers/isdn/mISDN/core.c +2 -2
@@ -139,9 +139,9 @@ static struct attribute *mISDN_attrs[] = { };ATTRIBUTE_GROUPS (mISDN); -static int mISDN_uevent (struct device *dev,struct kobj_uevent_env *env) +static int mISDN_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct mISDNdevice *mdev =dev_to_mISDN (dev); +const struct mISDNdevice *mdev =dev_to_mISDN (dev);if (!mdev)return 0 ;
drivers/media/dvb-core/dvbdev.c +2 -2
@@ -1008,9 +1008,9 @@ void dvb_module_release(struct i2c_client *client)EXPORT_SYMBOL_GPL (dvb_module_release);#endif -static int dvb_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dvb_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);add_uevent_var (env,"DVB_ADAPTER_NUM=%d" , dvbdev->adapter->num);add_uevent_var (env,"DVB_DEVICE_TYPE=%s" , dnames[dvbdev->type]);
drivers/nvme/host/core.c +2 -2
@@ -4580,9 +4580,9 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_remove_namespaces); -static int nvme_class_uevent (struct device *dev,struct kobj_uevent_env *env) +static int nvme_class_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct nvme_ctrl *ctrl = +const struct nvme_ctrl *ctrl = container_of(dev, struct nvme_ctrl, ctrl_device);struct nvmf_ctrl_options *opts = ctrl->opts;int ret;
drivers/pcmcia/cs.c +2 -2
@@ -810,10 +810,10 @@ int pcmcia_reset_card(struct pcmcia_socket *skt)EXPORT_SYMBOL (pcmcia_reset_card); -static int pcmcia_socket_uevent (struct device *dev, +static int pcmcia_socket_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); + const struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);if (add_uevent_var (env,"SOCKET_NO=%u" , s->sock))return -ENOMEM ;
drivers/power/supply/power_supply.h +1 -1
@@ -16,7 +16,7 @@ struct power_supply;#ifdef CONFIG_SYSFS extern void power_supply_init_attrs (struct device_type *dev_type); -extern int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env); +extern int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env);#else
drivers/power/supply/power_supply_sysfs.c +4 -4
@@ -427,7 +427,7 @@ void power_supply_init_attrs(struct device_type *dev_type) } } -static int add_prop_uevent (struct device *dev,struct kobj_uevent_env *env, +static int add_prop_uevent (const struct device *dev,struct kobj_uevent_env *env,enum power_supply_property prop,char *prop_buf) {int ret =0 ;
@@ -438,7 +438,7 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr = &power_supply_attrs[prop]; dev_attr = &pwr_attr->dev_attr; - ret =power_supply_show_property (dev, dev_attr, prop_buf); + ret =power_supply_show_property ((struct device *)dev, dev_attr, prop_buf);if (ret == -ENODEV || ret == -ENODATA ) {/* * When a battery is absent, we expect -ENODEV. Don't abort;
@@ -458,9 +458,9 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr->prop_name, prop_buf); } -int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env) +int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct power_supply *psy =dev_get_drvdata (dev); +const struct power_supply *psy =dev_get_drvdata (dev);int ret =0 , j;char *prop_buf;
drivers/usb/gadget/udc/core.c +2 -2
@@ -1723,9 +1723,9 @@ static const struct attribute_group *usb_udc_attr_groups[] = { NULL, }; -static int usb_udc_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_udc_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); + const struct usb_udc *udc = container_of(dev, struct usb_udc, dev);int ret; ret =add_uevent_var (env,"USB_UDC_NAME=%s" , udc->gadget->name);
include/linux/device/class.h +1 -1
@@ -59,7 +59,7 @@ struct class {const struct attribute_group **dev_groups;struct kobject *dev_kobj; -int (*dev_uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode);void (*class_release)(struct class *class);
include/linux/mISDNif.h +1 -1
@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);
net/atm/atm_sysfs.c +2 -2
@@ -108,9 +108,9 @@ static struct device_attribute *atm_attrs[] = { }; -static int atm_uevent (struct device *cdev,struct kobj_uevent_env *env) +static int atm_uevent (const struct device *cdev,struct kobj_uevent_env *env) { -struct atm_dev *adev; +const struct atm_dev *adev;if (!cdev)return -ENODEV ;
net/core/net-sysfs.c +2 -2
@@ -1873,9 +1873,9 @@ const struct kobj_ns_type_operations net_ns_type_operations = { };EXPORT_SYMBOL_GPL (net_ns_type_operations); -static int netdev_uevent (struct device *d,struct kobj_uevent_env *env) +static int netdev_uevent (const struct device *d,struct kobj_uevent_env *env) { -struct net_device *dev =to_net_dev (d); +const struct net_device *dev =to_net_dev (d);int retval;/* pass interface to uevent. */
net/rfkill/core.c +1 -1
@@ -832,7 +832,7 @@ static void rfkill_release(struct device *dev)kfree (rfkill); } -static int rfkill_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int rfkill_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {struct rfkill *rfkill =to_rfkill (dev);unsigned long flags;
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 2/5 driver core: make struct class.devnode() take a const *
The devnode() in struct class 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.
--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++-- arch/x86/kernel/cpuid.c | 2 +- arch/x86/kernel/msr.c | 2 +- block/bsg.c | 2 +- drivers/block/aoe/aoechr.c | 2 +- drivers/char/mem.c | 2 +- drivers/char/misc.c | 4 ++-- drivers/dma-buf/dma-heap.c | 2 +- drivers/gpu/drm/drm_sysfs.c | 2 +- drivers/infiniband/core/user_mad.c | 2 +- drivers/infiniband/core/uverbs_main.c | 2 +- drivers/infiniband/hw/hfi1/device.c | 4 ++-- drivers/input/input.c | 2 +- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++-- drivers/media/rc/rc-main.c | 2 +- drivers/misc/genwqe/card_base.c | 2 +- drivers/tty/tty_io.c | 2 +- drivers/usb/core/file.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vfio/vfio_main.c | 2 +- fs/pstore/pmsg.c | 2 +- include/linux/device/class.h | 2 +- sound/sound_core.c | 2 +- 24 files changed, 29 insertions(+), 29 deletions(-)
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2 -2
@@ -1560,9 +1560,9 @@ static const struct file_operations pseudo_lock_dev_fops = { .mmap = pseudo_lock_dev_mmap, }; -static char *pseudo_lock_devnode (struct device *dev,umode_t *mode) +static char *pseudo_lock_devnode (const struct device *dev,umode_t *mode) { -struct rdtgroup *rdtgrp; +const struct rdtgroup *rdtgrp; rdtgrp =dev_get_drvdata (dev);if (mode)
arch/x86/kernel/cpuid.c +1 -1
@@ -139,7 +139,7 @@ static int cpuid_device_destroy(unsigned int cpu)return 0 ; } -static char *cpuid_devnode (struct device *dev,umode_t *mode) +static char *cpuid_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"cpu/%u/cpuid" ,MINOR (dev->devt)); }
arch/x86/kernel/msr.c +1 -1
@@ -250,7 +250,7 @@ static int msr_device_destroy(unsigned int cpu)return 0 ; } -static char *msr_devnode (struct device *dev,umode_t *mode) +static char *msr_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"cpu/%u/msr" ,MINOR (dev->devt)); }
block/bsg.c +1 -1
@@ -232,7 +232,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q, }EXPORT_SYMBOL_GPL (bsg_register_queue); -static char *bsg_devnode (struct device *dev,umode_t *mode) +static char *bsg_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"bsg/%s" ,dev_name (dev)); }
drivers/block/aoe/aoechr.c +1 -1
@@ -273,7 +273,7 @@ static const struct file_operations aoe_fops = { .llseek = noop_llseek, }; -static char *aoe_devnode (struct device *dev,umode_t *mode) +static char *aoe_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"etherd/%s" ,dev_name (dev)); }
drivers/char/mem.c +1 -1
@@ -746,7 +746,7 @@ static const struct file_operations memory_fops = { .llseek = noop_llseek, }; -static char *mem_devnode (struct device *dev,umode_t *mode) +static char *mem_devnode (const struct device *dev,umode_t *mode) {if (mode && devlist[MINOR (dev->devt)].mode) *mode = devlist[MINOR (dev->devt)].mode;
drivers/char/misc.c +2 -2
@@ -254,9 +254,9 @@ void misc_deregister(struct miscdevice *misc) }EXPORT_SYMBOL (misc_deregister); -static char *misc_devnode (struct device *dev,umode_t *mode) +static char *misc_devnode (const struct device *dev,umode_t *mode) { -struct miscdevice *c =dev_get_drvdata (dev); +const struct miscdevice *c =dev_get_drvdata (dev);if (mode && c->mode) *mode = c->mode;
drivers/dma-buf/dma-heap.c +1 -1
@@ -299,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)return err_ret; } -static char *dma_heap_devnode (struct device *dev,umode_t *mode) +static char *dma_heap_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"dma_heap/%s" ,dev_name (dev)); }
drivers/gpu/drm/drm_sysfs.c +1 -1
@@ -90,7 +90,7 @@ static void drm_sysfs_acpi_register(void) { }static void drm_sysfs_acpi_unregister (void ) { }#endif -static char *drm_devnode (struct device *dev,umode_t *mode) +static char *drm_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"dri/%s" ,dev_name (dev)); }
drivers/infiniband/core/user_mad.c +1 -1
@@ -1224,7 +1224,7 @@ static struct attribute *umad_class_dev_attrs[] = { };ATTRIBUTE_GROUPS (umad_class_dev); -static char *umad_devnode (struct device *dev,umode_t *mode) +static char *umad_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"infiniband/%s" ,dev_name (dev)); }
drivers/infiniband/core/uverbs_main.c +1 -1
@@ -1237,7 +1237,7 @@ static void ib_uverbs_remove_one(struct ib_device *device, void *client_data)put_device (&uverbs_dev->dev); } -static char *uverbs_devnode (struct device *dev,umode_t *mode) +static char *uverbs_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;
drivers/infiniband/hw/hfi1/device.c +2 -2
@@ -72,7 +72,7 @@ const char *class_name(void)return hfi1_class_name; } -static char *hfi1_devnode (struct device *dev,umode_t *mode) +static char *hfi1_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0600 ;
@@ -85,7 +85,7 @@ static const char *class_name_user(void)return hfi1_class_name_user; } -static char *hfi1_user_devnode (struct device *dev,umode_t *mode) +static char *hfi1_user_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;
drivers/input/input.c +1 -1
@@ -1913,7 +1913,7 @@ static const struct device_type input_dev_type = {#endif }; -static char *input_devnode (struct device *dev,umode_t *mode) +static char *input_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"input/%s" ,dev_name (dev)); }
drivers/media/dvb-core/dvbdev.c +2 -2
@@ -1018,9 +1018,9 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env)return 0 ; } -static char *dvb_devnode (struct device *dev,umode_t *mode) +static char *dvb_devnode (const struct device *dev,umode_t *mode) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);return kasprintf (GFP_KERNEL ,"dvb/adapter%d/%s%d" , dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id);
drivers/media/pci/ddbridge/ddbridge-core.c +2 -2
@@ -2716,9 +2716,9 @@ static const struct file_operations ddb_fops = { .release = ddb_release, }; -static char *ddb_devnode (struct device *device,umode_t *mode) +static char *ddb_devnode (const struct device *device,umode_t *mode) { -struct ddb *dev =dev_get_drvdata (device); +const struct ddb *dev =dev_get_drvdata (device);return kasprintf (GFP_KERNEL ,"ddbridge/card%d" , dev->nr); }
drivers/media/rc/rc-main.c +1 -1
@@ -1017,7 +1017,7 @@ static void ir_close(struct input_dev *idev) }/* class for /sys/class/rc */ -static char *rc_devnode (struct device *dev,umode_t *mode) +static char *rc_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"rc/%s" ,dev_name (dev)); }
drivers/misc/genwqe/card_base.c +1 -1
@@ -1349,7 +1349,7 @@ static struct pci_driver genwqe_driver = {* Default mode should be rw for everybody. Do not change default * device name. */ -static char *genwqe_devnode (struct device *dev,umode_t *mode) +static char *genwqe_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;
drivers/tty/tty_io.c +1 -1
@@ -3494,7 +3494,7 @@ void tty_default_fops(struct file_operations *fops) *fops = tty_fops; } -static char *tty_devnode (struct device *dev,umode_t *mode) +static char *tty_devnode (const struct device *dev,umode_t *mode) {if (!mode)return NULL ;
drivers/usb/core/file.c +1 -1
@@ -62,7 +62,7 @@ static struct usb_class {struct class *class; } *usb_class; -static char *usb_devnode (struct device *dev,umode_t *mode) +static char *usb_devnode (const struct device *dev,umode_t *mode) {struct usb_class_driver *drv;
drivers/vdpa/vdpa_user/vduse_dev.c +1 -1
@@ -1656,7 +1656,7 @@ static const struct file_operations vduse_ctrl_fops = { .llseek = noop_llseek, }; -static char *vduse_devnode (struct device *dev,umode_t *mode) +static char *vduse_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"vduse/%s" ,dev_name (dev)); }
drivers/vfio/vfio_main.c +1 -1
@@ -1812,7 +1812,7 @@ EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare);/* * Module/class support */ -static char *vfio_devnode (struct device *dev,umode_t *mode) +static char *vfio_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"vfio/%s" ,dev_name (dev)); }
fs/pstore/pmsg.c +1 -1
@@ -46,7 +46,7 @@ static int pmsg_major;#undef pr_fmt#define pr_fmt (fmt) PMSG_NAME ": " fmt -static char *pmsg_devnode (struct device *dev,umode_t *mode) +static char *pmsg_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0220 ;
include/linux/device/class.h +1 -1
@@ -60,7 +60,7 @@ struct class {struct kobject *dev_kobj;int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env); -char *(*devnode)(struct device *dev,umode_t *mode); +char *(*devnode)(const struct device *dev,umode_t *mode);void (*class_release)(struct class *class);void (*dev_release)(struct device *dev);
sound/sound_core.c +1 -1
@@ -30,7 +30,7 @@ MODULE_DESCRIPTION("Core sound module");MODULE_AUTHOR ("Alan Cox" );MODULE_LICENSE ("GPL" ); -static char *sound_devnode (struct device *dev,umode_t *mode) +static char *sound_devnode (const struct device *dev,umode_t *mode) {if (MAJOR (dev->devt) ==SOUND_MAJOR )return NULL ;
Signature · 1 line
2.38.1
Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
Em Wed, 23 Nov 2022 13:25:20 +0100
Greg Kroah-Hartman <[email protected]> escreveu:
Quoted 4 lines
The
devnode()in struct class 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.
Quoted 424 lines
Cc Fenghua Yu <[email protected]>Cc Reinette Chatre <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Borislav Petkov <[email protected]>Cc Dave Hansen <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc FUJITA Tomonori <[email protected]>Cc Jens Axboe <[email protected]>Cc Justin Sanders <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Sumit Semwal <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Liam Mark <[email protected]>Cc Laura Abbott <[email protected]>Cc Brian Starkey <[email protected]>Cc John Stultz <[email protected]>Cc "Christian König" <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Leon Romanovsky <[email protected]>Cc Dennis Dalessandro <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Sean Young <[email protected]>Cc Frank Haverkamp <[email protected]>Cc Jiri Slaby <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Jason Wang <[email protected]>Cc Alex Williamson <[email protected]>Cc Cornelia Huck <[email protected]>Cc Kees Cook <[email protected]>Cc Anton Vorontsov <[email protected]>Cc Colin Cross <[email protected]>Cc Tony Luck <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Hans Verkuil <[email protected]>Cc Christophe JAILLET <[email protected]>Cc Xie Yongji <[email protected]>Cc Gautam Dawar <[email protected]>Cc Dan Carpenter <[email protected]>Cc Eli Cohen <[email protected]>Cc Parav Pandit <[email protected]>Cc Maxime Coquelin <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++-- arch/x86/kernel/cpuid.c | 2 +- arch/x86/kernel/msr.c | 2 +- block/bsg.c | 2 +- drivers/block/aoe/aoechr.c | 2 +- drivers/char/mem.c | 2 +- drivers/char/misc.c | 4 ++-- drivers/dma-buf/dma-heap.c | 2 +- drivers/gpu/drm/drm_sysfs.c | 2 +- drivers/infiniband/core/user_mad.c | 2 +- drivers/infiniband/core/uverbs_main.c | 2 +- drivers/infiniband/hw/hfi1/device.c | 4 ++-- drivers/input/input.c | 2 +- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++-- drivers/media/rc/rc-main.c | 2 +- drivers/misc/genwqe/card_base.c | 2 +- drivers/tty/tty_io.c | 2 +- drivers/usb/core/file.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vfio/vfio_main.c | 2 +- fs/pstore/pmsg.c | 2 +- include/linux/device/class.h | 2 +- sound/sound_core.c | 2 +- 24 files changed, 29 insertions(+), 29 deletions(-)arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2
-2@@ -1560,9 +1560,9 @@ static const struct file_operations pseudo_lock_dev_fops = { .mmap = pseudo_lock_dev_mmap, }; -static char *pseudo_lock_devnode (struct device *dev,umode_t *mode) +static char *pseudo_lock_devnode (const struct device *dev,umode_t *mode) { -struct rdtgroup *rdtgrp; +const struct rdtgroup *rdtgrp; rdtgrp =dev_get_drvdata (dev);if (mode)arch/x86/kernel/cpuid.c +1
-1@@ -139,7 +139,7 @@ static int cpuid_device_destroy(unsigned int cpu)return 0 ; } -static char *cpuid_devnode (struct device *dev,umode_t *mode) +static char *cpuid_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"cpu/%u/cpuid" ,MINOR (dev->devt)); }arch/x86/kernel/msr.c +1
-1@@ -250,7 +250,7 @@ static int msr_device_destroy(unsigned int cpu)return 0 ; } -static char *msr_devnode (struct device *dev,umode_t *mode) +static char *msr_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"cpu/%u/msr" ,MINOR (dev->devt)); }block/bsg.c +1
-1@@ -232,7 +232,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q, }EXPORT_SYMBOL_GPL (bsg_register_queue); -static char *bsg_devnode (struct device *dev,umode_t *mode) +static char *bsg_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"bsg/%s" ,dev_name (dev)); }drivers/block/aoe/aoechr.c +1
-1@@ -273,7 +273,7 @@ static const struct file_operations aoe_fops = { .llseek = noop_llseek, }; -static char *aoe_devnode (struct device *dev,umode_t *mode) +static char *aoe_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"etherd/%s" ,dev_name (dev)); }drivers/char/mem.c +1
-1@@ -746,7 +746,7 @@ static const struct file_operations memory_fops = { .llseek = noop_llseek, }; -static char *mem_devnode (struct device *dev,umode_t *mode) +static char *mem_devnode (const struct device *dev,umode_t *mode) {if (mode && devlist[MINOR (dev->devt)].mode) *mode = devlist[MINOR (dev->devt)].mode;drivers/char/misc.c +2
-2@@ -254,9 +254,9 @@ void misc_deregister(struct miscdevice *misc) }EXPORT_SYMBOL (misc_deregister); -static char *misc_devnode (struct device *dev,umode_t *mode) +static char *misc_devnode (const struct device *dev,umode_t *mode) { -struct miscdevice *c =dev_get_drvdata (dev); +const struct miscdevice *c =dev_get_drvdata (dev);if (mode && c->mode) *mode = c->mode;drivers/dma-buf/dma-heap.c +1
-1@@ -299,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)return err_ret; } -static char *dma_heap_devnode (struct device *dev,umode_t *mode) +static char *dma_heap_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"dma_heap/%s" ,dev_name (dev)); }drivers/gpu/drm/drm_sysfs.c +1
-1@@ -90,7 +90,7 @@ static void drm_sysfs_acpi_register(void) { }static void drm_sysfs_acpi_unregister (void ) { }#endif -static char *drm_devnode (struct device *dev,umode_t *mode) +static char *drm_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"dri/%s" ,dev_name (dev)); }drivers/infiniband/core/user_mad.c +1
-1@@ -1224,7 +1224,7 @@ static struct attribute *umad_class_dev_attrs[] = { };ATTRIBUTE_GROUPS (umad_class_dev); -static char *umad_devnode (struct device *dev,umode_t *mode) +static char *umad_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"infiniband/%s" ,dev_name (dev)); }drivers/infiniband/core/uverbs_main.c +1
-1@@ -1237,7 +1237,7 @@ static void ib_uverbs_remove_one(struct ib_device *device, void *client_data)put_device (&uverbs_dev->dev); } -static char *uverbs_devnode (struct device *dev,umode_t *mode) +static char *uverbs_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;drivers/infiniband/hw/hfi1/device.c +2
-2@@ -72,7 +72,7 @@ const char *class_name(void)return hfi1_class_name; } -static char *hfi1_devnode (struct device *dev,umode_t *mode) +static char *hfi1_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0600 ;@@ -85,7 +85,7 @@ static const char *class_name_user(void)return hfi1_class_name_user; } -static char *hfi1_user_devnode (struct device *dev,umode_t *mode) +static char *hfi1_user_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;drivers/input/input.c +1
-1@@ -1913,7 +1913,7 @@ static const struct device_type input_dev_type = {#endif }; -static char *input_devnode (struct device *dev,umode_t *mode) +static char *input_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"input/%s" ,dev_name (dev)); }drivers/media/dvb-core/dvbdev.c +2
-2@@ -1018,9 +1018,9 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env)return 0 ; } -static char *dvb_devnode (struct device *dev,umode_t *mode) +static char *dvb_devnode (const struct device *dev,umode_t *mode) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);return kasprintf (GFP_KERNEL ,"dvb/adapter%d/%s%d" , dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id);drivers/media/pci/ddbridge/ddbridge-core.c +2
-2@@ -2716,9 +2716,9 @@ static const struct file_operations ddb_fops = { .release = ddb_release, }; -static char *ddb_devnode (struct device *device,umode_t *mode) +static char *ddb_devnode (const struct device *device,umode_t *mode) { -struct ddb *dev =dev_get_drvdata (device); +const struct ddb *dev =dev_get_drvdata (device);return kasprintf (GFP_KERNEL ,"ddbridge/card%d" , dev->nr); }drivers/media/rc/rc-main.c +1
-1@@ -1017,7 +1017,7 @@ static void ir_close(struct input_dev *idev) }/* class for /sys/class/rc */ -static char *rc_devnode (struct device *dev,umode_t *mode) +static char *rc_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"rc/%s" ,dev_name (dev)); }drivers/misc/genwqe/card_base.c +1
-1@@ -1349,7 +1349,7 @@ static struct pci_driver genwqe_driver = {* Default mode should be rw for everybody. Do not change default * device name. */ -static char *genwqe_devnode (struct device *dev,umode_t *mode) +static char *genwqe_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;drivers/tty/tty_io.c +1
-1@@ -3494,7 +3494,7 @@ void tty_default_fops(struct file_operations *fops) *fops = tty_fops; } -static char *tty_devnode (struct device *dev,umode_t *mode) +static char *tty_devnode (const struct device *dev,umode_t *mode) {if (!mode)return NULL ;drivers/usb/core/file.c +1
-1@@ -62,7 +62,7 @@ static struct usb_class {struct class *class; } *usb_class; -static char *usb_devnode (struct device *dev,umode_t *mode) +static char *usb_devnode (const struct device *dev,umode_t *mode) {struct usb_class_driver *drv;drivers/vdpa/vdpa_user/vduse_dev.c +1
-1@@ -1656,7 +1656,7 @@ static const struct file_operations vduse_ctrl_fops = { .llseek = noop_llseek, }; -static char *vduse_devnode (struct device *dev,umode_t *mode) +static char *vduse_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"vduse/%s" ,dev_name (dev)); }drivers/vfio/vfio_main.c +1
-1@@ -1812,7 +1812,7 @@ EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare);/* * Module/class support */ -static char *vfio_devnode (struct device *dev,umode_t *mode) +static char *vfio_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"vfio/%s" ,dev_name (dev)); }fs/pstore/pmsg.c +1
-1@@ -46,7 +46,7 @@ static int pmsg_major;#undef pr_fmt#define pr_fmt (fmt) PMSG_NAME ": " fmt -static char *pmsg_devnode (struct device *dev,umode_t *mode) +static char *pmsg_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0220 ;include/linux/device/class.h +1
-1@@ -60,7 +60,7 @@ struct class {struct kobject *dev_kobj;int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env); -char *(*devnode)(struct device *dev,umode_t *mode); +char *(*devnode)(const struct device *dev,umode_t *mode);void (*class_release)(struct class *class);void (*dev_release)(struct device *dev);sound/sound_core.c +1
-1@@ -30,7 +30,7 @@ MODULE_DESCRIPTION("Core sound module");MODULE_AUTHOR ("Alan Cox" );MODULE_LICENSE ("GPL" ); -static char *sound_devnode (struct device *dev,umode_t *mode) +static char *sound_devnode (const struct device *dev,umode_t *mode) {if (MAJOR (dev->devt) ==SOUND_MAJOR )return NULL ;
Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
Hello Greg,
Quoted 11 lines · Mauro Carvalho Chehab
Em Wed, 23 Nov 2022 13:25:20 +0100
Greg Kroah-Hartman <[email protected]> escreveu:Quoted 4 lines
The
devnode()in struct class 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.Quoted 1 line
Please feel free to add my
for the dma-buf portion.
Best,
Sumit.
Quoted 423 lines
Quoted 423 lines
Cc Fenghua Yu <[email protected]>Cc Reinette Chatre <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc Borislav Petkov <[email protected]>Cc Dave Hansen <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc FUJITA Tomonori <[email protected]>Cc Jens Axboe <[email protected]>Cc Justin Sanders <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Sumit Semwal <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Liam Mark <[email protected]>Cc Laura Abbott <[email protected]>Cc Brian Starkey <[email protected]>Cc John Stultz <[email protected]>Cc "Christian König" <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Thomas Zimmermann <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Leon Romanovsky <[email protected]>Cc Dennis Dalessandro <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Sean Young <[email protected]>Cc Frank Haverkamp <[email protected]>Cc Jiri Slaby <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Jason Wang <[email protected]>Cc Alex Williamson <[email protected]>Cc Cornelia Huck <[email protected]>Cc Kees Cook <[email protected]>Cc Anton Vorontsov <[email protected]>Cc Colin Cross <[email protected]>Cc Tony Luck <[email protected]>Cc Jaroslav Kysela <[email protected]>Cc Takashi Iwai <[email protected]>Cc Hans Verkuil <[email protected]>Cc Christophe JAILLET <[email protected]>Cc Xie Yongji <[email protected]>Cc Gautam Dawar <[email protected]>Cc Dan Carpenter <[email protected]>Cc Eli Cohen <[email protected]>Cc Parav Pandit <[email protected]>Cc Maxime Coquelin <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 4 ++-- arch/x86/kernel/cpuid.c | 2 +- arch/x86/kernel/msr.c | 2 +- block/bsg.c | 2 +- drivers/block/aoe/aoechr.c | 2 +- drivers/char/mem.c | 2 +- drivers/char/misc.c | 4 ++-- drivers/dma-buf/dma-heap.c | 2 +- drivers/gpu/drm/drm_sysfs.c | 2 +- drivers/infiniband/core/user_mad.c | 2 +- drivers/infiniband/core/uverbs_main.c | 2 +- drivers/infiniband/hw/hfi1/device.c | 4 ++-- drivers/input/input.c | 2 +- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++-- drivers/media/rc/rc-main.c | 2 +- drivers/misc/genwqe/card_base.c | 2 +- drivers/tty/tty_io.c | 2 +- drivers/usb/core/file.c | 2 +- drivers/vdpa/vdpa_user/vduse_dev.c | 2 +- drivers/vfio/vfio_main.c | 2 +- fs/pstore/pmsg.c | 2 +- include/linux/device/class.h | 2 +- sound/sound_core.c | 2 +- 24 files changed, 29 insertions(+), 29 deletions(-)arch/x86/kernel/cpu/resctrl/pseudo_lock.c +2
-2@@ -1560,9 +1560,9 @@ static const struct file_operations pseudo_lock_dev_fops = { .mmap = pseudo_lock_dev_mmap, }; -static char *pseudo_lock_devnode (struct device *dev,umode_t *mode) +static char *pseudo_lock_devnode (const struct device *dev,umode_t *mode) { -struct rdtgroup *rdtgrp; +const struct rdtgroup *rdtgrp; rdtgrp =dev_get_drvdata (dev);if (mode)arch/x86/kernel/cpuid.c +1
-1@@ -139,7 +139,7 @@ static int cpuid_device_destroy(unsigned int cpu)return 0 ; } -static char *cpuid_devnode (struct device *dev,umode_t *mode) +static char *cpuid_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"cpu/%u/cpuid" ,MINOR (dev->devt)); }arch/x86/kernel/msr.c +1
-1@@ -250,7 +250,7 @@ static int msr_device_destroy(unsigned int cpu)return 0 ; } -static char *msr_devnode (struct device *dev,umode_t *mode) +static char *msr_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"cpu/%u/msr" ,MINOR (dev->devt)); }block/bsg.c +1
-1@@ -232,7 +232,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q, }EXPORT_SYMBOL_GPL (bsg_register_queue); -static char *bsg_devnode (struct device *dev,umode_t *mode) +static char *bsg_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"bsg/%s" ,dev_name (dev)); }drivers/block/aoe/aoechr.c +1
-1@@ -273,7 +273,7 @@ static const struct file_operations aoe_fops = { .llseek = noop_llseek, }; -static char *aoe_devnode (struct device *dev,umode_t *mode) +static char *aoe_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"etherd/%s" ,dev_name (dev)); }drivers/char/mem.c +1
-1@@ -746,7 +746,7 @@ static const struct file_operations memory_fops = { .llseek = noop_llseek, }; -static char *mem_devnode (struct device *dev,umode_t *mode) +static char *mem_devnode (const struct device *dev,umode_t *mode) {if (mode && devlist[MINOR (dev->devt)].mode) *mode = devlist[MINOR (dev->devt)].mode;drivers/char/misc.c +2
-2@@ -254,9 +254,9 @@ void misc_deregister(struct miscdevice *misc) }EXPORT_SYMBOL (misc_deregister); -static char *misc_devnode (struct device *dev,umode_t *mode) +static char *misc_devnode (const struct device *dev,umode_t *mode) { -struct miscdevice *c =dev_get_drvdata (dev); +const struct miscdevice *c =dev_get_drvdata (dev);if (mode && c->mode) *mode = c->mode;drivers/dma-buf/dma-heap.c +1
-1@@ -299,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)return err_ret; } -static char *dma_heap_devnode (struct device *dev,umode_t *mode) +static char *dma_heap_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"dma_heap/%s" ,dev_name (dev)); }drivers/gpu/drm/drm_sysfs.c +1
-1@@ -90,7 +90,7 @@ static void drm_sysfs_acpi_register(void) { }static void drm_sysfs_acpi_unregister (void ) { }#endif -static char *drm_devnode (struct device *dev,umode_t *mode) +static char *drm_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"dri/%s" ,dev_name (dev)); }drivers/infiniband/core/user_mad.c +1
-1@@ -1224,7 +1224,7 @@ static struct attribute *umad_class_dev_attrs[] = { };ATTRIBUTE_GROUPS (umad_class_dev); -static char *umad_devnode (struct device *dev,umode_t *mode) +static char *umad_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"infiniband/%s" ,dev_name (dev)); }drivers/infiniband/core/uverbs_main.c +1
-1@@ -1237,7 +1237,7 @@ static void ib_uverbs_remove_one(struct ib_device *device, void *client_data)put_device (&uverbs_dev->dev); } -static char *uverbs_devnode (struct device *dev,umode_t *mode) +static char *uverbs_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;drivers/infiniband/hw/hfi1/device.c +2
-2@@ -72,7 +72,7 @@ const char *class_name(void)return hfi1_class_name; } -static char *hfi1_devnode (struct device *dev,umode_t *mode) +static char *hfi1_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0600 ;@@ -85,7 +85,7 @@ static const char *class_name_user(void)return hfi1_class_name_user; } -static char *hfi1_user_devnode (struct device *dev,umode_t *mode) +static char *hfi1_user_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;drivers/input/input.c +1
-1@@ -1913,7 +1913,7 @@ static const struct device_type input_dev_type = {#endif }; -static char *input_devnode (struct device *dev,umode_t *mode) +static char *input_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"input/%s" ,dev_name (dev)); }drivers/media/dvb-core/dvbdev.c +2
-2@@ -1018,9 +1018,9 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env)return 0 ; } -static char *dvb_devnode (struct device *dev,umode_t *mode) +static char *dvb_devnode (const struct device *dev,umode_t *mode) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);return kasprintf (GFP_KERNEL ,"dvb/adapter%d/%s%d" , dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id);drivers/media/pci/ddbridge/ddbridge-core.c +2
-2@@ -2716,9 +2716,9 @@ static const struct file_operations ddb_fops = { .release = ddb_release, }; -static char *ddb_devnode (struct device *device,umode_t *mode) +static char *ddb_devnode (const struct device *device,umode_t *mode) { -struct ddb *dev =dev_get_drvdata (device); +const struct ddb *dev =dev_get_drvdata (device);return kasprintf (GFP_KERNEL ,"ddbridge/card%d" , dev->nr); }drivers/media/rc/rc-main.c +1
-1@@ -1017,7 +1017,7 @@ static void ir_close(struct input_dev *idev) }/* class for /sys/class/rc */ -static char *rc_devnode (struct device *dev,umode_t *mode) +static char *rc_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"rc/%s" ,dev_name (dev)); }drivers/misc/genwqe/card_base.c +1
-1@@ -1349,7 +1349,7 @@ static struct pci_driver genwqe_driver = {* Default mode should be rw for everybody. Do not change default * device name. */ -static char *genwqe_devnode (struct device *dev,umode_t *mode) +static char *genwqe_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0666 ;drivers/tty/tty_io.c +1
-1@@ -3494,7 +3494,7 @@ void tty_default_fops(struct file_operations *fops) *fops = tty_fops; } -static char *tty_devnode (struct device *dev,umode_t *mode) +static char *tty_devnode (const struct device *dev,umode_t *mode) {if (!mode)return NULL ;drivers/usb/core/file.c +1
-1@@ -62,7 +62,7 @@ static struct usb_class {struct class *class; } *usb_class; -static char *usb_devnode (struct device *dev,umode_t *mode) +static char *usb_devnode (const struct device *dev,umode_t *mode) {struct usb_class_driver *drv;drivers/vdpa/vdpa_user/vduse_dev.c +1
-1@@ -1656,7 +1656,7 @@ static const struct file_operations vduse_ctrl_fops = { .llseek = noop_llseek, }; -static char *vduse_devnode (struct device *dev,umode_t *mode) +static char *vduse_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"vduse/%s" ,dev_name (dev)); }drivers/vfio/vfio_main.c +1
-1@@ -1812,7 +1812,7 @@ EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare);/* * Module/class support */ -static char *vfio_devnode (struct device *dev,umode_t *mode) +static char *vfio_devnode (const struct device *dev,umode_t *mode) {return kasprintf (GFP_KERNEL ,"vfio/%s" ,dev_name (dev)); }fs/pstore/pmsg.c +1
-1@@ -46,7 +46,7 @@ static int pmsg_major;#undef pr_fmt#define pr_fmt (fmt) PMSG_NAME ": " fmt -static char *pmsg_devnode (struct device *dev,umode_t *mode) +static char *pmsg_devnode (const struct device *dev,umode_t *mode) {if (mode) *mode =0220 ;include/linux/device/class.h +1
-1@@ -60,7 +60,7 @@ struct class {struct kobject *dev_kobj;int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env); -char *(*devnode)(struct device *dev,umode_t *mode); +char *(*devnode)(const struct device *dev,umode_t *mode);void (*class_release)(struct class *class);void (*dev_release)(struct device *dev);sound/sound_core.c +1
-1@@ -30,7 +30,7 @@ MODULE_DESCRIPTION("Core sound module");MODULE_AUTHOR ("Alan Cox" );MODULE_LICENSE ("GPL" ); -static char *sound_devnode (struct device *dev,umode_t *mode) +static char *sound_devnode (const struct device *dev,umode_t *mode) {if (MAJOR (dev->devt) ==SOUND_MAJOR )return NULL ;
Signature · 5 lines
Thanks and regards, Sumit Semwal (he / him) Tech Lead - LCG, Vertical Technologies Linaro.org │ Open source software for ARM SoCs
Greg Kroah-Hartman
maintainerPATCH 3/5 driver core: make struct device_type.uevent() take a const *
In reply to Greg Kroah-HartmanThe 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.
--- block/partitions/core.c | 4 ++-- drivers/acpi/device_sysfs.c | 8 ++++---- drivers/acpi/internal.h | 2 +- drivers/firewire/core-device.c | 8 ++++---- drivers/i2c/i2c-core-base.c | 4 ++-- drivers/i3c/device.c | 4 ++-- drivers/i3c/master.c | 4 ++-- drivers/input/input.c | 16 ++++++++-------- drivers/media/rc/rc-main.c | 2 +- drivers/of/device.c | 4 ++-- drivers/platform/surface/aggregator/bus.c | 4 ++-- drivers/soundwire/bus_type.c | 4 ++-- drivers/thunderbolt/switch.c | 4 ++-- drivers/thunderbolt/tb.h | 2 +- drivers/thunderbolt/xdomain.c | 6 +++--- drivers/tty/serdev/core.c | 2 +- drivers/usb/core/message.c | 8 ++++---- drivers/usb/core/usb.c | 4 ++-- drivers/usb/phy/phy.c | 6 +++--- drivers/usb/roles/class.c | 3 +-- drivers/usb/typec/class.c | 2 +- include/linux/acpi.h | 4 ++-- include/linux/device.h | 2 +- include/linux/firewire.h | 6 +++--- include/linux/i3c/device.h | 4 ++-- include/linux/of_device.h | 4 ++-- include/linux/soundwire/sdw_type.h | 2 +- include/linux/surface_aggregator/device.h | 2 +- 28 files changed, 62 insertions(+), 63 deletions(-)
block/partitions/core.c +2 -2
@@ -254,9 +254,9 @@ static void part_release(struct device *dev)iput (dev_to_bdev (dev)->bd_inode); } -static int part_uevent (struct device *dev,struct kobj_uevent_env *env) +static int part_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct block_device *part =dev_to_bdev (dev); +const struct block_device *part =dev_to_bdev (dev);add_uevent_var (env,"PARTN=%u" , part->bd_partno);if (part->bd_meta_info && part->bd_meta_info->volname[0 ])
drivers/acpi/device_sysfs.c +4 -4
@@ -133,7 +133,7 @@ static void acpi_hide_nondev_subnodes(struct acpi_device_data *data)* -EINVAL: output error * -ENOMEM: output is truncated */ -static int create_pnp_modalias (struct acpi_device *acpi_dev,char *modalias, +static int create_pnp_modalias (const struct acpi_device *acpi_dev,char *modalias,int size) {int len;
@@ -191,7 +191,7 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,* only be called for devices having ACPI_DT_NAMESPACE_HID in their list of * ACPI/PNP IDs. */ -static int create_of_modalias (struct acpi_device *acpi_dev,char *modalias, +static int create_of_modalias (const struct acpi_device *acpi_dev,char *modalias,int size) {struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER };
@@ -239,7 +239,7 @@ static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,return len; } -int __acpi_device_uevent_modalias (struct acpi_device *adev, +int __acpi_device_uevent_modalias (const struct acpi_device *adev,struct kobj_uevent_env *env) {int len;
@@ -277,7 +277,7 @@ int __acpi_device_uevent_modalias(struct acpi_device *adev,* Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001". */ -int acpi_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env) +int acpi_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return __acpi_device_uevent_modalias (acpi_companion_match (dev), env); }
drivers/acpi/internal.h +1 -1
@@ -120,7 +120,7 @@ int acpi_bus_register_early_device(int type);Device Matching and Notification -------------------------------------------------------------------------- */ struct acpi_device *acpi_companion_match (const struct device *dev); -int __acpi_device_uevent_modalias (struct acpi_device *adev, +int __acpi_device_uevent_modalias (const struct acpi_device *adev,struct kobj_uevent_env *env);/* --------------------------------------------------------------------------
drivers/firewire/core-device.c +4 -4
@@ -133,7 +133,7 @@ static void get_ids(const u32 *directory, int *id) } } -static void get_modalias_ids (struct fw_unit *unit,int *id) +static void get_modalias_ids (const struct fw_unit *unit,int *id) {get_ids (&fw_parent_device (unit)->config_rom[5 ], id);get_ids (unit->directory, id);
@@ -195,7 +195,7 @@ static void fw_unit_remove(struct device *dev) driver->remove (fw_unit (dev)); } -static int get_modalias (struct fw_unit *unit,char *buffer,size_t buffer_size) +static int get_modalias (const struct fw_unit *unit,char *buffer,size_t buffer_size) {int id[] = {0 ,0 ,0 ,0 };
@@ -206,9 +206,9 @@ static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) id[0], id[1], id[2], id[3]); } -static int fw_unit_uevent (struct device *dev,struct kobj_uevent_env *env) +static int fw_unit_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_unit *unit =fw_unit (dev); +const struct fw_unit *unit =fw_unit (dev);char modalias[64 ];get_modalias (unit, modalias,sizeof (modalias));
drivers/i2c/i2c-core-base.c +2 -2
@@ -136,9 +136,9 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)return 0 ; } -static int i2c_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int i2c_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct i2c_client *client =to_i2c_client (dev); +const struct i2c_client *client =to_i2c_client (dev);int rc; rc =of_device_uevent_modalias (dev, env);
drivers/i3c/device.c +2 -2
@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(i3c_device_do_priv_xfers);* * Retrieve I3C dev info. */ -void i3c_device_get_info (struct i3c_device *dev, +void i3c_device_get_info (const struct i3c_device *dev,struct i3c_device_info *info) {if (!info)
@@ -194,7 +194,7 @@ EXPORT_SYMBOL_GPL(i3cdev_to_dev);* * Return: a pointer to an I3C device object. */ -struct i3c_device *dev_to_i3cdev (struct device *dev) +struct i3c_device *dev_to_i3cdev (const struct device *dev) { return container_of(dev, struct i3c_device, dev); }
drivers/i3c/master.c +2 -2
@@ -273,9 +273,9 @@ static struct attribute *i3c_device_attrs[] = { };ATTRIBUTE_GROUPS (i3c_device); -static int i3c_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int i3c_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct i3c_device *i3cdev =dev_to_i3cdev (dev); +const struct i3c_device *i3cdev =dev_to_i3cdev (dev);struct i3c_device_info devinfo;u16 manuf, part, ext;
drivers/input/input.c +8 -8
@@ -1371,7 +1371,7 @@ INPUT_DEV_STRING_ATTR_SHOW(phys);INPUT_DEV_STRING_ATTR_SHOW (uniq);static int input_print_modalias_bits (char *buf,int size, -char name,unsigned long *bm, +char name,const unsigned long *bm,unsigned int min_bit,unsigned int max_bit) {int len =0 , i;
@@ -1383,7 +1383,7 @@ static int input_print_modalias_bits(char *buf, int size,return len; } -static int input_print_modalias (char *buf,int size,struct input_dev *id, +static int input_print_modalias (char *buf,int size,const struct input_dev *id,int add_cr) {int len;
@@ -1431,7 +1431,7 @@ static ssize_t input_dev_show_modalias(struct device *dev, } static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); -static int input_print_bitmap (char *buf,int buf_size,unsigned long *bitmap, +static int input_print_bitmap (char *buf,int buf_size,const unsigned long *bitmap,int max,int add_cr); static ssize_t input_dev_show_properties(struct device *dev,
@@ -1523,7 +1523,7 @@ static const struct attribute_group input_dev_id_attr_group = { .attrs = input_dev_id_attrs, }; -static int input_print_bitmap (char *buf,int buf_size,unsigned long *bitmap, +static int input_print_bitmap (char *buf,int buf_size,const unsigned long *bitmap,int max,int add_cr) {int i;
@@ -1620,7 +1620,7 @@ static void input_dev_release(struct device *device)* device bitfields. */ static int input_add_uevent_bm_var (struct kobj_uevent_env *env, -const char *name,unsigned long *bitmap,int max) +const char *name,const unsigned long *bitmap,int max) {int len;
@@ -1638,7 +1638,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env, }static int input_add_uevent_modalias_var (struct kobj_uevent_env *env, -struct input_dev *dev) +const struct input_dev *dev) {int len;
@@ -1676,9 +1676,9 @@ static int input_add_uevent_modalias_var(struct kobj_uevent_env *env,return err; \ }while (0 ) -static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) +static int input_dev_uevent(const struct device *device, struct kobj_uevent_env *env) { -struct input_dev *dev =to_input_dev (device); +const struct input_dev *dev =to_input_dev (device); INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x", dev->id.bustype, dev->id.vendor,
drivers/media/rc/rc-main.c +1 -1
@@ -1614,7 +1614,7 @@ static void rc_dev_release(struct device *device)kfree (dev); } -static int rc_dev_uevent (struct device *device,struct kobj_uevent_env *env) +static int rc_dev_uevent (const struct device *device,struct kobj_uevent_env *env) {struct rc_dev *dev =to_rc_dev (device);int ret =0 ;
drivers/of/device.c +2 -2
@@ -248,7 +248,7 @@ const void *of_device_get_match_data(const struct device *dev) }EXPORT_SYMBOL (of_device_get_match_data); -static ssize_t of_device_get_modalias (struct device *dev,char *str,ssize_t len) +static ssize_t of_device_get_modalias (const struct device *dev,char *str,ssize_t len) {const char *compat;char *c;
@@ -372,7 +372,7 @@ void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env)mutex_unlock (&of_mutex); } -int of_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env) +int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {int sl;
drivers/platform/surface/aggregator/bus.c +2 -2
@@ -35,9 +35,9 @@ static struct attribute *ssam_device_attrs[] = { };ATTRIBUTE_GROUPS (ssam_device); -static int ssam_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int ssam_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct ssam_device *sdev =to_ssam_device (dev); +const struct ssam_device *sdev =to_ssam_device (dev); return add_uevent_var(env, "MODALIAS=ssam:d%02Xc%02Xt%02Xi%02Xf%02X", sdev->uid.domain, sdev->uid.category,
drivers/soundwire/bus_type.c +2 -2
@@ -58,9 +58,9 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) slave->id.sdw_version, slave->id.class_id); } -int sdw_slave_uevent (struct device *dev,struct kobj_uevent_env *env) +int sdw_slave_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +const struct sdw_slave *slave =dev_to_sdw_dev (dev);char modalias[32 ];sdw_slave_modalias (slave, modalias,sizeof (modalias));
drivers/thunderbolt/switch.c +2 -2
@@ -2175,9 +2175,9 @@ static void tb_switch_release(struct device *dev)kfree (sw); } -static int tb_switch_uevent (struct device *dev,struct kobj_uevent_env *env) +static int tb_switch_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct tb_switch *sw =tb_to_switch (dev); +const struct tb_switch *sw =tb_to_switch (dev);const char *type;if (sw->config.thunderbolt_version ==USB4_VERSION_1_0 ) {
drivers/thunderbolt/tb.h +1 -1
@@ -815,7 +815,7 @@ static inline bool tb_is_switch(const struct device *dev)return dev->type == &tb_switch_type; } -static inline struct tb_switch *tb_to_switch (struct device *dev) +static inline struct tb_switch *tb_to_switch (const struct device *dev) {if (tb_is_switch (dev)) return container_of(dev, struct tb_switch, dev);
drivers/thunderbolt/xdomain.c +3 -3
@@ -881,7 +881,7 @@ static ssize_t key_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (key); -static int get_modalias (struct tb_service *svc,char *buf,size_t size) +static int get_modalias (const struct tb_service *svc,char *buf,size_t size) {return snprintf (buf, size,"tbsvc:k%sp%08Xv%08Xr%08X" , svc->key, svc->prtcid, svc->prtcvers, svc->prtcrevs);
@@ -953,9 +953,9 @@ static const struct attribute_group *tb_service_attr_groups[] = { NULL, }; -static int tb_service_uevent (struct device *dev,struct kobj_uevent_env *env) +static int tb_service_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct tb_service *svc = container_of(dev, struct tb_service, dev); + const struct tb_service *svc = container_of(dev, struct tb_service, dev);char modalias[64 ];get_modalias (svc, modalias,sizeof (modalias));
drivers/tty/serdev/core.c +1 -1
@@ -42,7 +42,7 @@ static struct attribute *serdev_device_attrs[] = { };ATTRIBUTE_GROUPS (serdev_device); -static int serdev_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int serdev_device_uevent (const struct device *dev,struct kobj_uevent_env *env) {int rc;
drivers/usb/core/message.c +4 -4
@@ -1818,11 +1818,11 @@ void usb_authorize_interface(struct usb_interface *intf) } } -static int usb_if_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_if_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_device *usb_dev; -struct usb_interface *intf; -struct usb_host_interface *alt; +const struct usb_device *usb_dev; +const struct usb_interface *intf; +const struct usb_host_interface *alt; intf =to_usb_interface (dev); usb_dev =interface_to_usbdev (intf);
drivers/usb/core/usb.c +2 -2
@@ -423,9 +423,9 @@ static void usb_release_dev(struct device *dev)kfree (udev); } -static int usb_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_device *usb_dev; +const struct usb_device *usb_dev; usb_dev =to_usb_device (dev);
drivers/usb/phy/phy.c +3 -3
@@ -80,7 +80,7 @@ static struct usb_phy *__of_usb_find_phy(struct device_node *node)return ERR_PTR (-EPROBE_DEFER ); } -static struct usb_phy *__device_to_usb_phy (struct device *dev) +static struct usb_phy *__device_to_usb_phy (const struct device *dev) {struct usb_phy *usb_phy;
@@ -145,9 +145,9 @@ static void usb_phy_notify_charger_work(struct work_struct *work)kobject_uevent (&usb_phy->dev->kobj,KOBJ_CHANGE ); } -static int usb_phy_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_phy_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_phy *usb_phy; +const struct usb_phy *usb_phy;char uchger_state[50 ] = {0 };char uchger_type[50 ] = {0 };unsigned long flags;
drivers/usb/roles/class.c +1 -2
@@ -271,8 +271,7 @@ static const struct attribute_group *usb_role_switch_groups[] = { NULL, }; -static int -usb_role_switch_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_role_switch_uevent (const struct device *dev,struct kobj_uevent_env *env) {int ret;
drivers/usb/typec/class.c +1 -1
@@ -1718,7 +1718,7 @@ static const struct attribute_group *typec_groups[] = { NULL }; -static int typec_uevent (struct device *dev,struct kobj_uevent_env *env) +static int typec_uevent (const struct device *dev,struct kobj_uevent_env *env) {int ret;
include/linux/acpi.h +2 -2
@@ -722,7 +722,7 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,const void *acpi_device_get_match_data (const struct device *dev);extern bool acpi_driver_match_device (struct device *dev,const struct device_driver *drv); -int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *); +int acpi_device_uevent_modalias (const struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); struct platform_device *acpi_create_platform_device(struct acpi_device *,
@@ -957,7 +957,7 @@ static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,return NULL ; } -static inline int acpi_device_uevent_modalias (struct device *dev, +static inline int acpi_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return -ENODEV ;
include/linux/device.h +1 -1
@@ -88,7 +88,7 @@ int subsys_virtual_register(struct bus_type *subsys,struct device_type {const char *name;const struct attribute_group **groups; -int (*uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid);void (*release)(struct device *dev);
include/linux/firewire.h +3 -3
@@ -208,7 +208,7 @@ struct fw_device {struct fw_attribute_group attribute_group; }; -static inline struct fw_device *fw_device (struct device *dev) +static inline struct fw_device *fw_device (const struct device *dev) { return container_of(dev, struct fw_device, device); }
@@ -229,7 +229,7 @@ struct fw_unit {struct fw_attribute_group attribute_group; }; -static inline struct fw_unit *fw_unit (struct device *dev) +static inline struct fw_unit *fw_unit (const struct device *dev) { return container_of(dev, struct fw_unit, device); }
@@ -246,7 +246,7 @@ static inline void fw_unit_put(struct fw_unit *unit)put_device (&unit->device); } -static inline struct fw_device *fw_parent_device (struct fw_unit *unit) +static inline struct fw_device *fw_parent_device (const struct fw_unit *unit) {return fw_device (unit->device.parent); }
include/linux/i3c/device.h +2 -2
@@ -186,7 +186,7 @@ static inline struct i3c_driver *drv_to_i3cdrv(struct device_driver *drv) }struct device *i3cdev_to_dev (struct i3c_device *i3cdev); -struct i3c_device *dev_to_i3cdev (struct device *dev); +struct i3c_device *dev_to_i3cdev (const struct device *dev);const struct i3c_device_id * i3c_device_match_id(struct i3c_device *i3cdev,
@@ -293,7 +293,7 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev,struct i3c_priv_xfer *xfers, int nxfers); -void i3c_device_get_info (struct i3c_device *dev,struct i3c_device_info *info); +void i3c_device_get_info (const struct i3c_device *dev,struct i3c_device_info *info);struct i3c_ibi_payload {unsigned int len;
include/linux/of_device.h +2 -2
@@ -36,7 +36,7 @@ extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);extern int of_device_request_module (struct device *dev);extern void of_device_uevent (const struct device *dev,struct kobj_uevent_env *env); -extern int of_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env); +extern int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env);static inline struct device_node *of_cpu_device_node_get (int cpu) {
@@ -83,7 +83,7 @@ static inline int of_device_request_module(struct device *dev)return -ENODEV ; } -static inline int of_device_uevent_modalias (struct device *dev, +static inline int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return -ENODEV ;
include/linux/soundwire/sdw_type.h +1 -1
@@ -21,7 +21,7 @@ static inline int is_sdw_slave(const struct device *dev)int __sdw_register_driver (struct sdw_driver *drv,struct module *owner);void sdw_unregister_driver (struct sdw_driver *drv); -int sdw_slave_uevent (struct device *dev,struct kobj_uevent_env *env); +int sdw_slave_uevent (const struct device *dev,struct kobj_uevent_env *env);/** * module_sdw_driver() - Helper macro for registering a Soundwire driver
include/linux/surface_aggregator/device.h +1 -1
@@ -229,7 +229,7 @@ static inline bool is_ssam_device(struct device *d)* Return: Returns a pointer to the &struct ssam_device wrapping the given * device @d. */ -static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }
Signature · 1 line
2.38.1
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 49 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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 Jens Axboe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Cc Stefan Richter <[email protected]>Cc Wolfram Sang <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Sean Young <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>Cc Maximilian Luz <[email protected]>Cc Hans de Goede <[email protected]>Cc Mark Gross <[email protected]>Cc Vinod Koul <[email protected]>Cc Bard Liao <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Sanyog Kale <[email protected]>Cc Andreas Noever <[email protected]>Cc Michael Jamet <[email protected]>Cc Mika Westerberg <[email protected]>Cc Yehezkel Bernat <[email protected]>Cc Jiri Slaby <[email protected]>Cc Heikki Krogerus <[email protected]>Cc "Matthew Wilcox (Oracle)" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Chaitanya Kulkarni <[email protected]>Cc Ming Lei <[email protected]>Cc Jilin Yuan <[email protected]>Cc Alan Stern <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Sakari Ailus <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ira Weiny <[email protected]>Cc Dan Williams <[email protected]>Cc Won Chung <[email protected]>
Quoted 8 lines
(which my ACPI maintainer hat on).
Thanks!
Quoted 619 lines
--- block/partitions/core.c | 4 ++-- drivers/acpi/device_sysfs.c | 8 ++++---- drivers/acpi/internal.h | 2 +- drivers/firewire/core-device.c | 8 ++++---- drivers/i2c/i2c-core-base.c | 4 ++-- drivers/i3c/device.c | 4 ++-- drivers/i3c/master.c | 4 ++-- drivers/input/input.c | 16 ++++++++-------- drivers/media/rc/rc-main.c | 2 +- drivers/of/device.c | 4 ++-- drivers/platform/surface/aggregator/bus.c | 4 ++-- drivers/soundwire/bus_type.c | 4 ++-- drivers/thunderbolt/switch.c | 4 ++-- drivers/thunderbolt/tb.h | 2 +- drivers/thunderbolt/xdomain.c | 6 +++--- drivers/tty/serdev/core.c | 2 +- drivers/usb/core/message.c | 8 ++++---- drivers/usb/core/usb.c | 4 ++-- drivers/usb/phy/phy.c | 6 +++--- drivers/usb/roles/class.c | 3 +-- drivers/usb/typec/class.c | 2 +- include/linux/acpi.h | 4 ++-- include/linux/device.h | 2 +- include/linux/firewire.h | 6 +++--- include/linux/i3c/device.h | 4 ++-- include/linux/of_device.h | 4 ++-- include/linux/soundwire/sdw_type.h | 2 +- include/linux/surface_aggregator/device.h | 2 +- 28 files changed, 62 insertions(+), 63 deletions(-)block/partitions/core.c +2
-2@@ -254,9 +254,9 @@ static void part_release(struct device *dev)iput (dev_to_bdev (dev)->bd_inode); } -static int part_uevent (struct device *dev,struct kobj_uevent_env *env) +static int part_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct block_device *part =dev_to_bdev (dev); +const struct block_device *part =dev_to_bdev (dev);add_uevent_var (env,"PARTN=%u" , part->bd_partno);if (part->bd_meta_info && part->bd_meta_info->volname[0 ])drivers/acpi/device_sysfs.c +4
-4@@ -133,7 +133,7 @@ static void acpi_hide_nondev_subnodes(struct acpi_device_data *data)* -EINVAL: output error * -ENOMEM: output is truncated */ -static int create_pnp_modalias (struct acpi_device *acpi_dev,char *modalias, +static int create_pnp_modalias (const struct acpi_device *acpi_dev,char *modalias,int size) {int len;@@ -191,7 +191,7 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,* only be called for devices having ACPI_DT_NAMESPACE_HID in their list of * ACPI/PNP IDs. */ -static int create_of_modalias (struct acpi_device *acpi_dev,char *modalias, +static int create_of_modalias (const struct acpi_device *acpi_dev,char *modalias,int size) {struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER };@@ -239,7 +239,7 @@ static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,return len; } -int __acpi_device_uevent_modalias (struct acpi_device *adev, +int __acpi_device_uevent_modalias (const struct acpi_device *adev,struct kobj_uevent_env *env) {int len;@@ -277,7 +277,7 @@ int __acpi_device_uevent_modalias(struct acpi_device *adev,* Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001". */ -int acpi_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env) +int acpi_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return __acpi_device_uevent_modalias (acpi_companion_match (dev), env); }drivers/acpi/internal.h +1
-1@@ -120,7 +120,7 @@ int acpi_bus_register_early_device(int type);Device Matching and Notification -------------------------------------------------------------------------- */ struct acpi_device *acpi_companion_match (const struct device *dev); -int __acpi_device_uevent_modalias (struct acpi_device *adev, +int __acpi_device_uevent_modalias (const struct acpi_device *adev,struct kobj_uevent_env *env);/* -------------------------------------------------------------------------- drivers/firewire/core-device.c +4
-4@@ -133,7 +133,7 @@ static void get_ids(const u32 *directory, int *id) } } -static void get_modalias_ids (struct fw_unit *unit,int *id) +static void get_modalias_ids (const struct fw_unit *unit,int *id) {get_ids (&fw_parent_device (unit)->config_rom[5 ], id);get_ids (unit->directory, id);@@ -195,7 +195,7 @@ static void fw_unit_remove(struct device *dev) driver->remove (fw_unit (dev)); } -static int get_modalias (struct fw_unit *unit,char *buffer,size_t buffer_size) +static int get_modalias (const struct fw_unit *unit,char *buffer,size_t buffer_size) {int id[] = {0 ,0 ,0 ,0 };@@ -206,9 +206,9 @@ static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) id[0], id[1], id[2], id[3]); } -static int fw_unit_uevent (struct device *dev,struct kobj_uevent_env *env) +static int fw_unit_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_unit *unit =fw_unit (dev); +const struct fw_unit *unit =fw_unit (dev);char modalias[64 ];get_modalias (unit, modalias,sizeof (modalias));drivers/i2c/i2c-core-base.c +2
-2@@ -136,9 +136,9 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)return 0 ; } -static int i2c_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int i2c_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct i2c_client *client =to_i2c_client (dev); +const struct i2c_client *client =to_i2c_client (dev);int rc; rc =of_device_uevent_modalias (dev, env);drivers/i3c/device.c +2
-2@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(i3c_device_do_priv_xfers);* * Retrieve I3C dev info. */ -void i3c_device_get_info (struct i3c_device *dev, +void i3c_device_get_info (const struct i3c_device *dev,struct i3c_device_info *info) {if (!info)@@ -194,7 +194,7 @@ EXPORT_SYMBOL_GPL(i3cdev_to_dev);* * Return: a pointer to an I3C device object. */ -struct i3c_device *dev_to_i3cdev (struct device *dev) +struct i3c_device *dev_to_i3cdev (const struct device *dev) { return container_of(dev, struct i3c_device, dev); }drivers/i3c/master.c +2
-2@@ -273,9 +273,9 @@ static struct attribute *i3c_device_attrs[] = { };ATTRIBUTE_GROUPS (i3c_device); -static int i3c_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int i3c_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct i3c_device *i3cdev =dev_to_i3cdev (dev); +const struct i3c_device *i3cdev =dev_to_i3cdev (dev);struct i3c_device_info devinfo;u16 manuf, part, ext;drivers/input/input.c +8
-8@@ -1371,7 +1371,7 @@ INPUT_DEV_STRING_ATTR_SHOW(phys);INPUT_DEV_STRING_ATTR_SHOW (uniq);static int input_print_modalias_bits (char *buf,int size, -char name,unsigned long *bm, +char name,const unsigned long *bm,unsigned int min_bit,unsigned int max_bit) {int len =0 , i;@@ -1383,7 +1383,7 @@ static int input_print_modalias_bits(char *buf, int size,return len; } -static int input_print_modalias (char *buf,int size,struct input_dev *id, +static int input_print_modalias (char *buf,int size,const struct input_dev *id,int add_cr) {int len;@@ -1431,7 +1431,7 @@ static ssize_t input_dev_show_modalias(struct device *dev, } static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); -static int input_print_bitmap (char *buf,int buf_size,unsigned long *bitmap, +static int input_print_bitmap (char *buf,int buf_size,const unsigned long *bitmap,int max,int add_cr); static ssize_t input_dev_show_properties(struct device *dev,@@ -1523,7 +1523,7 @@ static const struct attribute_group input_dev_id_attr_group = { .attrs = input_dev_id_attrs, }; -static int input_print_bitmap (char *buf,int buf_size,unsigned long *bitmap, +static int input_print_bitmap (char *buf,int buf_size,const unsigned long *bitmap,int max,int add_cr) {int i;@@ -1620,7 +1620,7 @@ static void input_dev_release(struct device *device)* device bitfields. */ static int input_add_uevent_bm_var (struct kobj_uevent_env *env, -const char *name,unsigned long *bitmap,int max) +const char *name,const unsigned long *bitmap,int max) {int len;@@ -1638,7 +1638,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env, }static int input_add_uevent_modalias_var (struct kobj_uevent_env *env, -struct input_dev *dev) +const struct input_dev *dev) {int len;@@ -1676,9 +1676,9 @@ static int input_add_uevent_modalias_var(struct kobj_uevent_env *env,return err; \ }while (0 ) -static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) +static int input_dev_uevent(const struct device *device, struct kobj_uevent_env *env) { -struct input_dev *dev =to_input_dev (device); +const struct input_dev *dev =to_input_dev (device); INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x", dev->id.bustype, dev->id.vendor,drivers/media/rc/rc-main.c +1
-1@@ -1614,7 +1614,7 @@ static void rc_dev_release(struct device *device)kfree (dev); } -static int rc_dev_uevent (struct device *device,struct kobj_uevent_env *env) +static int rc_dev_uevent (const struct device *device,struct kobj_uevent_env *env) {struct rc_dev *dev =to_rc_dev (device);int ret =0 ;drivers/of/device.c +2
-2@@ -248,7 +248,7 @@ const void *of_device_get_match_data(const struct device *dev) }EXPORT_SYMBOL (of_device_get_match_data); -static ssize_t of_device_get_modalias (struct device *dev,char *str,ssize_t len) +static ssize_t of_device_get_modalias (const struct device *dev,char *str,ssize_t len) {const char *compat;char *c;@@ -372,7 +372,7 @@ void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env)mutex_unlock (&of_mutex); } -int of_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env) +int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {int sl;drivers/platform/surface/aggregator/bus.c +2
-2@@ -35,9 +35,9 @@ static struct attribute *ssam_device_attrs[] = { };ATTRIBUTE_GROUPS (ssam_device); -static int ssam_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int ssam_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct ssam_device *sdev =to_ssam_device (dev); +const struct ssam_device *sdev =to_ssam_device (dev); return add_uevent_var(env, "MODALIAS=ssam:d%02Xc%02Xt%02Xi%02Xf%02X", sdev->uid.domain, sdev->uid.category,drivers/soundwire/bus_type.c +2
-2@@ -58,9 +58,9 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) slave->id.sdw_version, slave->id.class_id); } -int sdw_slave_uevent (struct device *dev,struct kobj_uevent_env *env) +int sdw_slave_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +const struct sdw_slave *slave =dev_to_sdw_dev (dev);char modalias[32 ];sdw_slave_modalias (slave, modalias,sizeof (modalias));drivers/thunderbolt/switch.c +2
-2@@ -2175,9 +2175,9 @@ static void tb_switch_release(struct device *dev)kfree (sw); } -static int tb_switch_uevent (struct device *dev,struct kobj_uevent_env *env) +static int tb_switch_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct tb_switch *sw =tb_to_switch (dev); +const struct tb_switch *sw =tb_to_switch (dev);const char *type;if (sw->config.thunderbolt_version ==USB4_VERSION_1_0 ) {drivers/thunderbolt/tb.h +1
-1@@ -815,7 +815,7 @@ static inline bool tb_is_switch(const struct device *dev)return dev->type == &tb_switch_type; } -static inline struct tb_switch *tb_to_switch (struct device *dev) +static inline struct tb_switch *tb_to_switch (const struct device *dev) {if (tb_is_switch (dev)) return container_of(dev, struct tb_switch, dev);drivers/thunderbolt/xdomain.c +3
-3@@ -881,7 +881,7 @@ static ssize_t key_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (key); -static int get_modalias (struct tb_service *svc,char *buf,size_t size) +static int get_modalias (const struct tb_service *svc,char *buf,size_t size) {return snprintf (buf, size,"tbsvc:k%sp%08Xv%08Xr%08X" , svc->key, svc->prtcid, svc->prtcvers, svc->prtcrevs);@@ -953,9 +953,9 @@ static const struct attribute_group *tb_service_attr_groups[] = { NULL, }; -static int tb_service_uevent (struct device *dev,struct kobj_uevent_env *env) +static int tb_service_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct tb_service *svc = container_of(dev, struct tb_service, dev); + const struct tb_service *svc = container_of(dev, struct tb_service, dev);char modalias[64 ];get_modalias (svc, modalias,sizeof (modalias));drivers/tty/serdev/core.c +1
-1@@ -42,7 +42,7 @@ static struct attribute *serdev_device_attrs[] = { };ATTRIBUTE_GROUPS (serdev_device); -static int serdev_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int serdev_device_uevent (const struct device *dev,struct kobj_uevent_env *env) {int rc;drivers/usb/core/message.c +4
-4@@ -1818,11 +1818,11 @@ void usb_authorize_interface(struct usb_interface *intf) } } -static int usb_if_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_if_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_device *usb_dev; -struct usb_interface *intf; -struct usb_host_interface *alt; +const struct usb_device *usb_dev; +const struct usb_interface *intf; +const struct usb_host_interface *alt; intf =to_usb_interface (dev); usb_dev =interface_to_usbdev (intf);drivers/usb/core/usb.c +2
-2@@ -423,9 +423,9 @@ static void usb_release_dev(struct device *dev)kfree (udev); } -static int usb_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_device *usb_dev; +const struct usb_device *usb_dev; usb_dev =to_usb_device (dev);drivers/usb/phy/phy.c +3
-3@@ -80,7 +80,7 @@ static struct usb_phy *__of_usb_find_phy(struct device_node *node)return ERR_PTR (-EPROBE_DEFER ); } -static struct usb_phy *__device_to_usb_phy (struct device *dev) +static struct usb_phy *__device_to_usb_phy (const struct device *dev) {struct usb_phy *usb_phy;@@ -145,9 +145,9 @@ static void usb_phy_notify_charger_work(struct work_struct *work)kobject_uevent (&usb_phy->dev->kobj,KOBJ_CHANGE ); } -static int usb_phy_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_phy_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_phy *usb_phy; +const struct usb_phy *usb_phy;char uchger_state[50 ] = {0 };char uchger_type[50 ] = {0 };unsigned long flags;drivers/usb/roles/class.c +1
-2@@ -271,8 +271,7 @@ static const struct attribute_group *usb_role_switch_groups[] = { NULL, }; -static int -usb_role_switch_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_role_switch_uevent (const struct device *dev,struct kobj_uevent_env *env) {int ret;drivers/usb/typec/class.c +1
-1@@ -1718,7 +1718,7 @@ static const struct attribute_group *typec_groups[] = { NULL }; -static int typec_uevent (struct device *dev,struct kobj_uevent_env *env) +static int typec_uevent (const struct device *dev,struct kobj_uevent_env *env) {int ret;include/linux/acpi.h +2
-2@@ -722,7 +722,7 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,const void *acpi_device_get_match_data (const struct device *dev);extern bool acpi_driver_match_device (struct device *dev,const struct device_driver *drv); -int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *); +int acpi_device_uevent_modalias (const struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); struct platform_device *acpi_create_platform_device(struct acpi_device *,@@ -957,7 +957,7 @@ static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,return NULL ; } -static inline int acpi_device_uevent_modalias (struct device *dev, +static inline int acpi_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return -ENODEV ;include/linux/device.h +1
-1@@ -88,7 +88,7 @@ int subsys_virtual_register(struct bus_type *subsys,struct device_type {const char *name;const struct attribute_group **groups; -int (*uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid);void (*release)(struct device *dev);include/linux/firewire.h +3
-3@@ -208,7 +208,7 @@ struct fw_device {struct fw_attribute_group attribute_group; }; -static inline struct fw_device *fw_device (struct device *dev) +static inline struct fw_device *fw_device (const struct device *dev) { return container_of(dev, struct fw_device, device); }@@ -229,7 +229,7 @@ struct fw_unit {struct fw_attribute_group attribute_group; }; -static inline struct fw_unit *fw_unit (struct device *dev) +static inline struct fw_unit *fw_unit (const struct device *dev) { return container_of(dev, struct fw_unit, device); }@@ -246,7 +246,7 @@ static inline void fw_unit_put(struct fw_unit *unit)put_device (&unit->device); } -static inline struct fw_device *fw_parent_device (struct fw_unit *unit) +static inline struct fw_device *fw_parent_device (const struct fw_unit *unit) {return fw_device (unit->device.parent); }include/linux/i3c/device.h +2
-2@@ -186,7 +186,7 @@ static inline struct i3c_driver *drv_to_i3cdrv(struct device_driver *drv) }struct device *i3cdev_to_dev (struct i3c_device *i3cdev); -struct i3c_device *dev_to_i3cdev (struct device *dev); +struct i3c_device *dev_to_i3cdev (const struct device *dev);const struct i3c_device_id * i3c_device_match_id(struct i3c_device *i3cdev,@@ -293,7 +293,7 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev,struct i3c_priv_xfer *xfers, int nxfers); -void i3c_device_get_info (struct i3c_device *dev,struct i3c_device_info *info); +void i3c_device_get_info (const struct i3c_device *dev,struct i3c_device_info *info);struct i3c_ibi_payload {unsigned int len;include/linux/of_device.h +2
-2@@ -36,7 +36,7 @@ extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);extern int of_device_request_module (struct device *dev);extern void of_device_uevent (const struct device *dev,struct kobj_uevent_env *env); -extern int of_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env); +extern int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env);static inline struct device_node *of_cpu_device_node_get (int cpu) {@@ -83,7 +83,7 @@ static inline int of_device_request_module(struct device *dev)return -ENODEV ; } -static inline int of_device_uevent_modalias (struct device *dev, +static inline int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return -ENODEV ;include/linux/soundwire/sdw_type.h +1
-1@@ -21,7 +21,7 @@ static inline int is_sdw_slave(const struct device *dev)int __sdw_register_driver (struct sdw_driver *drv,struct module *owner);void sdw_unregister_driver (struct sdw_driver *drv); -int sdw_slave_uevent (struct device *dev,struct kobj_uevent_env *env); +int sdw_slave_uevent (const struct device *dev,struct kobj_uevent_env *env);/** * module_sdw_driver() - Helper macro for registering a Soundwire driver include/linux/surface_aggregator/device.h +1
-2@@ -229,7 +229,7 @@ static inline bool is_ssam_device(struct device *d)* Return: Returns a pointer to the &struct ssam_device wrapping the given * device @d. */ -static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); } --2.38.1
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 60 lines · Rafael J. Wysocki
Quoted 49 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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 Jens Axboe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Cc Stefan Richter <[email protected]>Cc Wolfram Sang <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Sean Young <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>Cc Maximilian Luz <[email protected]>Cc Hans de Goede <[email protected]>Cc Mark Gross <[email protected]>Cc Vinod Koul <[email protected]>Cc Bard Liao <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Sanyog Kale <[email protected]>Cc Andreas Noever <[email protected]>Cc Michael Jamet <[email protected]>Cc Mika Westerberg <[email protected]>Cc Yehezkel Bernat <[email protected]>Cc Jiri Slaby <[email protected]>Cc Heikki Krogerus <[email protected]>Cc "Matthew Wilcox (Oracle)" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Chaitanya Kulkarni <[email protected]>Cc Ming Lei <[email protected]>Cc Jilin Yuan <[email protected]>Cc Alan Stern <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Sakari Ailus <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ira Weiny <[email protected]>Cc Dan Williams <[email protected]>Cc Won Chung <[email protected]>Quoted 8 lines
Quoted 3 lines
(which my ACPI maintainer hat on).
thanks for the review, I'll add it to the v2 patch.
greg k-h
Maximilian Luz
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
In reply to Greg Kroah-HartmanHi,
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.
[...]
Quoted 16 lines
drivers/platform/surface/aggregator/bus.c +2
-2@@ -35,9 +35,9 @@ static struct attribute *ssam_device_attrs[] = { };ATTRIBUTE_GROUPS (ssam_device); -static int ssam_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int ssam_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct ssam_device *sdev =to_ssam_device (dev); +const struct ssam_device *sdev =to_ssam_device (dev); return add_uevent_var(env, "MODALIAS=ssam:d%02Xc%02Xt%02Xi%02Xf%02X", sdev->uid.domain, sdev->uid.category,
[...]
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 11 lines
include/linux/surface_aggregator/device.h +1
-1@@ -229,7 +229,7 @@ static inline bool is_ssam_device(struct device *d)* Return: Returns a pointer to the &struct ssam_device wrapping the given * device @d. */ -static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }
I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
Regards,
Max
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.
[...]
Quoted 11 lines
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 5 lines
include/linux/surface_aggregator/device.h +1
-1-static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving container_of to recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Maximilian Luz
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.[...]
Quoted 11 lines
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 5 lines
include/linux/surface_aggregator/device.h +1
-1-static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 7 lines
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving
container_ofto recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.
Thanks! I assume you are referring to the following?
https://lore.kernel.org/lkml/[email protected]/T/
As far as I can tell this is only a warning in documentation, not compile time (which would probably be impossible?).
As I've said I'd be fine with converting the function to a macro (and preferably adding a similar warning like the one proposed in that thread). The point that irks me up is just that, as proposed, the function signature would now advertise a conversion that should never be happening.
Having two separate functions would create a compile-time guarantee, so I'd prefer that, but I can understand if that might be considered too noisy in code. Or if there is a push to make container_of() emit a compile-time warning I'd also be perfectly happy with converting it to a macro now as that'd alleviate the need for functions in the future.
Regards,
Max
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 42 lines · Maximilian Luz
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.[...]
Quoted 11 lines
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 5 lines
include/linux/surface_aggregator/device.h +1
-1-static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 7 lines
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving
container_ofto recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.Thanks! I assume you are referring to the following?
https://lore.kernel.org/lkml/[email protected]/T/As far as I can tell this is only a warning in documentation, not compile time (which would probably be impossible?).
As I've said I'd be fine with converting the function to a macro (and preferably adding a similar warning like the one proposed in that thread). The point that irks me up is just that, as proposed, the function signature would now advertise a conversion that should never be happening.
Quoted 5 lines
Having two separate functions would create a compile-time guarantee, so I'd prefer that, but I can understand if that might be considered too noisy in code. Or if there is a push to make
container_of()emit a compile-time warning I'd also be perfectly happy with converting it to a macro now as that'd alleviate the need for functions in the future.
Can't we do:
static inline const struct ssam_device *to_ssam_device(const struct device *d)
{
return container_of(d, const struct ssam_device, dev);
}Maximilian Luz
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 49 lines · Matthew Wilcox
Quoted 42 lines · Maximilian Luz
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.[...]
Quoted 11 lines
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 5 lines
include/linux/surface_aggregator/device.h +1
-1-static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 7 lines
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving
container_ofto recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.Thanks! I assume you are referring to the following?
https://lore.kernel.org/lkml/[email protected]/T/As far as I can tell this is only a warning in documentation, not compile time (which would probably be impossible?).
As I've said I'd be fine with converting the function to a macro (and preferably adding a similar warning like the one proposed in that thread). The point that irks me up is just that, as proposed, the function signature would now advertise a conversion that should never be happening.
Quoted 5 lines
Having two separate functions would create a compile-time guarantee, so I'd prefer that, but I can understand if that might be considered too noisy in code. Or if there is a push to make
container_of()emit a compile-time warning I'd also be perfectly happy with converting it to a macro now as that'd alleviate the need for functions in the future.
Quoted 6 lines
Can't we do:
static inline const struct
ssam_device*to_ssam_device(const struct device *d){ return container_of(d, const struct ssam_device, dev); }
There are at least a couple of places (device/driver-management and device-removal related, I think) using this function and requiring non-const access.
A bunch of other instances could be converted to const-access only, but that would require a couple more function signature changes (I should probably set up a patch for that regardless of this here as being a bit more strict about this makes sense).
Regards,
Max
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
In reply to Matthew WilcoxQuoted 49 lines · Matthew Wilcox
Quoted 42 lines · Maximilian Luz
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.[...]
Quoted 11 lines
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 5 lines
include/linux/surface_aggregator/device.h +1
-1-static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 7 lines
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving
container_ofto recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.Thanks! I assume you are referring to the following?
https://lore.kernel.org/lkml/[email protected]/T/As far as I can tell this is only a warning in documentation, not compile time (which would probably be impossible?).
As I've said I'd be fine with converting the function to a macro (and preferably adding a similar warning like the one proposed in that thread). The point that irks me up is just that, as proposed, the function signature would now advertise a conversion that should never be happening.
Quoted 5 lines
Having two separate functions would create a compile-time guarantee, so I'd prefer that, but I can understand if that might be considered too noisy in code. Or if there is a push to make
container_of()emit a compile-time warning I'd also be perfectly happy with converting it to a macro now as that'd alleviate the need for functions in the future.
Quoted 7 lines
Can't we do:
static inline const struct
ssam_device*to_ssam_device(const struct device *d){ return container_of(d, const struct ssam_device, dev); }
You could, if you can always handle a const pointer coming out of this function, but I don't think you can.
What you might want to do instead, and I'll be glad to do it for all of the functions like this I change, is to do what we have for struct device now:
static inline struct device *__kobj_to_dev(struct kobject *kobj)
{
return container_of(kobj, struct device, kobj);
}static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
{
return container_of(kobj, const struct device, kobj);
}/*
* container_of() will happily take a const * and spit back a non-const * as it
* is just doing pointer math. But we want to be a bit more careful in the
* driver code, so manually force any const * of a kobject to also be a const *
* to a device.
*/
#define kobj_to_dev(kobj) \
_Generic((kobj), \
const struct kobject *: __kobj_to_dev_const, \struct kobject *: __kobj_to_dev)(kobj)
Want me to do the same thing here as well?
thanks,
greg k-h
Maximilian Luz
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 81 lines · Greg Kroah-Hartman
Quoted 49 lines · Matthew Wilcox
Quoted 42 lines · Maximilian Luz
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.[...]
Quoted 11 lines
include/linux/surface_aggregator/device.h static inline bool is_ssam_device(struct device *d) · line 235
Quoted 5 lines
include/linux/surface_aggregator/device.h +1
-1-static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 7 lines
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving
container_ofto recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.Thanks! I assume you are referring to the following?
https://lore.kernel.org/lkml/[email protected]/T/As far as I can tell this is only a warning in documentation, not compile time (which would probably be impossible?).
As I've said I'd be fine with converting the function to a macro (and preferably adding a similar warning like the one proposed in that thread). The point that irks me up is just that, as proposed, the function signature would now advertise a conversion that should never be happening.
Quoted 5 lines
Having two separate functions would create a compile-time guarantee, so I'd prefer that, but I can understand if that might be considered too noisy in code. Or if there is a push to make
container_of()emit a compile-time warning I'd also be perfectly happy with converting it to a macro now as that'd alleviate the need for functions in the future.Quoted 7 lines
Can't we do:
static inline const struct
ssam_device*to_ssam_device(const struct device *d){ return container_of(d, const struct ssam_device, dev); }You could, if you can always handle a const pointer coming out of this function, but I don't think you can.
What you might want to do instead, and I'll be glad to do it for all of the functions like this I change, is to do what we have for struct device now:
static inline struct device *__kobj_to_dev(struct kobject *kobj)
{ return container_of(kobj, struct device, kobj); }static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
{ return container_of(kobj, const struct device, kobj); }/*
*container_of()will happily take a const * and spit back a non-const * as it
* is just doing pointer math. But we want to be a bit more careful in the
* driver code, so manually force any const * of a kobject to also be a const *
* to a device.
*/
Quoted 7 lines
#define kobj_to_dev(kobj) \ _Generic((kobj), \ const struct kobject *: __kobj_to_dev_const, \ struct kobject *: __kobj_to_dev)(kobj)Want me to do the same thing here as well?
That looks great! Thanks!
I would very much prefer that.
Regards,
Max
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 88 lines · Maximilian Luz
Quoted 87 lines · Greg Kroah-Hartman
Quoted 49 lines · Matthew Wilcox
Quoted 42 lines · Maximilian Luz
Quoted 20 lines · Andy Shevchenko
Quoted 5 lines · Maximilian Luz
Quoted 4 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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.[...]
Quoted 11 lines
Review
Quoted 5 lines
(quoted diff) +1
-1-static inline struct ssam_device *to_ssam_device(struct device *d) +static inline struct ssam_device *to_ssam_device(const struct device *d) { return container_of(d, struct ssam_device, dev); }I am slightly conflicted about this change as that now more or less implicitly drops the const. So I'm wondering if it wouldn't be better to either create a function specifically for const pointers or to just open-code it in the instance above.
Quoted 7 lines
Quoted 3 lines
I guess we could also convert this to a macro. Then at least there wouldn't be an explicit and potentially misleading const-conversion indicated in the function signature.
This is an intermediate step as far as I know since moving
container_ofto recognize const is a bit noisy right now. I guess you can find a discussion on the topic between Greg and Sakari.Thanks! I assume you are referring to the following?
https://lore.kernel.org/lkml/[email protected]/T/As far as I can tell this is only a warning in documentation, not compile time (which would probably be impossible?).
As I've said I'd be fine with converting the function to a macro (and preferably adding a similar warning like the one proposed in that thread). The point that irks me up is just that, as proposed, the function signature would now advertise a conversion that should never be happening.
Quoted 5 lines
Having two separate functions would create a compile-time guarantee, so I'd prefer that, but I can understand if that might be considered too noisy in code. Or if there is a push to make
container_of()emit a compile-time warning I'd also be perfectly happy with converting it to a macro now as that'd alleviate the need for functions in the future.Quoted 7 lines
Can't we do:
static inline const struct
ssam_device*to_ssam_device(const struct device *d){ return container_of(d, const struct ssam_device, dev); }You could, if you can always handle a const pointer coming out of this function, but I don't think you can.
What you might want to do instead, and I'll be glad to do it for all of the functions like this I change, is to do what we have for struct device now:
static inline struct device *__kobj_to_dev(struct kobject *kobj)
{ return container_of(kobj, struct device, kobj); }static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
{ return container_of(kobj, const struct device, kobj); }/*
*container_of()will happily take a const * and spit back a non-const * as it
* is just doing pointer math. But we want to be a bit more careful in the
* driver code, so manually force any const * of a kobject to also be a const *
* to a device.
*/#define kobj_to_dev(kobj) \ _Generic((kobj), \ const struct kobject *: __kobj_to_dev_const, \ struct kobject *: __kobj_to_dev)(kobj)
Quoted 5 lines
Quoted 1 line
Want me to do the same thing here as well?
That looks great! Thanks!
I would very much prefer that.
Ok, will respin this patch as at least 2 individual patches, one that does the change to to_ssam_device() and the next that does the bus-wide changes.
I'll review the other container_of() users in this patch as well to see if they can be converted as well.
thanks,
greg k-h
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
In reply to Greg Kroah-HartmanQuoted 16 lines · Greg Kroah-Hartman
static inline struct device *__kobj_to_dev(struct kobject *kobj)
{ return container_of(kobj, struct device, kobj); }static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
{ return container_of(kobj, const struct device, kobj); }/*
*container_of()will happily take a const * and spit back a non-const * as it
* is just doing pointer math. But we want to be a bit more careful in the
* driver code, so manually force any const * of a kobject to also be a const *
* to a device.
*/
Quoted 7 lines
#define kobj_to_dev(kobj) \ _Generic((kobj), \ const struct kobject *: __kobj_to_dev_const, \struct kobject *: __kobj_to_dev)(kobj)
Want me to do the same thing here as well?
It would be nice to have a shared macro code gen all of the above instead of copy and pasting it. Then maybe other cases beyond struct device could adopt const too..
Jason
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 23 lines · Jason Gunthorpe
Quoted 22 lines · Greg Kroah-Hartman
static inline struct device *__kobj_to_dev(struct kobject *kobj)
{ return container_of(kobj, struct device, kobj); }static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
{ return container_of(kobj, const struct device, kobj); }/*
*container_of()will happily take a const * and spit back a non-const * as it
* is just doing pointer math. But we want to be a bit more careful in the
* driver code, so manually force any const * of a kobject to also be a const *
* to a device.
*/#define kobj_to_dev(kobj) \ _Generic((kobj), \ const struct kobject *: __kobj_to_dev_const, \struct kobject *: __kobj_to_dev)(kobj)
Quoted 5 lines
Quoted 1 line
Want me to do the same thing here as well?
It would be nice to have a shared macro code gen all of the above instead of copy and pasting it. Then maybe other cases beyond struct device could adopt const too..
I think I tried to create such a beast, but failed, so ended up open-coding it in a few places in the USB headers already. I can try it again, but the redirection gets tricky (defines creating defines...)
thanks,
greg k-h
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 26 lines · Greg Kroah-Hartman
Quoted 25 lines · Jason Gunthorpe
Quoted 23 lines · Greg Kroah-Hartman
static inline struct device *__kobj_to_dev(struct kobject *kobj)
{ return container_of(kobj, struct device, kobj); }static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj)
{ return container_of(kobj, const struct device, kobj); }/*
*container_of()will happily take a const * and spit back a non-const * as it
* is just doing pointer math. But we want to be a bit more careful in the
* driver code, so manually force any const * of a kobject to also be a const *
* to a device.
*/#define kobj_to_dev(kobj) \ _Generic((kobj), \ const struct kobject *: __kobj_to_dev_const, \struct kobject *: __kobj_to_dev)(kobj)
Want me to do the same thing here as well?
Quoted 7 lines
Quoted 3 lines
It would be nice to have a shared macro code gen all of the above instead of copy and pasting it. Then maybe other cases beyond struct device could adopt const too..
I think I tried to create such a beast, but failed, so ended up open-coding it in a few places in the USB headers already. I can try it again, but the redirection gets tricky (defines creating defines...)
This seems OK:
#define generic_container_of(in_type, in, out_type, out_member) \
_Generic(in, \
const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \
in_type *: ((out_type *)container_of(in, out_type, out_member)) \
)#define kobj_to_dev(__kobj) \
generic_container_of(struct kobject, __kobj, struct device, kobj)
Jason
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \
_Generic(in, \
const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \
in_type *: ((out_type *)container_of(in, out_type, out_member)) \
)There's a neat trick I found in seqlock.h:
#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )
and now it fits in 80 columns ;-)
Quoted 4 lines
#define
kobj_to_dev(__kobj)\
generic_container_of(struct kobject, __kobj, struct device, kobj)Jason
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 9 lines · Matthew Wilcox
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \ _Generic(in, \ const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \ in_type *: ((out_type *)container_of(in, out_type, out_member)) \ )There's a neat trick I found in
seqlock.h:
Quoted 7 lines
#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )and now it fits in 80 columns ;-)
Aside from less letters, is their another benifit to using *(in) ?
Jason
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 16 lines · Jason Gunthorpe
Quoted 15 lines · Matthew Wilcox
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \ _Generic(in, \ const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \ in_type *: ((out_type *)container_of(in, out_type, out_member)) \ )There's a neat trick I found in
seqlock.h:#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )
Quoted 3 lines
Quoted 1 line
and now it fits in 80 columns ;-)
Aside from less letters, is their another benifit to using *(in) ?
I don't think so. It just looks nicer to me than putting the star in each case. If I'd thought of it, I would have done it to page_folio(), but I won't change it now.
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 17 lines · Matthew Wilcox
Quoted 16 lines · Jason Gunthorpe
Quoted 15 lines · Matthew Wilcox
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \ _Generic(in, \ const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \ in_type *: ((out_type *)container_of(in, out_type, out_member)) \ )There's a neat trick I found in
seqlock.h:#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
and now it fits in 80 columns ;-)
Aside from less letters, is their another benifit to using *(in) ?
I don't think so. It just looks nicer to me than putting the star in each case. If I'd thought of it, I would have done it to
page_folio(), but I won't change it now.
Ah, but your trick will not work, that blows up and will not build. The original one from Jason here does work. _Generic is tricky...
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
In reply to Matthew WilcoxQuoted 9 lines · Matthew Wilcox
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \ _Generic(in, \ const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \ in_type *: ((out_type *)container_of(in, out_type, out_member)) \ )There's a neat trick I found in
seqlock.h:
Quoted 7 lines
#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )and now it fits in 80 columns ;-)
Nice trick! Dropping the inline functions is a bit different, let me see if that still gives a sane error if we pass an incorrect type or mess with the const * the wrong way. I'll run some tests tomorrow afternoon...
thanks,
greg k-h
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Matthew Wilcox
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \ _Generic(in, \ const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \ in_type *: ((out_type *)container_of(in, out_type, out_member)) \ )There's a neat trick I found in
seqlock.h:#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )
Quoted 6 lines
Quoted 1 line
and now it fits in 80 columns ;-)
Nice trick! Dropping the inline functions is a bit different, let me see if that still gives a sane error if we pass an incorrect type or mess with the const * the wrong way. I'll run some tests tomorrow afternoon...
The errors in some cases are very verbose, but it is somewhat understandable - the worst is when _Generic fails to match anything, but also at least clang partially expanded container_of and it throws other assertions too.
I also wonder if this could just be rolled into the normal container_of.
in_type would have to be derived like:
in_type = typeof((out_type *)NULL)->out_member)
But I don't know if you can use typeof in a generic type matching expression..
Jason
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 24 lines · Jason Gunthorpe
Quoted 16 lines · Greg Kroah-Hartman
Quoted 15 lines · Matthew Wilcox
Quoted 5 lines · Jason Gunthorpe
#define generic_container_of(in_type, in, out_type, out_member) \ _Generic(in, \ const in_type *: ((const out_type *)container_of(in, out_type, out_member)), \ in_type *: ((out_type *)container_of(in, out_type, out_member)) \ )There's a neat trick I found in
seqlock.h:#define generic_container_of(in_t, in, out_t, m) \ _Generic(*(in), \ const in_t: ((const out_t *)container_of(in, out_t, m)), \ in_t: ((out_t *)container_of(in, out_type, m)) \ )Quoted 6 lines
Quoted 1 line
and now it fits in 80 columns ;-)
Nice trick! Dropping the inline functions is a bit different, let me see if that still gives a sane error if we pass an incorrect type or mess with the const * the wrong way. I'll run some tests tomorrow afternoon...
Quoted 7 lines
The errors in some cases are very verbose, but it is somewhat understandable - the worst is when
_Genericfails to match anything, but also at least clang partially expandedcontainer_ofand it throws other assertions too.I also wonder if this could just be rolled into the normal
container_of.
I think we might be able to now, my previous attempts with inline functions prevented that. I'll beat on that tomorrow...
Quoted 5 lines
in_typewould have to be derived like:
in_type=typeof((out_type *)NULL)->out_member)But I don't know if you can use typeof in a generic type matching expression..
Maybe that is what threw me before, I can't remember. I do know we tried a number of different attempts, can't recall the failed ones...
thanks,
greg k-h
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Hi
2022. november 23., szerda 20:06 keltezéssel, Greg Kroah-Hartman írta:
Quoted 43 lines · Jason Gunthorpe
Quoted 28 lines · Greg Kroah-Hartman
Quoted 19 lines · Matthew Wilcox
Quoted 17 lines · Jason Gunthorpe
Quoted 6 lines
#define
generic_container_of(in_type, in, out_type, out_member)\
_Generic(in, \
constin_type*: ((constout_type*)container_of(in,out_type,out_member)), \in_type*: ((out_type*)container_of(in,out_type,out_member)) \
)There's a neat trick I found in
seqlock.h:#define
generic_container_of(in_t, in, out_t, m)\
_Generic(*(in), \
constin_t: ((constout_t*)container_of(in,out_t, m)), \in_t: ((out_t*)container_of(in,out_type, m)) \
)Quoted 6 lines
Quoted 1 line
and now it fits in 80 columns ;-)
Nice trick! Dropping the inline functions is a bit different, let me see if that still gives a sane error if we pass an incorrect type or mess with the const * the wrong way. I'll run some tests tomorrow afternoon...
Quoted 7 lines
The errors in some cases are very verbose, but it is somewhat understandable - the worst is when
_Genericfails to match anything, but also at least clang partially expandedcontainer_ofand it throws other assertions too.I also wonder if this could just be rolled into the normal
container_of.I think we might be able to now, my previous attempts with inline functions prevented that. I'll beat on that tomorrow...
Quoted 2 lines
in_typewould have to be derived like:
Quoted 8 lines
Quoted 3 lines
in_type=typeof((out_type *)NULL)->out_member)But I don't know if you can use typeof in a generic type matching expression..
Maybe that is what threw me before, I can't remember. I do know we tried a number of different attempts, can't recall the failed ones...
I am sorry I haven't followed the previous discussion, but has something like the following been considered?
#define container_of2(ptr, type, member) \ _Generic((ptr), \ typeof_member(const type, member) *: container_of((ptr), const type, member), \ const void *: container_of((ptr), const type, member), \ default: container_of((ptr), type, member) \ )
This is not perfect by any means, but I believe it is a reasonable improvement. It only really works reliably if the member type and the specified type in the arguments are unqualified, but I believe that should cover the majority of cases.
I have tried to build an x86-64 defconfig with this and there are numerous const violations, but I haven't seen any false positives.
Quoted 1 line
[...]
Regards,
Barnabás Pőcze
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
In reply to Greg Kroah-HartmanQuoted 18 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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 Jens Axboe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Cc Stefan Richter <[email protected]>Cc Wolfram Sang <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Sean Young <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>Cc Maximilian Luz <[email protected]>Cc Hans de Goede <[email protected]>
Quoted 8 lines
Cc Mark Gross <[email protected]>Cc Vinod Koul <[email protected]>Cc Bard Liao <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Sanyog Kale <[email protected]>Cc Andreas Noever <[email protected]>Cc Michael Jamet <[email protected]>Cc Mika Westerberg <[email protected]>
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 28 lines · Mika Westerberg
Quoted 18 lines · Greg Kroah-Hartman
The
uevent()callback in structdevice_typeshould 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 Jens Axboe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Cc Stefan Richter <[email protected]>Cc Wolfram Sang <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Sean Young <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>Cc Maximilian Luz <[email protected]>Cc Hans de Goede <[email protected]>Quoted 8 lines
Cc Mark Gross <[email protected]>Cc Vinod Koul <[email protected]>Cc Bard Liao <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Sanyog Kale <[email protected]>Cc Andreas Noever <[email protected]>Cc Michael Jamet <[email protected]>Cc Mika Westerberg <[email protected]>
Quoted 1 line
Thanks for the review.
Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
In reply to Greg Kroah-HartmanEm Wed, 23 Nov 2022 13:25:21 +0100
Greg Kroah-Hartman <[email protected]> escreveu:
Quoted 4 lines
The
uevent()callback in structdevice_typeshould 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.
Quoted 668 lines
Cc Jens Axboe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Cc Stefan Richter <[email protected]>Cc Wolfram Sang <[email protected]>Cc Alexandre Belloni <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Sean Young <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Rob Herring <[email protected]>Cc Frank Rowand <[email protected]>Cc Maximilian Luz <[email protected]>Cc Hans de Goede <[email protected]>Cc Mark Gross <[email protected]>Cc Vinod Koul <[email protected]>Cc Bard Liao <[email protected]>Cc Pierre-Louis Bossart <[email protected]>Cc Sanyog Kale <[email protected]>Cc Andreas Noever <[email protected]>Cc Michael Jamet <[email protected]>Cc Mika Westerberg <[email protected]>Cc Yehezkel Bernat <[email protected]>Cc Jiri Slaby <[email protected]>Cc Heikki Krogerus <[email protected]>Cc "Matthew Wilcox (Oracle)" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Chaitanya Kulkarni <[email protected]>Cc Ming Lei <[email protected]>Cc Jilin Yuan <[email protected]>Cc Alan Stern <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Sakari Ailus <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ira Weiny <[email protected]>Cc Dan Williams <[email protected]>Cc Won Chung <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- block/partitions/core.c | 4 ++-- drivers/acpi/device_sysfs.c | 8 ++++---- drivers/acpi/internal.h | 2 +- drivers/firewire/core-device.c | 8 ++++---- drivers/i2c/i2c-core-base.c | 4 ++-- drivers/i3c/device.c | 4 ++-- drivers/i3c/master.c | 4 ++-- drivers/input/input.c | 16 ++++++++-------- drivers/media/rc/rc-main.c | 2 +- drivers/of/device.c | 4 ++-- drivers/platform/surface/aggregator/bus.c | 4 ++-- drivers/soundwire/bus_type.c | 4 ++-- drivers/thunderbolt/switch.c | 4 ++-- drivers/thunderbolt/tb.h | 2 +- drivers/thunderbolt/xdomain.c | 6 +++--- drivers/tty/serdev/core.c | 2 +- drivers/usb/core/message.c | 8 ++++---- drivers/usb/core/usb.c | 4 ++-- drivers/usb/phy/phy.c | 6 +++--- drivers/usb/roles/class.c | 3 +-- drivers/usb/typec/class.c | 2 +- include/linux/acpi.h | 4 ++-- include/linux/device.h | 2 +- include/linux/firewire.h | 6 +++--- include/linux/i3c/device.h | 4 ++-- include/linux/of_device.h | 4 ++-- include/linux/soundwire/sdw_type.h | 2 +- include/linux/surface_aggregator/device.h | 2 +- 28 files changed, 62 insertions(+), 63 deletions(-)block/partitions/core.c +2
-2@@ -254,9 +254,9 @@ static void part_release(struct device *dev)iput (dev_to_bdev (dev)->bd_inode); } -static int part_uevent (struct device *dev,struct kobj_uevent_env *env) +static int part_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct block_device *part =dev_to_bdev (dev); +const struct block_device *part =dev_to_bdev (dev);add_uevent_var (env,"PARTN=%u" , part->bd_partno);if (part->bd_meta_info && part->bd_meta_info->volname[0 ])drivers/acpi/device_sysfs.c +4
-4@@ -133,7 +133,7 @@ static void acpi_hide_nondev_subnodes(struct acpi_device_data *data)* -EINVAL: output error * -ENOMEM: output is truncated */ -static int create_pnp_modalias (struct acpi_device *acpi_dev,char *modalias, +static int create_pnp_modalias (const struct acpi_device *acpi_dev,char *modalias,int size) {int len;@@ -191,7 +191,7 @@ static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,* only be called for devices having ACPI_DT_NAMESPACE_HID in their list of * ACPI/PNP IDs. */ -static int create_of_modalias (struct acpi_device *acpi_dev,char *modalias, +static int create_of_modalias (const struct acpi_device *acpi_dev,char *modalias,int size) {struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER };@@ -239,7 +239,7 @@ static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,return len; } -int __acpi_device_uevent_modalias (struct acpi_device *adev, +int __acpi_device_uevent_modalias (const struct acpi_device *adev,struct kobj_uevent_env *env) {int len;@@ -277,7 +277,7 @@ int __acpi_device_uevent_modalias(struct acpi_device *adev,* Because other buses do not support ACPI HIDs & CIDs, e.g. for a device with * hid:IBM0001 and cid:ACPI0001 you get: "acpi:IBM0001:ACPI0001". */ -int acpi_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env) +int acpi_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return __acpi_device_uevent_modalias (acpi_companion_match (dev), env); }drivers/acpi/internal.h +1
-1@@ -120,7 +120,7 @@ int acpi_bus_register_early_device(int type);Device Matching and Notification -------------------------------------------------------------------------- */ struct acpi_device *acpi_companion_match (const struct device *dev); -int __acpi_device_uevent_modalias (struct acpi_device *adev, +int __acpi_device_uevent_modalias (const struct acpi_device *adev,struct kobj_uevent_env *env);/* -------------------------------------------------------------------------- drivers/firewire/core-device.c +4
-4@@ -133,7 +133,7 @@ static void get_ids(const u32 *directory, int *id) } } -static void get_modalias_ids (struct fw_unit *unit,int *id) +static void get_modalias_ids (const struct fw_unit *unit,int *id) {get_ids (&fw_parent_device (unit)->config_rom[5 ], id);get_ids (unit->directory, id);@@ -195,7 +195,7 @@ static void fw_unit_remove(struct device *dev) driver->remove (fw_unit (dev)); } -static int get_modalias (struct fw_unit *unit,char *buffer,size_t buffer_size) +static int get_modalias (const struct fw_unit *unit,char *buffer,size_t buffer_size) {int id[] = {0 ,0 ,0 ,0 };@@ -206,9 +206,9 @@ static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) id[0], id[1], id[2], id[3]); } -static int fw_unit_uevent (struct device *dev,struct kobj_uevent_env *env) +static int fw_unit_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_unit *unit =fw_unit (dev); +const struct fw_unit *unit =fw_unit (dev);char modalias[64 ];get_modalias (unit, modalias,sizeof (modalias));drivers/i2c/i2c-core-base.c +2
-2@@ -136,9 +136,9 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)return 0 ; } -static int i2c_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int i2c_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct i2c_client *client =to_i2c_client (dev); +const struct i2c_client *client =to_i2c_client (dev);int rc; rc =of_device_uevent_modalias (dev, env);drivers/i3c/device.c +2
-2@@ -58,7 +58,7 @@ EXPORT_SYMBOL_GPL(i3c_device_do_priv_xfers);* * Retrieve I3C dev info. */ -void i3c_device_get_info (struct i3c_device *dev, +void i3c_device_get_info (const struct i3c_device *dev,struct i3c_device_info *info) {if (!info)@@ -194,7 +194,7 @@ EXPORT_SYMBOL_GPL(i3cdev_to_dev);* * Return: a pointer to an I3C device object. */ -struct i3c_device *dev_to_i3cdev (struct device *dev) +struct i3c_device *dev_to_i3cdev (const struct device *dev) { return container_of(dev, struct i3c_device, dev); }drivers/i3c/master.c +2
-2@@ -273,9 +273,9 @@ static struct attribute *i3c_device_attrs[] = { };ATTRIBUTE_GROUPS (i3c_device); -static int i3c_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int i3c_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct i3c_device *i3cdev =dev_to_i3cdev (dev); +const struct i3c_device *i3cdev =dev_to_i3cdev (dev);struct i3c_device_info devinfo;u16 manuf, part, ext;drivers/input/input.c +8
-8@@ -1371,7 +1371,7 @@ INPUT_DEV_STRING_ATTR_SHOW(phys);INPUT_DEV_STRING_ATTR_SHOW (uniq);static int input_print_modalias_bits (char *buf,int size, -char name,unsigned long *bm, +char name,const unsigned long *bm,unsigned int min_bit,unsigned int max_bit) {int len =0 , i;@@ -1383,7 +1383,7 @@ static int input_print_modalias_bits(char *buf, int size,return len; } -static int input_print_modalias (char *buf,int size,struct input_dev *id, +static int input_print_modalias (char *buf,int size,const struct input_dev *id,int add_cr) {int len;@@ -1431,7 +1431,7 @@ static ssize_t input_dev_show_modalias(struct device *dev, } static DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); -static int input_print_bitmap (char *buf,int buf_size,unsigned long *bitmap, +static int input_print_bitmap (char *buf,int buf_size,const unsigned long *bitmap,int max,int add_cr); static ssize_t input_dev_show_properties(struct device *dev,@@ -1523,7 +1523,7 @@ static const struct attribute_group input_dev_id_attr_group = { .attrs = input_dev_id_attrs, }; -static int input_print_bitmap (char *buf,int buf_size,unsigned long *bitmap, +static int input_print_bitmap (char *buf,int buf_size,const unsigned long *bitmap,int max,int add_cr) {int i;@@ -1620,7 +1620,7 @@ static void input_dev_release(struct device *device)* device bitfields. */ static int input_add_uevent_bm_var (struct kobj_uevent_env *env, -const char *name,unsigned long *bitmap,int max) +const char *name,const unsigned long *bitmap,int max) {int len;@@ -1638,7 +1638,7 @@ static int input_add_uevent_bm_var(struct kobj_uevent_env *env, }static int input_add_uevent_modalias_var (struct kobj_uevent_env *env, -struct input_dev *dev) +const struct input_dev *dev) {int len;@@ -1676,9 +1676,9 @@ static int input_add_uevent_modalias_var(struct kobj_uevent_env *env,return err; \ }while (0 ) -static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) +static int input_dev_uevent(const struct device *device, struct kobj_uevent_env *env) { -struct input_dev *dev =to_input_dev (device); +const struct input_dev *dev =to_input_dev (device); INPUT_ADD_HOTPLUG_VAR("PRODUCT=%x/%x/%x/%x", dev->id.bustype, dev->id.vendor,drivers/media/rc/rc-main.c +1
-1@@ -1614,7 +1614,7 @@ static void rc_dev_release(struct device *device)kfree (dev); } -static int rc_dev_uevent (struct device *device,struct kobj_uevent_env *env) +static int rc_dev_uevent (const struct device *device,struct kobj_uevent_env *env) {struct rc_dev *dev =to_rc_dev (device);int ret =0 ;drivers/of/device.c +2
-2@@ -248,7 +248,7 @@ const void *of_device_get_match_data(const struct device *dev) }EXPORT_SYMBOL (of_device_get_match_data); -static ssize_t of_device_get_modalias (struct device *dev,char *str,ssize_t len) +static ssize_t of_device_get_modalias (const struct device *dev,char *str,ssize_t len) {const char *compat;char *c;@@ -372,7 +372,7 @@ void of_device_uevent(const struct device *dev, struct kobj_uevent_env *env)mutex_unlock (&of_mutex); } -int of_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env) +int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {int sl;drivers/platform/surface/aggregator/bus.c +2
-2@@ -35,9 +35,9 @@ static struct attribute *ssam_device_attrs[] = { };ATTRIBUTE_GROUPS (ssam_device); -static int ssam_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int ssam_device_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct ssam_device *sdev =to_ssam_device (dev); +const struct ssam_device *sdev =to_ssam_device (dev); return add_uevent_var(env, "MODALIAS=ssam:d%02Xc%02Xt%02Xi%02Xf%02X", sdev->uid.domain, sdev->uid.category,drivers/soundwire/bus_type.c +2
-2@@ -58,9 +58,9 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) slave->id.sdw_version, slave->id.class_id); } -int sdw_slave_uevent (struct device *dev,struct kobj_uevent_env *env) +int sdw_slave_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct sdw_slave *slave =dev_to_sdw_dev (dev); +const struct sdw_slave *slave =dev_to_sdw_dev (dev);char modalias[32 ];sdw_slave_modalias (slave, modalias,sizeof (modalias));drivers/thunderbolt/switch.c +2
-2@@ -2175,9 +2175,9 @@ static void tb_switch_release(struct device *dev)kfree (sw); } -static int tb_switch_uevent (struct device *dev,struct kobj_uevent_env *env) +static int tb_switch_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct tb_switch *sw =tb_to_switch (dev); +const struct tb_switch *sw =tb_to_switch (dev);const char *type;if (sw->config.thunderbolt_version ==USB4_VERSION_1_0 ) {drivers/thunderbolt/tb.h +1
-1@@ -815,7 +815,7 @@ static inline bool tb_is_switch(const struct device *dev)return dev->type == &tb_switch_type; } -static inline struct tb_switch *tb_to_switch (struct device *dev) +static inline struct tb_switch *tb_to_switch (const struct device *dev) {if (tb_is_switch (dev)) return container_of(dev, struct tb_switch, dev);drivers/thunderbolt/xdomain.c +3
-3@@ -881,7 +881,7 @@ static ssize_t key_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (key); -static int get_modalias (struct tb_service *svc,char *buf,size_t size) +static int get_modalias (const struct tb_service *svc,char *buf,size_t size) {return snprintf (buf, size,"tbsvc:k%sp%08Xv%08Xr%08X" , svc->key, svc->prtcid, svc->prtcvers, svc->prtcrevs);@@ -953,9 +953,9 @@ static const struct attribute_group *tb_service_attr_groups[] = { NULL, }; -static int tb_service_uevent (struct device *dev,struct kobj_uevent_env *env) +static int tb_service_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct tb_service *svc = container_of(dev, struct tb_service, dev); + const struct tb_service *svc = container_of(dev, struct tb_service, dev);char modalias[64 ];get_modalias (svc, modalias,sizeof (modalias));drivers/tty/serdev/core.c +1
-1@@ -42,7 +42,7 @@ static struct attribute *serdev_device_attrs[] = { };ATTRIBUTE_GROUPS (serdev_device); -static int serdev_device_uevent (struct device *dev,struct kobj_uevent_env *env) +static int serdev_device_uevent (const struct device *dev,struct kobj_uevent_env *env) {int rc;drivers/usb/core/message.c +4
-4@@ -1818,11 +1818,11 @@ void usb_authorize_interface(struct usb_interface *intf) } } -static int usb_if_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_if_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_device *usb_dev; -struct usb_interface *intf; -struct usb_host_interface *alt; +const struct usb_device *usb_dev; +const struct usb_interface *intf; +const struct usb_host_interface *alt; intf =to_usb_interface (dev); usb_dev =interface_to_usbdev (intf);drivers/usb/core/usb.c +2
-2@@ -423,9 +423,9 @@ static void usb_release_dev(struct device *dev)kfree (udev); } -static int usb_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_device *usb_dev; +const struct usb_device *usb_dev; usb_dev =to_usb_device (dev);drivers/usb/phy/phy.c +3
-3@@ -80,7 +80,7 @@ static struct usb_phy *__of_usb_find_phy(struct device_node *node)return ERR_PTR (-EPROBE_DEFER ); } -static struct usb_phy *__device_to_usb_phy (struct device *dev) +static struct usb_phy *__device_to_usb_phy (const struct device *dev) {struct usb_phy *usb_phy;@@ -145,9 +145,9 @@ static void usb_phy_notify_charger_work(struct work_struct *work)kobject_uevent (&usb_phy->dev->kobj,KOBJ_CHANGE ); } -static int usb_phy_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_phy_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct usb_phy *usb_phy; +const struct usb_phy *usb_phy;char uchger_state[50 ] = {0 };char uchger_type[50 ] = {0 };unsigned long flags;drivers/usb/roles/class.c +1
-2@@ -271,8 +271,7 @@ static const struct attribute_group *usb_role_switch_groups[] = { NULL, }; -static int -usb_role_switch_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_role_switch_uevent (const struct device *dev,struct kobj_uevent_env *env) {int ret;drivers/usb/typec/class.c +1
-1@@ -1718,7 +1718,7 @@ static const struct attribute_group *typec_groups[] = { NULL }; -static int typec_uevent (struct device *dev,struct kobj_uevent_env *env) +static int typec_uevent (const struct device *dev,struct kobj_uevent_env *env) {int ret;include/linux/acpi.h +2
-2@@ -722,7 +722,7 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,const void *acpi_device_get_match_data (const struct device *dev);extern bool acpi_driver_match_device (struct device *dev,const struct device_driver *drv); -int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *); +int acpi_device_uevent_modalias (const struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); struct platform_device *acpi_create_platform_device(struct acpi_device *,@@ -957,7 +957,7 @@ static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,return NULL ; } -static inline int acpi_device_uevent_modalias (struct device *dev, +static inline int acpi_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return -ENODEV ;include/linux/device.h +1
-1@@ -88,7 +88,7 @@ int subsys_virtual_register(struct bus_type *subsys,struct device_type {const char *name;const struct attribute_group **groups; -int (*uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid);void (*release)(struct device *dev);include/linux/firewire.h +3
-3@@ -208,7 +208,7 @@ struct fw_device {struct fw_attribute_group attribute_group; }; -static inline struct fw_device *fw_device (struct device *dev) +static inline struct fw_device *fw_device (const struct device *dev) { return container_of(dev, struct fw_device, device); }@@ -229,7 +229,7 @@ struct fw_unit {struct fw_attribute_group attribute_group; }; -static inline struct fw_unit *fw_unit (struct device *dev) +static inline struct fw_unit *fw_unit (const struct device *dev) { return container_of(dev, struct fw_unit, device); }@@ -246,7 +246,7 @@ static inline void fw_unit_put(struct fw_unit *unit)put_device (&unit->device); } -static inline struct fw_device *fw_parent_device (struct fw_unit *unit) +static inline struct fw_device *fw_parent_device (const struct fw_unit *unit) {return fw_device (unit->device.parent); }include/linux/i3c/device.h +2
-2@@ -186,7 +186,7 @@ static inline struct i3c_driver *drv_to_i3cdrv(struct device_driver *drv) }struct device *i3cdev_to_dev (struct i3c_device *i3cdev); -struct i3c_device *dev_to_i3cdev (struct device *dev); +struct i3c_device *dev_to_i3cdev (const struct device *dev);const struct i3c_device_id * i3c_device_match_id(struct i3c_device *i3cdev,@@ -293,7 +293,7 @@ int i3c_device_do_priv_xfers(struct i3c_device *dev,struct i3c_priv_xfer *xfers, int nxfers); -void i3c_device_get_info (struct i3c_device *dev,struct i3c_device_info *info); +void i3c_device_get_info (const struct i3c_device *dev,struct i3c_device_info *info);struct i3c_ibi_payload {unsigned int len;include/linux/of_device.h +2
-2@@ -36,7 +36,7 @@ extern ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len);extern int of_device_request_module (struct device *dev);extern void of_device_uevent (const struct device *dev,struct kobj_uevent_env *env); -extern int of_device_uevent_modalias (struct device *dev,struct kobj_uevent_env *env); +extern int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env);static inline struct device_node *of_cpu_device_node_get (int cpu) {@@ -83,7 +83,7 @@ static inline int of_device_request_module(struct device *dev)return -ENODEV ; } -static inline int of_device_uevent_modalias (struct device *dev, +static inline int of_device_uevent_modalias (const struct device *dev,struct kobj_uevent_env *env) {return -ENODEV ;include/linux/soundwire/sdw_type.h +1
-1@@ -21,7 +21,7 @@ static inline int is_sdw_slave(const struct device *dev)int __sdw_register_driver (struct sdw_driver *drv,struct module *owner);void sdw_unregister_driver (struct sdw_driver *drv); -int sdw_slave_uevent (struct device *dev,struct kobj_uevent_env *env); +int sdw_slave_uevent (const struct device *dev,struct kobj_uevent_env *env);/** * module_sdw_driver() - Helper macro for registering a Soundwire driver include/linux/surface_aggregator/device.h +1
-1@@ -229,7 +229,7 @@ static inline bool is_ssam_device(struct device *d)* Return: Returns a pointer to the &struct ssam_device wrapping the given * device @d. */ -static inline struct ssam_device *to_ssam_device (struct device *d) +static inline struct ssam_device *to_ssam_device (const struct device *d) { return container_of(d, struct ssam_device, dev); }
Greg Kroah-Hartman
maintainerRe: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
Quoted 9 lines · Mauro Carvalho Chehab
Em Wed, 23 Nov 2022 13:25:21 +0100
Greg Kroah-Hartman <[email protected]> escreveu:Quoted 4 lines
The
uevent()callback in structdevice_typeshould 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.
Thanks for the review.
Greg Kroah-Hartman
maintainerPATCH 4/5 driver core: make struct device_type.devnode() take a const *
In reply to Greg Kroah-HartmanThe devnode() 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.
--- block/genhd.c | 4 ++-- drivers/cxl/core/memdev.c | 2 +- drivers/fsi/fsi-core.c | 6 +++--- drivers/hwtracing/intel_th/core.c | 6 +++--- drivers/hwtracing/intel_th/intel_th.h | 4 ++-- drivers/usb/core/usb.c | 4 ++-- include/linux/device.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
block/genhd.c +2 -2
@@ -1193,10 +1193,10 @@ struct class block_class = { .dev_uevent = block_uevent, }; -static char *block_devnode (struct device *dev,umode_t *mode, +static char *block_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) { -struct gendisk *disk =dev_to_disk (dev); +const struct gendisk *disk =dev_to_disk (dev);if (disk->fops->devnode)return disk->fops->devnode (disk, mode);
drivers/cxl/core/memdev.c +1 -1
@@ -27,7 +27,7 @@ static void cxl_memdev_release(struct device *dev)kfree (cxlmd); } -static char *cxl_memdev_devnode (struct device *dev,umode_t *mode,kuid_t *uid, +static char *cxl_memdev_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) {return kasprintf (GFP_KERNEL ,"cxl/%s" ,dev_name (dev));
drivers/fsi/fsi-core.c +3 -3
@@ -897,10 +897,10 @@ static const struct attribute_group *cfam_attr_groups[] = { NULL, }; -static char *cfam_devnode (struct device *dev,umode_t *mode, +static char *cfam_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) { -struct fsi_slave *slave =to_fsi_slave (dev); +const struct fsi_slave *slave =to_fsi_slave (dev);#ifdef CONFIG_FSI_NEW_DEV_NODE return kasprintf (GFP_KERNEL ,"fsi/cfam%d" , slave->cdev_idx);
@@ -915,7 +915,7 @@ static const struct device_type cfam_type = { .groups = cfam_attr_groups }; -static char *fsi_cdev_devnode (struct device *dev,umode_t *mode, +static char *fsi_cdev_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) {#ifdef CONFIG_FSI_NEW_DEV_NODE
drivers/hwtracing/intel_th/core.c +3 -3
@@ -185,11 +185,11 @@ static struct device_type intel_th_source_device_type = { .release = intel_th_device_release, }; -static char *intel_th_output_devnode (struct device *dev,umode_t *mode, +static char *intel_th_output_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) { -struct intel_th_device *thdev =to_intel_th_device (dev); -struct intel_th *th =to_intel_th (thdev); +const struct intel_th_device *thdev =to_intel_th_device (dev); +const struct intel_th *th =to_intel_th (thdev);char *node;if (thdev->id >=0 )
drivers/hwtracing/intel_th/intel_th.h +2 -2
@@ -205,7 +205,7 @@ struct intel_th_driver {* INTEL_TH_SWITCH and INTEL_TH_SOURCE are children of the intel_th device. */ static inline struct intel_th_device * -to_intel_th_parent (struct intel_th_device *thdev) +to_intel_th_parent (const struct intel_th_device *thdev) {struct device *parent = thdev->dev.parent;
@@ -215,7 +215,7 @@ to_intel_th_parent(struct intel_th_device *thdev)return to_intel_th_device (parent); } -static inline struct intel_th *to_intel_th (struct intel_th_device *thdev) +static inline struct intel_th *to_intel_th (const struct intel_th_device *thdev) {if (thdev->type ==INTEL_TH_OUTPUT ) thdev =to_intel_th_parent (thdev);
drivers/usb/core/usb.c +2 -2
@@ -505,10 +505,10 @@ static const struct dev_pm_ops usb_device_pm_ops = {#endif /* CONFIG_PM */ -static char *usb_devnode (struct device *dev, +static char *usb_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) { -struct usb_device *usb_dev; +const struct usb_device *usb_dev; usb_dev =to_usb_device (dev); return kasprintf(GFP_KERNEL, "bus/usb/%03d/%03d",
include/linux/device.h +1 -1
@@ -89,7 +89,7 @@ struct device_type {const char *name;const struct attribute_group **groups;int (*uevent)(const struct device *dev,struct kobj_uevent_env *env); -char *(*devnode)(struct device *dev,umode_t *mode, +char *(*devnode)(const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid);void (*release)(struct device *dev);
Signature · 1 line
2.38.1
RE: [PATCH 4/5] driver core: make struct device_type.devnode() take a const *
Quoted 31 lines · Greg Kroah-Hartman
The
devnode()callback in structdevice_typeshould 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 Jens Axboe <[email protected]>Cc Alison Schofield <[email protected]>Cc Vishal Verma <[email protected]>Cc Ira Weiny <[email protected]>Cc Ben Widawsky <[email protected]>Cc Dan Williams <[email protected]>Cc Jeremy Kerr <[email protected]>Cc Joel Stanley <[email protected]>Cc Alistar Popple <[email protected]>Cc Eddie James <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Jilin Yuan <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Alan Stern <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Won Chung <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
[..]
drivers/cxl/core/memdev.c static void cxl_memdev_release(struct device *dev) · line 33
Quoted 13 lines
drivers/cxl/core/memdev.c +1
-1@@ -27,7 +27,7 @@ static void cxl_memdev_release(struct device *dev)kfree (cxlmd); } -static char *cxl_memdev_devnode (struct device *dev,umode_t *mode,kuid_t *uid, +static char *cxl_memdev_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) {return kasprintf (GFP_KERNEL ,"cxl/%s" ,dev_name (dev));
For the CXL bit:
Greg Kroah-Hartman
maintainerRe: [PATCH 4/5] driver core: make struct device_type.devnode() take a const *
Quoted 49 lines · Dan Williams
Quoted 31 lines · Greg Kroah-Hartman
The
devnode()callback in structdevice_typeshould 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 Jens Axboe <[email protected]>Cc Alison Schofield <[email protected]>Cc Vishal Verma <[email protected]>Cc Ira Weiny <[email protected]>Cc Ben Widawsky <[email protected]>Cc Dan Williams <[email protected]>Cc Jeremy Kerr <[email protected]>Cc Joel Stanley <[email protected]>Cc Alistar Popple <[email protected]>Cc Eddie James <[email protected]>Cc Alexander Shishkin <[email protected]>Cc Jonathan Cameron <[email protected]>Cc Jilin Yuan <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Alan Stern <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Won Chung <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>[..]
drivers/cxl/core/memdev.c static void cxl_memdev_release(struct device *dev) · line 33
Quoted 13 lines
drivers/cxl/core/memdev.c +1
-1@@ -27,7 +27,7 @@ static void cxl_memdev_release(struct device *dev)kfree (cxlmd); } -static char *cxl_memdev_devnode (struct device *dev,umode_t *mode,kuid_t *uid, +static char *cxl_memdev_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid) {return kasprintf (GFP_KERNEL ,"cxl/%s" ,dev_name (dev));For the CXL bit:
Quoted 1 line
Acked-by Dan Williams <[email protected]>
Thanks for the review!
Greg Kroah-Hartman
maintainerPATCH 5/5 driver core: device_get_devnode() should take a const *
In reply to Greg Kroah-Hartmandevice_get_devnode() should take a constant * to struct device as it does not modify it in any way, so modify the function definition to do this and move it out of device.h as it does not need to be exposed to the whole kernel tree.
--- drivers/base/base.h | 2 ++ drivers/base/core.c | 2 +- include/linux/device.h | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/base.h +2 -0
@@ -158,6 +158,8 @@ extern void device_block_probing(void);extern void device_unblock_probing (void );extern void deferred_probe_extend_timeout (void );extern void driver_deferred_probe_trigger (void ); +const char *device_get_devnode (const struct device *dev,umode_t *mode, +kuid_t *uid,kgid_t *gid,const char **tmp);/* /sys/devices directory */ extern struct kset *devices_kset;
drivers/base/core.c +1 -1
@@ -3739,7 +3739,7 @@ static struct device *next_device(struct klist_iter *i)* a name. This memory is returned in tmp and needs to be * freed by the caller. */ -const char *device_get_devnode (struct device *dev, +const char *device_get_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid,const char **tmp) {
include/linux/device.h +0 -2
@@ -927,8 +927,6 @@ int device_rename(struct device *dev, const char *new_name);int device_move (struct device *dev,struct device *new_parent,enum dpm_order dpm_order);int device_change_owner (struct device *dev,kuid_t kuid,kgid_t kgid); -const char *device_get_devnode (struct device *dev,umode_t *mode,kuid_t *uid, -kgid_t *gid,const char **tmp);int device_is_dependent (struct device *dev,void *target);static inline bool device_supports_offline (struct device *dev)
Signature · 1 line
2.38.1
Re: [PATCH 5/5] driver core: device_get_devnode() should take a const *
Quoted 6 lines · Greg Kroah-Hartman
device_get_devnode()should take a constant * to struct device as it does not modify it in any way, so modify the function definition to do this and move it out ofdevice.has it does not need to be exposed to the whole kernel tree.
Quoted 9 lines
Cc "Rafael J. Wysocki" <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Ira Weiny <[email protected]>Cc Dan Williams <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Won Chung <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 48 lines
--- drivers/base/base.h | 2 ++ drivers/base/core.c | 2 +- include/linux/device.h | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/base/base.h +2
-0@@ -158,6 +158,8 @@ extern void device_block_probing(void);extern void device_unblock_probing (void );extern void deferred_probe_extend_timeout (void );extern void driver_deferred_probe_trigger (void ); +const char *device_get_devnode (const struct device *dev,umode_t *mode, +kuid_t *uid,kgid_t *gid,const char **tmp);/* /sys/devices directory */ extern struct kset *devices_kset;drivers/base/core.c +1
-1@@ -3739,7 +3739,7 @@ static struct device *next_device(struct klist_iter *i)* a name. This memory is returned in tmp and needs to be * freed by the caller. */ -const char *device_get_devnode (struct device *dev, +const char *device_get_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid,const char **tmp) {include/linux/device.h +0
-3@@ -927,8 +927,6 @@ int device_rename(struct device *dev, const char *new_name);int device_move (struct device *dev,struct device *new_parent,enum dpm_order dpm_order);int device_change_owner (struct device *dev,kuid_t kuid,kgid_t kgid); -const char *device_get_devnode (struct device *dev,umode_t *mode,kuid_t *uid, -kgid_t *gid,const char **tmp);int device_is_dependent (struct device *dev,void *target);static inline bool device_supports_offline (struct device *dev) --2.38.1
Re: [PATCH 5/5] driver core: device_get_devnode() should take a const *
In reply to Greg Kroah-HartmanQuoted 4 lines · Greg Kroah-Hartman
device_get_devnode()should take a constant * to struct device as it does not modify it in any way, so modify the function definition to do this and move it out ofdevice.has it does not need to be exposed to the whole kernel tree.
(see one nit-pick below)
Quoted 20 lines
Cc "Rafael J. Wysocki" <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Ira Weiny <[email protected]>Cc Dan Williams <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Won Chung <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/base/base.h | 2 ++ drivers/base/core.c | 2 +- include/linux/device.h | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/base/base.h +0
-0
drivers/base/base.h extern void device_block_probing(void); · line 160
Quoted 3 lines
drivers/base/base.h +0
-0@@ -158,6 +158,8 @@ extern void device_block_probing(void);extern void device_unblock_probing (void );extern void deferred_probe_extend_timeout (void );extern void driver_deferred_probe_trigger (void );
I would put a blank line here if the below doesn't belong to the deferral probe routines.
Quoted 34 lines
drivers/base/base.h +2
-0+const char *device_get_devnode (const struct device *dev,umode_t *mode, +kuid_t *uid,kgid_t *gid,const char **tmp);/* /sys/devices directory */ extern struct kset *devices_kset;drivers/base/core.c +1
-1@@ -3739,7 +3739,7 @@ static struct device *next_device(struct klist_iter *i)* a name. This memory is returned in tmp and needs to be * freed by the caller. */ -const char *device_get_devnode (struct device *dev, +const char *device_get_devnode (const struct device *dev,umode_t *mode,kuid_t *uid,kgid_t *gid,const char **tmp) {include/linux/device.h +0
-2@@ -927,8 +927,6 @@ int device_rename(struct device *dev, const char *new_name);int device_move (struct device *dev,struct device *new_parent,enum dpm_order dpm_order);int device_change_owner (struct device *dev,kuid_t kuid,kgid_t kgid); -const char *device_get_devnode (struct device *dev,umode_t *mode,kuid_t *uid, -kgid_t *gid,const char **tmp);int device_is_dependent (struct device *dev,void *target);static inline bool device_supports_offline (struct device *dev)Signature · 1 line
2.38.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Greg Kroah-Hartman
maintainerRe: [PATCH 5/5] driver core: device_get_devnode() should take a const *
Quoted 25 lines · Andy Shevchenko
Quoted 4 lines · Greg Kroah-Hartman
device_get_devnode()should take a constant * to struct device as it does not modify it in any way, so modify the function definition to do this and move it out ofdevice.has it does not need to be exposed to the whole kernel tree.Reviewed-by Andy Shevchenko <[email protected]>(see one nit-pick below)
Quoted 15 lines
Cc "Rafael J. Wysocki" <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Ira Weiny <[email protected]>Cc Dan Williams <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Won Chung <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/base/base.h | 2 ++ drivers/base/core.c | 2 +- include/linux/device.h | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-)
Quoted 11 lines
drivers/base/base.h extern void device_block_probing(void); · line 160
Quoted 8 lines
drivers/base/base.h +0
-0@@ -158,6 +158,8 @@ extern void device_block_probing(void);extern void device_unblock_probing (void );extern void deferred_probe_extend_timeout (void );extern void driver_deferred_probe_trigger (void );I would put a blank line here if the below doesn't belong to the deferral probe routines.
This whole .h file needs to be cleaned up and made nicer (the externs show it's age), so I'll just leave this as-is and when all of the rework is done reorginize it.
thanks for the review!
greg k-h
Quoted 41 lines · Greg Kroah-Hartman
The
dev_uevent()in struct class 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 Jens Axboe <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Russ Weight <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Jean Delvare <[email protected]>Cc Johan Hovold <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Leon Romanovsky <[email protected]>Cc Karsten Keil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Keith Busch <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Sagi Grimberg <[email protected]>Cc Dominik Brodowski <[email protected]>Cc Sebastian Reichel <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Johannes Berg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Raed Salem <[email protected]>Cc Chen Zhongjin <[email protected]>Cc Tetsuo Handa <[email protected]>Cc Avihai Horon <[email protected]>Cc "Matthew Wilcox (Oracle)" <[email protected]>Cc Alan Stern <[email protected]>Cc Colin Ian King <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jakob Koschel <[email protected]>Cc Antoine Tenart <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Wang Yufen <[email protected]>
Quoted 8 lines
Quoted 328 lines
--- block/genhd.c | 4 ++-- drivers/base/firmware_loader/sysfs.c | 6 +++--- drivers/base/firmware_loader/sysfs.h | 2 +- drivers/firmware/dmi-id.c | 2 +- drivers/gnss/core.c | 6 +++--- drivers/infiniband/core/device.c | 2 +- drivers/isdn/mISDN/core.c | 4 ++-- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/nvme/host/core.c | 4 ++-- drivers/pcmcia/cs.c | 4 ++-- drivers/power/supply/power_supply.h | 2 +- drivers/power/supply/power_supply_sysfs.c | 8 ++++---- drivers/usb/gadget/udc/core.c | 4 ++-- include/linux/device/class.h | 2 +- include/linux/mISDNif.h | 2 +- net/atm/atm_sysfs.c | 4 ++-- net/core/net-sysfs.c | 4 ++-- net/rfkill/core.c | 2 +- 18 files changed, 33 insertions(+), 33 deletions(-)block/genhd.c +2
-2@@ -1181,9 +1181,9 @@ static void disk_release(struct device *dev)iput (disk->part0->bd_inode);/* frees the disk */ } -static int block_uevent (struct device *dev,struct kobj_uevent_env *env) +static int block_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gendisk *disk =dev_to_disk (dev); +const struct gendisk *disk =dev_to_disk (dev);return add_uevent_var (env,"DISKSEQ=%llu" , disk->diskseq); }drivers/base/firmware_loader/sysfs.c +3
-3@@ -64,7 +64,7 @@ static struct attribute *firmware_class_attrs[] = { };ATTRIBUTE_GROUPS (firmware_class); -static int do_firmware_uevent (struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) +static int do_firmware_uevent (const struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) {if (add_uevent_var (env,"FIRMWARE=%s" , fw_sysfs->fw_priv->fw_name))return -ENOMEM ;@@ -76,9 +76,9 @@ static int do_firmware_uevent(struct fw_sysfs *fw_sysfs, struct kobj_uevent_envreturn 0 ; } -static int firmware_uevent (struct device *dev,struct kobj_uevent_env *env) +static int firmware_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev); +const struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev);int err =0 ;mutex_lock (&fw_lock);drivers/base/firmware_loader/sysfs.h +1
-1@@ -81,7 +81,7 @@ struct fw_sysfs {void *fw_upload_priv; }; -static inline struct fw_sysfs *to_fw_sysfs (struct device *dev) +static inline struct fw_sysfs *to_fw_sysfs (const struct device *dev) { return container_of(dev, struct fw_sysfs, dev); }drivers/firmware/dmi-id.c +1
-1@@ -155,7 +155,7 @@ static const struct attribute_group* sys_dmi_attribute_groups[] = { NULL }; -static int dmi_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dmi_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {ssize_t len;drivers/gnss/core.c +3
-3@@ -337,7 +337,7 @@ static const char * const gnss_type_names[GNSS_TYPE_COUNT] = { [GNSS_TYPE_MTK] = "MTK", }; -static const char *gnss_type_name (struct gnss_device *gdev) +static const char *gnss_type_name (const struct gnss_device *gdev) {const char *name =NULL ;@@ -365,9 +365,9 @@ static struct attribute *gnss_attrs[] = { };ATTRIBUTE_GROUPS (gnss); -static int gnss_uevent (struct device *dev,struct kobj_uevent_env *env) +static int gnss_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gnss_device *gdev =to_gnss_device (dev); +const struct gnss_device *gdev =to_gnss_device (dev);int ret; ret =add_uevent_var (env,"GNSS_TYPE=%s" ,gnss_type_name (gdev));drivers/infiniband/core/device.c +1
-1@@ -511,7 +511,7 @@ static void ib_device_release(struct device *device)kfree_rcu (dev, rcu_head); } -static int ib_device_uevent (struct device *device, +static int ib_device_uevent (const struct device *device,struct kobj_uevent_env *env) {if (add_uevent_var (env,"NAME=%s" ,dev_name (device)))drivers/isdn/mISDN/core.c +2
-2@@ -139,9 +139,9 @@ static struct attribute *mISDN_attrs[] = { };ATTRIBUTE_GROUPS (mISDN); -static int mISDN_uevent (struct device *dev,struct kobj_uevent_env *env) +static int mISDN_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct mISDNdevice *mdev =dev_to_mISDN (dev); +const struct mISDNdevice *mdev =dev_to_mISDN (dev);if (!mdev)return 0 ;drivers/media/dvb-core/dvbdev.c +2
-2@@ -1008,9 +1008,9 @@ void dvb_module_release(struct i2c_client *client)EXPORT_SYMBOL_GPL (dvb_module_release);#endif -static int dvb_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dvb_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);add_uevent_var (env,"DVB_ADAPTER_NUM=%d" , dvbdev->adapter->num);add_uevent_var (env,"DVB_DEVICE_TYPE=%s" , dnames[dvbdev->type]);drivers/nvme/host/core.c +2
-2@@ -4580,9 +4580,9 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_remove_namespaces); -static int nvme_class_uevent (struct device *dev,struct kobj_uevent_env *env) +static int nvme_class_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct nvme_ctrl *ctrl = +const struct nvme_ctrl *ctrl = container_of(dev, struct nvme_ctrl, ctrl_device);struct nvmf_ctrl_options *opts = ctrl->opts;int ret;drivers/pcmcia/cs.c +2
-2@@ -810,10 +810,10 @@ int pcmcia_reset_card(struct pcmcia_socket *skt)EXPORT_SYMBOL (pcmcia_reset_card); -static int pcmcia_socket_uevent (struct device *dev, +static int pcmcia_socket_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); + const struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);if (add_uevent_var (env,"SOCKET_NO=%u" , s->sock))return -ENOMEM ;drivers/power/supply/power_supply.h +1
-1@@ -16,7 +16,7 @@ struct power_supply;#ifdef CONFIG_SYSFS extern void power_supply_init_attrs (struct device_type *dev_type); -extern int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env); +extern int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env);#else drivers/power/supply/power_supply_sysfs.c +4
-4@@ -427,7 +427,7 @@ void power_supply_init_attrs(struct device_type *dev_type) } } -static int add_prop_uevent (struct device *dev,struct kobj_uevent_env *env, +static int add_prop_uevent (const struct device *dev,struct kobj_uevent_env *env,enum power_supply_property prop,char *prop_buf) {int ret =0 ;@@ -438,7 +438,7 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr = &power_supply_attrs[prop]; dev_attr = &pwr_attr->dev_attr; - ret =power_supply_show_property (dev, dev_attr, prop_buf); + ret =power_supply_show_property ((struct device *)dev, dev_attr, prop_buf);if (ret == -ENODEV || ret == -ENODATA ) {/* * When a battery is absent, we expect -ENODEV. Don't abort; @@ -458,9 +458,9 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr->prop_name, prop_buf); } -int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env) +int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct power_supply *psy =dev_get_drvdata (dev); +const struct power_supply *psy =dev_get_drvdata (dev);int ret =0 , j;char *prop_buf;drivers/usb/gadget/udc/core.c +2
-2@@ -1723,9 +1723,9 @@ static const struct attribute_group *usb_udc_attr_groups[] = { NULL, }; -static int usb_udc_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_udc_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); + const struct usb_udc *udc = container_of(dev, struct usb_udc, dev);int ret; ret =add_uevent_var (env,"USB_UDC_NAME=%s" , udc->gadget->name);include/linux/device/class.h +1
-1@@ -59,7 +59,7 @@ struct class {const struct attribute_group **dev_groups;struct kobject *dev_kobj; -int (*dev_uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode);void (*class_release)(struct class *class);include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);net/atm/atm_sysfs.c +2
-2@@ -108,9 +108,9 @@ static struct device_attribute *atm_attrs[] = { }; -static int atm_uevent (struct device *cdev,struct kobj_uevent_env *env) +static int atm_uevent (const struct device *cdev,struct kobj_uevent_env *env) { -struct atm_dev *adev; +const struct atm_dev *adev;if (!cdev)return -ENODEV ;net/core/net-sysfs.c +2
-2@@ -1873,9 +1873,9 @@ const struct kobj_ns_type_operations net_ns_type_operations = { };EXPORT_SYMBOL_GPL (net_ns_type_operations); -static int netdev_uevent (struct device *d,struct kobj_uevent_env *env) +static int netdev_uevent (const struct device *d,struct kobj_uevent_env *env) { -struct net_device *dev =to_net_dev (d); +const struct net_device *dev =to_net_dev (d);int retval;/* pass interface to uevent. */ net/rfkill/core.c +1
-2@@ -832,7 +832,7 @@ static void rfkill_release(struct device *dev)kfree (rfkill); } -static int rfkill_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int rfkill_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {struct rfkill *rfkill =to_rfkill (dev);unsigned long flags; --2.38.1
Hi,
Quoted 48 lines · Greg Kroah-Hartman
The
dev_uevent()in struct class 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 Jens Axboe <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Russ Weight <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Jean Delvare <[email protected]>Cc Johan Hovold <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Leon Romanovsky <[email protected]>Cc Karsten Keil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Keith Busch <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Sagi Grimberg <[email protected]>Cc Dominik Brodowski <[email protected]>Cc Sebastian Reichel <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Johannes Berg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Raed Salem <[email protected]>Cc Chen Zhongjin <[email protected]>Cc Tetsuo Handa <[email protected]>Cc Avihai Horon <[email protected]>Cc "Matthew Wilcox (Oracle)" <[email protected]>Cc Alan Stern <[email protected]>Cc Colin Ian King <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jakob Koschel <[email protected]>Cc Antoine Tenart <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Wang Yufen <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 1 line
---
-- Sebastian
Quoted 327 lines
block/genhd.c | 4 ++-- drivers/base/firmware_loader/sysfs.c | 6 +++--- drivers/base/firmware_loader/sysfs.h | 2 +- drivers/firmware/dmi-id.c | 2 +- drivers/gnss/core.c | 6 +++--- drivers/infiniband/core/device.c | 2 +- drivers/isdn/mISDN/core.c | 4 ++-- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/nvme/host/core.c | 4 ++-- drivers/pcmcia/cs.c | 4 ++-- drivers/power/supply/power_supply.h | 2 +- drivers/power/supply/power_supply_sysfs.c | 8 ++++---- drivers/usb/gadget/udc/core.c | 4 ++-- include/linux/device/class.h | 2 +- include/linux/mISDNif.h | 2 +- net/atm/atm_sysfs.c | 4 ++-- net/core/net-sysfs.c | 4 ++-- net/rfkill/core.c | 2 +- 18 files changed, 33 insertions(+), 33 deletions(-)block/genhd.c +2
-2@@ -1181,9 +1181,9 @@ static void disk_release(struct device *dev)iput (disk->part0->bd_inode);/* frees the disk */ } -static int block_uevent (struct device *dev,struct kobj_uevent_env *env) +static int block_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gendisk *disk =dev_to_disk (dev); +const struct gendisk *disk =dev_to_disk (dev);return add_uevent_var (env,"DISKSEQ=%llu" , disk->diskseq); }drivers/base/firmware_loader/sysfs.c +3
-3@@ -64,7 +64,7 @@ static struct attribute *firmware_class_attrs[] = { };ATTRIBUTE_GROUPS (firmware_class); -static int do_firmware_uevent (struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) +static int do_firmware_uevent (const struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) {if (add_uevent_var (env,"FIRMWARE=%s" , fw_sysfs->fw_priv->fw_name))return -ENOMEM ;@@ -76,9 +76,9 @@ static int do_firmware_uevent(struct fw_sysfs *fw_sysfs, struct kobj_uevent_envreturn 0 ; } -static int firmware_uevent (struct device *dev,struct kobj_uevent_env *env) +static int firmware_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev); +const struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev);int err =0 ;mutex_lock (&fw_lock);drivers/base/firmware_loader/sysfs.h +1
-1@@ -81,7 +81,7 @@ struct fw_sysfs {void *fw_upload_priv; }; -static inline struct fw_sysfs *to_fw_sysfs (struct device *dev) +static inline struct fw_sysfs *to_fw_sysfs (const struct device *dev) { return container_of(dev, struct fw_sysfs, dev); }drivers/firmware/dmi-id.c +1
-1@@ -155,7 +155,7 @@ static const struct attribute_group* sys_dmi_attribute_groups[] = { NULL }; -static int dmi_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dmi_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {ssize_t len;drivers/gnss/core.c +3
-3@@ -337,7 +337,7 @@ static const char * const gnss_type_names[GNSS_TYPE_COUNT] = { [GNSS_TYPE_MTK] = "MTK", }; -static const char *gnss_type_name (struct gnss_device *gdev) +static const char *gnss_type_name (const struct gnss_device *gdev) {const char *name =NULL ;@@ -365,9 +365,9 @@ static struct attribute *gnss_attrs[] = { };ATTRIBUTE_GROUPS (gnss); -static int gnss_uevent (struct device *dev,struct kobj_uevent_env *env) +static int gnss_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gnss_device *gdev =to_gnss_device (dev); +const struct gnss_device *gdev =to_gnss_device (dev);int ret; ret =add_uevent_var (env,"GNSS_TYPE=%s" ,gnss_type_name (gdev));drivers/infiniband/core/device.c +1
-1@@ -511,7 +511,7 @@ static void ib_device_release(struct device *device)kfree_rcu (dev, rcu_head); } -static int ib_device_uevent (struct device *device, +static int ib_device_uevent (const struct device *device,struct kobj_uevent_env *env) {if (add_uevent_var (env,"NAME=%s" ,dev_name (device)))drivers/isdn/mISDN/core.c +2
-2@@ -139,9 +139,9 @@ static struct attribute *mISDN_attrs[] = { };ATTRIBUTE_GROUPS (mISDN); -static int mISDN_uevent (struct device *dev,struct kobj_uevent_env *env) +static int mISDN_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct mISDNdevice *mdev =dev_to_mISDN (dev); +const struct mISDNdevice *mdev =dev_to_mISDN (dev);if (!mdev)return 0 ;drivers/media/dvb-core/dvbdev.c +2
-2@@ -1008,9 +1008,9 @@ void dvb_module_release(struct i2c_client *client)EXPORT_SYMBOL_GPL (dvb_module_release);#endif -static int dvb_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dvb_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);add_uevent_var (env,"DVB_ADAPTER_NUM=%d" , dvbdev->adapter->num);add_uevent_var (env,"DVB_DEVICE_TYPE=%s" , dnames[dvbdev->type]);drivers/nvme/host/core.c +2
-2@@ -4580,9 +4580,9 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_remove_namespaces); -static int nvme_class_uevent (struct device *dev,struct kobj_uevent_env *env) +static int nvme_class_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct nvme_ctrl *ctrl = +const struct nvme_ctrl *ctrl = container_of(dev, struct nvme_ctrl, ctrl_device);struct nvmf_ctrl_options *opts = ctrl->opts;int ret;drivers/pcmcia/cs.c +2
-2@@ -810,10 +810,10 @@ int pcmcia_reset_card(struct pcmcia_socket *skt)EXPORT_SYMBOL (pcmcia_reset_card); -static int pcmcia_socket_uevent (struct device *dev, +static int pcmcia_socket_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); + const struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);if (add_uevent_var (env,"SOCKET_NO=%u" , s->sock))return -ENOMEM ;drivers/power/supply/power_supply.h +1
-1@@ -16,7 +16,7 @@ struct power_supply;#ifdef CONFIG_SYSFS extern void power_supply_init_attrs (struct device_type *dev_type); -extern int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env); +extern int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env);#else drivers/power/supply/power_supply_sysfs.c +4
-4@@ -427,7 +427,7 @@ void power_supply_init_attrs(struct device_type *dev_type) } } -static int add_prop_uevent (struct device *dev,struct kobj_uevent_env *env, +static int add_prop_uevent (const struct device *dev,struct kobj_uevent_env *env,enum power_supply_property prop,char *prop_buf) {int ret =0 ;@@ -438,7 +438,7 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr = &power_supply_attrs[prop]; dev_attr = &pwr_attr->dev_attr; - ret =power_supply_show_property (dev, dev_attr, prop_buf); + ret =power_supply_show_property ((struct device *)dev, dev_attr, prop_buf);if (ret == -ENODEV || ret == -ENODATA ) {/* * When a battery is absent, we expect -ENODEV. Don't abort; @@ -458,9 +458,9 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr->prop_name, prop_buf); } -int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env) +int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct power_supply *psy =dev_get_drvdata (dev); +const struct power_supply *psy =dev_get_drvdata (dev);int ret =0 , j;char *prop_buf;drivers/usb/gadget/udc/core.c +2
-2@@ -1723,9 +1723,9 @@ static const struct attribute_group *usb_udc_attr_groups[] = { NULL, }; -static int usb_udc_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_udc_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); + const struct usb_udc *udc = container_of(dev, struct usb_udc, dev);int ret; ret =add_uevent_var (env,"USB_UDC_NAME=%s" , udc->gadget->name);include/linux/device/class.h +1
-1@@ -59,7 +59,7 @@ struct class {const struct attribute_group **dev_groups;struct kobject *dev_kobj; -int (*dev_uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode);void (*class_release)(struct class *class);include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);net/atm/atm_sysfs.c +2
-2@@ -108,9 +108,9 @@ static struct device_attribute *atm_attrs[] = { }; -static int atm_uevent (struct device *cdev,struct kobj_uevent_env *env) +static int atm_uevent (const struct device *cdev,struct kobj_uevent_env *env) { -struct atm_dev *adev; +const struct atm_dev *adev;if (!cdev)return -ENODEV ;net/core/net-sysfs.c +2
-2@@ -1873,9 +1873,9 @@ const struct kobj_ns_type_operations net_ns_type_operations = { };EXPORT_SYMBOL_GPL (net_ns_type_operations); -static int netdev_uevent (struct device *d,struct kobj_uevent_env *env) +static int netdev_uevent (const struct device *d,struct kobj_uevent_env *env) { -struct net_device *dev =to_net_dev (d); +const struct net_device *dev =to_net_dev (d);int retval;/* pass interface to uevent. */ net/rfkill/core.c +1
-1@@ -832,7 +832,7 @@ static void rfkill_release(struct device *dev)kfree (rfkill); } -static int rfkill_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int rfkill_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {struct rfkill *rfkill =to_rfkill (dev);unsigned long flags;Signature · 1 line
2.38.1
Em Wed, 23 Nov 2022 13:25:19 +0100
Greg Kroah-Hartman <[email protected]> escreveu:
Quoted 4 lines
The
dev_uevent()in struct class 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.
Quoted 369 lines
Cc Jens Axboe <[email protected]>Cc Luis Chamberlain <[email protected]>Cc Russ Weight <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Jean Delvare <[email protected]>Cc Johan Hovold <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Leon Romanovsky <[email protected]>Cc Karsten Keil <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Keith Busch <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Sagi Grimberg <[email protected]>Cc Dominik Brodowski <[email protected]>Cc Sebastian Reichel <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Johannes Berg <[email protected]>Cc Wolfram Sang <[email protected]>Cc Raed Salem <[email protected]>Cc Chen Zhongjin <[email protected]>Cc Tetsuo Handa <[email protected]>Cc Avihai Horon <[email protected]>Cc "Matthew Wilcox (Oracle)" <[email protected]>Cc Alan Stern <[email protected]>Cc Colin Ian King <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jakob Koschel <[email protected]>Cc Antoine Tenart <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Wang Yufen <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- block/genhd.c | 4 ++-- drivers/base/firmware_loader/sysfs.c | 6 +++--- drivers/base/firmware_loader/sysfs.h | 2 +- drivers/firmware/dmi-id.c | 2 +- drivers/gnss/core.c | 6 +++--- drivers/infiniband/core/device.c | 2 +- drivers/isdn/mISDN/core.c | 4 ++-- drivers/media/dvb-core/dvbdev.c | 4 ++-- drivers/nvme/host/core.c | 4 ++-- drivers/pcmcia/cs.c | 4 ++-- drivers/power/supply/power_supply.h | 2 +- drivers/power/supply/power_supply_sysfs.c | 8 ++++---- drivers/usb/gadget/udc/core.c | 4 ++-- include/linux/device/class.h | 2 +- include/linux/mISDNif.h | 2 +- net/atm/atm_sysfs.c | 4 ++-- net/core/net-sysfs.c | 4 ++-- net/rfkill/core.c | 2 +- 18 files changed, 33 insertions(+), 33 deletions(-)block/genhd.c +2
-2@@ -1181,9 +1181,9 @@ static void disk_release(struct device *dev)iput (disk->part0->bd_inode);/* frees the disk */ } -static int block_uevent (struct device *dev,struct kobj_uevent_env *env) +static int block_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gendisk *disk =dev_to_disk (dev); +const struct gendisk *disk =dev_to_disk (dev);return add_uevent_var (env,"DISKSEQ=%llu" , disk->diskseq); }drivers/base/firmware_loader/sysfs.c +3
-3@@ -64,7 +64,7 @@ static struct attribute *firmware_class_attrs[] = { };ATTRIBUTE_GROUPS (firmware_class); -static int do_firmware_uevent (struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) +static int do_firmware_uevent (const struct fw_sysfs *fw_sysfs,struct kobj_uevent_env *env) {if (add_uevent_var (env,"FIRMWARE=%s" , fw_sysfs->fw_priv->fw_name))return -ENOMEM ;@@ -76,9 +76,9 @@ static int do_firmware_uevent(struct fw_sysfs *fw_sysfs, struct kobj_uevent_envreturn 0 ; } -static int firmware_uevent (struct device *dev,struct kobj_uevent_env *env) +static int firmware_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev); +const struct fw_sysfs *fw_sysfs =to_fw_sysfs (dev);int err =0 ;mutex_lock (&fw_lock);drivers/base/firmware_loader/sysfs.h +1
-1@@ -81,7 +81,7 @@ struct fw_sysfs {void *fw_upload_priv; }; -static inline struct fw_sysfs *to_fw_sysfs (struct device *dev) +static inline struct fw_sysfs *to_fw_sysfs (const struct device *dev) { return container_of(dev, struct fw_sysfs, dev); }drivers/firmware/dmi-id.c +1
-1@@ -155,7 +155,7 @@ static const struct attribute_group* sys_dmi_attribute_groups[] = { NULL }; -static int dmi_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dmi_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {ssize_t len;drivers/gnss/core.c +3
-3@@ -337,7 +337,7 @@ static const char * const gnss_type_names[GNSS_TYPE_COUNT] = { [GNSS_TYPE_MTK] = "MTK", }; -static const char *gnss_type_name (struct gnss_device *gdev) +static const char *gnss_type_name (const struct gnss_device *gdev) {const char *name =NULL ;@@ -365,9 +365,9 @@ static struct attribute *gnss_attrs[] = { };ATTRIBUTE_GROUPS (gnss); -static int gnss_uevent (struct device *dev,struct kobj_uevent_env *env) +static int gnss_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct gnss_device *gdev =to_gnss_device (dev); +const struct gnss_device *gdev =to_gnss_device (dev);int ret; ret =add_uevent_var (env,"GNSS_TYPE=%s" ,gnss_type_name (gdev));drivers/infiniband/core/device.c +1
-1@@ -511,7 +511,7 @@ static void ib_device_release(struct device *device)kfree_rcu (dev, rcu_head); } -static int ib_device_uevent (struct device *device, +static int ib_device_uevent (const struct device *device,struct kobj_uevent_env *env) {if (add_uevent_var (env,"NAME=%s" ,dev_name (device)))drivers/isdn/mISDN/core.c +2
-2@@ -139,9 +139,9 @@ static struct attribute *mISDN_attrs[] = { };ATTRIBUTE_GROUPS (mISDN); -static int mISDN_uevent (struct device *dev,struct kobj_uevent_env *env) +static int mISDN_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct mISDNdevice *mdev =dev_to_mISDN (dev); +const struct mISDNdevice *mdev =dev_to_mISDN (dev);if (!mdev)return 0 ;drivers/media/dvb-core/dvbdev.c +2
-2@@ -1008,9 +1008,9 @@ void dvb_module_release(struct i2c_client *client)EXPORT_SYMBOL_GPL (dvb_module_release);#endif -static int dvb_uevent (struct device *dev,struct kobj_uevent_env *env) +static int dvb_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct dvb_device *dvbdev =dev_get_drvdata (dev); +const struct dvb_device *dvbdev =dev_get_drvdata (dev);add_uevent_var (env,"DVB_ADAPTER_NUM=%d" , dvbdev->adapter->num);add_uevent_var (env,"DVB_DEVICE_TYPE=%s" , dnames[dvbdev->type]);drivers/nvme/host/core.c +2
-2@@ -4580,9 +4580,9 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_remove_namespaces); -static int nvme_class_uevent (struct device *dev,struct kobj_uevent_env *env) +static int nvme_class_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct nvme_ctrl *ctrl = +const struct nvme_ctrl *ctrl = container_of(dev, struct nvme_ctrl, ctrl_device);struct nvmf_ctrl_options *opts = ctrl->opts;int ret;drivers/pcmcia/cs.c +2
-2@@ -810,10 +810,10 @@ int pcmcia_reset_card(struct pcmcia_socket *skt)EXPORT_SYMBOL (pcmcia_reset_card); -static int pcmcia_socket_uevent (struct device *dev, +static int pcmcia_socket_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); + const struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);if (add_uevent_var (env,"SOCKET_NO=%u" , s->sock))return -ENOMEM ;drivers/power/supply/power_supply.h +1
-1@@ -16,7 +16,7 @@ struct power_supply;#ifdef CONFIG_SYSFS extern void power_supply_init_attrs (struct device_type *dev_type); -extern int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env); +extern int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env);#else drivers/power/supply/power_supply_sysfs.c +4
-4@@ -427,7 +427,7 @@ void power_supply_init_attrs(struct device_type *dev_type) } } -static int add_prop_uevent (struct device *dev,struct kobj_uevent_env *env, +static int add_prop_uevent (const struct device *dev,struct kobj_uevent_env *env,enum power_supply_property prop,char *prop_buf) {int ret =0 ;@@ -438,7 +438,7 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr = &power_supply_attrs[prop]; dev_attr = &pwr_attr->dev_attr; - ret =power_supply_show_property (dev, dev_attr, prop_buf); + ret =power_supply_show_property ((struct device *)dev, dev_attr, prop_buf);if (ret == -ENODEV || ret == -ENODATA ) {/* * When a battery is absent, we expect -ENODEV. Don't abort; @@ -458,9 +458,9 @@ static int add_prop_uevent(struct device *dev, struct kobj_uevent_env *env, pwr_attr->prop_name, prop_buf); } -int power_supply_uevent (struct device *dev,struct kobj_uevent_env *env) +int power_supply_uevent (const struct device *dev,struct kobj_uevent_env *env) { -struct power_supply *psy =dev_get_drvdata (dev); +const struct power_supply *psy =dev_get_drvdata (dev);int ret =0 , j;char *prop_buf;drivers/usb/gadget/udc/core.c +2
-2@@ -1723,9 +1723,9 @@ static const struct attribute_group *usb_udc_attr_groups[] = { NULL, }; -static int usb_udc_uevent (struct device *dev,struct kobj_uevent_env *env) +static int usb_udc_uevent (const struct device *dev,struct kobj_uevent_env *env) { - struct usb_udc *udc = container_of(dev, struct usb_udc, dev); + const struct usb_udc *udc = container_of(dev, struct usb_udc, dev);int ret; ret =add_uevent_var (env,"USB_UDC_NAME=%s" , udc->gadget->name);include/linux/device/class.h +1
-1@@ -59,7 +59,7 @@ struct class {const struct attribute_group **dev_groups;struct kobject *dev_kobj; -int (*dev_uevent)(struct device *dev,struct kobj_uevent_env *env); +int (*dev_uevent)(const struct device *dev,struct kobj_uevent_env *env);char *(*devnode)(struct device *dev,umode_t *mode);void (*class_release)(struct class *class);include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);net/atm/atm_sysfs.c +2
-2@@ -108,9 +108,9 @@ static struct device_attribute *atm_attrs[] = { }; -static int atm_uevent (struct device *cdev,struct kobj_uevent_env *env) +static int atm_uevent (const struct device *cdev,struct kobj_uevent_env *env) { -struct atm_dev *adev; +const struct atm_dev *adev;if (!cdev)return -ENODEV ;net/core/net-sysfs.c +2
-2@@ -1873,9 +1873,9 @@ const struct kobj_ns_type_operations net_ns_type_operations = { };EXPORT_SYMBOL_GPL (net_ns_type_operations); -static int netdev_uevent (struct device *d,struct kobj_uevent_env *env) +static int netdev_uevent (const struct device *d,struct kobj_uevent_env *env) { -struct net_device *dev =to_net_dev (d); +const struct net_device *dev =to_net_dev (d);int retval;/* pass interface to uevent. */ net/rfkill/core.c +1
-1@@ -832,7 +832,7 @@ static void rfkill_release(struct device *dev)kfree (rfkill); } -static int rfkill_dev_uevent (struct device *dev,struct kobj_uevent_env *env) +static int rfkill_dev_uevent (const struct device *dev,struct kobj_uevent_env *env) {struct rfkill *rfkill =to_rfkill (dev);unsigned long flags;
include/linux/mISDNif.h extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, · line 592
Quoted 13 lines · Greg Kroah-Hartman
include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);
Why does the dev_to_mISDN() function drop constness? I haven't found an explanation for this in the cover letter.
Thanks,
Bart.
Greg Kroah-Hartman
maintainerQuoted 16 lines · Bart Van Assche
include/linux/mISDNif.h extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, · line 591
Quoted 12 lines · Greg Kroah-Hartman
include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);Why does the
dev_to_mISDN()function drop constness? I haven't found an explanation for this in the cover letter.
I agree, this is going to be fixed up, see the thread starting here:
https://lore.kernel.org/r/[email protected]
I'll work on making a const / non const version for these so that we don't loose the marking.
Oh wait, no, this function is fine, it's not modifying the device structure at all, and only returning the pointer in the private data stored in the device. There is no loss of const-ness here.
thanks,
greg k-h
Quoted 21 lines · Greg Kroah-Hartman
Quoted 16 lines · Bart Van Assche
include/linux/mISDNif.h extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, · line 591
Quoted 12 lines · Greg Kroah-Hartman
include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);Why does the
dev_to_mISDN()function drop constness? I haven't found an explanation for this in the cover letter.I agree, this is going to be fixed up, see the thread starting here:
https://lore.kernel.org/r/[email protected]
Quoted 6 lines
I'll work on making a const / non const version for these so that we don't loose the marking.
Oh wait, no, this function is fine, it's not modifying the device structure at all, and only returning the pointer in the private data stored in the device. There is no loss of const-ness here.
Hi Greg,
This is what I found in include/linux/mISDNif.h:
struct mISDNdevice {
struct mISDNchannel D;
u_int id;
u_int Dprotocols;
u_int Bprotocols;
u_int nrbchan;
u_char channelmap[MISDN_CHMAP_SIZE];
struct list_head bchannels;
struct mISDNchannel *teimgr;
struct device dev;
};As one can see 'dev' is a member of struct mISDNdevice. I still think that dev_to_mISDN() drops constness. Did I perhaps overlook something?
Bart.
Greg Kroah-Hartman
maintainerQuoted 45 lines · Bart Van Assche
Quoted 21 lines · Greg Kroah-Hartman
Quoted 16 lines · Bart Van Assche
include/linux/mISDNif.h extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, · line 591
Quoted 12 lines · Greg Kroah-Hartman
include/linux/mISDNif.h +1
-1@@ -586,7 +586,7 @@ extern struct mISDNclock *mISDN_register_clock(char *, int, clockctl_func_t *, void *);extern void mISDN_unregister_clock (struct mISDNclock *); -static inline struct mISDNdevice *dev_to_mISDN (struct device *dev) +static inline struct mISDNdevice *dev_to_mISDN (const struct device *dev) {if (dev)return dev_get_drvdata (dev);Why does the
dev_to_mISDN()function drop constness? I haven't found an explanation for this in the cover letter.I agree, this is going to be fixed up, see the thread starting here:
https://lore.kernel.org/r/[email protected]Quoted 6 lines
I'll work on making a const / non const version for these so that we don't loose the marking.
Oh wait, no, this function is fine, it's not modifying the device structure at all, and only returning the pointer in the private data stored in the device. There is no loss of const-ness here.
Hi Greg,
This is what I found in
include/linux/mISDNif.h:struct mISDNdevice { struct mISDNchannel D; u_int id; u_int Dprotocols; u_int Bprotocols; u_int nrbchan; u_char channelmap[MISDN_CHMAP_SIZE]; struct list_head bchannels; struct mISDNchannel *teimgr; struct device dev; };
Quoted 2 lines
As one can see 'dev' is a member of struct mISDNdevice. I still think that
dev_to_mISDN()drops constness. Did I perhaps overlook something?
I think you are missing that dev_to_mISDN() is doing something different than most dev_to_FOO() functions do (i.e. there is no container_of() call here at all):
static inline struct mISDNdevice *dev_to_mISDN(struct device *dev)
{
if (dev)
return dev_get_drvdata(dev);
else
return NULL;
}See, no pointer mess or anything else here, all that happens is the driver data pointer in struct device is returned.
If this was a "normal" dev_to_FOO() function, then yes, the const-ness of the pointer would be called into question as the thread I linked to discusses.
thanks,
greg k-h