Commit ff62b8e6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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.

Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Justin Sanders <justin@coraid.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Cc: Liam Mark <lmark@codeaurora.org>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Brian Starkey <Brian.Starkey@arm.com>
Cc: John Stultz <jstultz@google.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sean Young <sean@mess.org>
Cc: Frank Haverkamp <haver@linux.ibm.com>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Xie Yongji <xieyongji@bytedance.com>
Cc: Gautam Dawar <gautam.dawar@xilinx.com>
Cc: Dan Carpenter <error27@gmail.com>
Cc: Eli Cohen <elic@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: alsa-devel@alsa-project.org
Cc: dri-devel@lists.freedesktop.org
Cc: kvm@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Cc: linux-block@vger.kernel.org
Cc: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Link: https://lore.kernel.org/r/20221123122523.1332370-2-gregkh@linuxfoundation.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 23680f0b
...@@ -1560,9 +1560,9 @@ static const struct file_operations pseudo_lock_dev_fops = { ...@@ -1560,9 +1560,9 @@ static const struct file_operations pseudo_lock_dev_fops = {
.mmap = pseudo_lock_dev_mmap, .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); rdtgrp = dev_get_drvdata(dev);
if (mode) if (mode)
......
...@@ -139,7 +139,7 @@ static int cpuid_device_destroy(unsigned int cpu) ...@@ -139,7 +139,7 @@ static int cpuid_device_destroy(unsigned int cpu)
return 0; 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)); return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt));
} }
......
...@@ -250,7 +250,7 @@ static int msr_device_destroy(unsigned int cpu) ...@@ -250,7 +250,7 @@ static int msr_device_destroy(unsigned int cpu)
return 0; 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)); return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt));
} }
......
...@@ -232,7 +232,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q, ...@@ -232,7 +232,7 @@ struct bsg_device *bsg_register_queue(struct request_queue *q,
} }
EXPORT_SYMBOL_GPL(bsg_register_queue); 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)); return kasprintf(GFP_KERNEL, "bsg/%s", dev_name(dev));
} }
......
...@@ -273,7 +273,7 @@ static const struct file_operations aoe_fops = { ...@@ -273,7 +273,7 @@ static const struct file_operations aoe_fops = {
.llseek = noop_llseek, .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)); return kasprintf(GFP_KERNEL, "etherd/%s", dev_name(dev));
} }
......
...@@ -746,7 +746,7 @@ static const struct file_operations memory_fops = { ...@@ -746,7 +746,7 @@ static const struct file_operations memory_fops = {
.llseek = noop_llseek, .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) if (mode && devlist[MINOR(dev->devt)].mode)
*mode = devlist[MINOR(dev->devt)].mode; *mode = devlist[MINOR(dev->devt)].mode;
......
...@@ -254,9 +254,9 @@ void misc_deregister(struct miscdevice *misc) ...@@ -254,9 +254,9 @@ void misc_deregister(struct miscdevice *misc)
} }
EXPORT_SYMBOL(misc_deregister); 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) if (mode && c->mode)
*mode = c->mode; *mode = c->mode;
......
...@@ -299,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) ...@@ -299,7 +299,7 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
return err_ret; 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)); return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
} }
......
...@@ -90,7 +90,7 @@ static void drm_sysfs_acpi_register(void) { } ...@@ -90,7 +90,7 @@ static void drm_sysfs_acpi_register(void) { }
static void drm_sysfs_acpi_unregister(void) { } static void drm_sysfs_acpi_unregister(void) { }
#endif #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)); return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
} }
......
...@@ -1224,7 +1224,7 @@ static struct attribute *umad_class_dev_attrs[] = { ...@@ -1224,7 +1224,7 @@ static struct attribute *umad_class_dev_attrs[] = {
}; };
ATTRIBUTE_GROUPS(umad_class_dev); 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)); return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
} }
......
...@@ -1237,7 +1237,7 @@ static void ib_uverbs_remove_one(struct ib_device *device, void *client_data) ...@@ -1237,7 +1237,7 @@ static void ib_uverbs_remove_one(struct ib_device *device, void *client_data)
put_device(&uverbs_dev->dev); 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) if (mode)
*mode = 0666; *mode = 0666;
......
...@@ -72,7 +72,7 @@ const char *class_name(void) ...@@ -72,7 +72,7 @@ const char *class_name(void)
return hfi1_class_name; 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) if (mode)
*mode = 0600; *mode = 0600;
...@@ -85,7 +85,7 @@ static const char *class_name_user(void) ...@@ -85,7 +85,7 @@ static const char *class_name_user(void)
return hfi1_class_name_user; 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) if (mode)
*mode = 0666; *mode = 0666;
......
...@@ -1913,7 +1913,7 @@ static const struct device_type input_dev_type = { ...@@ -1913,7 +1913,7 @@ static const struct device_type input_dev_type = {
#endif #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)); return kasprintf(GFP_KERNEL, "input/%s", dev_name(dev));
} }
......
...@@ -1018,9 +1018,9 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env) ...@@ -1018,9 +1018,9 @@ static int dvb_uevent(const struct device *dev, struct kobj_uevent_env *env)
return 0; 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", return kasprintf(GFP_KERNEL, "dvb/adapter%d/%s%d",
dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id); dvbdev->adapter->num, dnames[dvbdev->type], dvbdev->id);
......
...@@ -2716,9 +2716,9 @@ static const struct file_operations ddb_fops = { ...@@ -2716,9 +2716,9 @@ static const struct file_operations ddb_fops = {
.release = ddb_release, .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); return kasprintf(GFP_KERNEL, "ddbridge/card%d", dev->nr);
} }
......
...@@ -1017,7 +1017,7 @@ static void ir_close(struct input_dev *idev) ...@@ -1017,7 +1017,7 @@ static void ir_close(struct input_dev *idev)
} }
/* class for /sys/class/rc */ /* 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)); return kasprintf(GFP_KERNEL, "rc/%s", dev_name(dev));
} }
......
...@@ -1349,7 +1349,7 @@ static struct pci_driver genwqe_driver = { ...@@ -1349,7 +1349,7 @@ static struct pci_driver genwqe_driver = {
* Default mode should be rw for everybody. Do not change default * Default mode should be rw for everybody. Do not change default
* device name. * 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) if (mode)
*mode = 0666; *mode = 0666;
......
...@@ -3494,7 +3494,7 @@ void tty_default_fops(struct file_operations *fops) ...@@ -3494,7 +3494,7 @@ void tty_default_fops(struct file_operations *fops)
*fops = tty_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) if (!mode)
return NULL; return NULL;
......
...@@ -62,7 +62,7 @@ static struct usb_class { ...@@ -62,7 +62,7 @@ static struct usb_class {
struct class *class; struct class *class;
} *usb_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; struct usb_class_driver *drv;
......
...@@ -1656,7 +1656,7 @@ static const struct file_operations vduse_ctrl_fops = { ...@@ -1656,7 +1656,7 @@ static const struct file_operations vduse_ctrl_fops = {
.llseek = noop_llseek, .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)); return kasprintf(GFP_KERNEL, "vduse/%s", dev_name(dev));
} }
......
...@@ -1812,7 +1812,7 @@ EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare); ...@@ -1812,7 +1812,7 @@ EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare);
/* /*
* Module/class support * 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)); return kasprintf(GFP_KERNEL, "vfio/%s", dev_name(dev));
} }
......
...@@ -46,7 +46,7 @@ static int pmsg_major; ...@@ -46,7 +46,7 @@ static int pmsg_major;
#undef pr_fmt #undef pr_fmt
#define pr_fmt(fmt) PMSG_NAME ": " 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) if (mode)
*mode = 0220; *mode = 0220;
......
...@@ -60,7 +60,7 @@ struct class { ...@@ -60,7 +60,7 @@ struct class {
struct kobject *dev_kobj; struct kobject *dev_kobj;
int (*dev_uevent)(const 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); char *(*devnode)(const struct device *dev, umode_t *mode);
void (*class_release)(struct class *class); void (*class_release)(struct class *class);
void (*dev_release)(struct device *dev); void (*dev_release)(struct device *dev);
......
...@@ -30,7 +30,7 @@ MODULE_DESCRIPTION("Core sound module"); ...@@ -30,7 +30,7 @@ MODULE_DESCRIPTION("Core sound module");
MODULE_AUTHOR("Alan Cox"); MODULE_AUTHOR("Alan Cox");
MODULE_LICENSE("GPL"); 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) if (MAJOR(dev->devt) == SOUND_MAJOR)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment