2022-11-23 12:42:47

by Greg KH

[permalink] [raw]
Subject: [PATCH 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.

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: [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]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [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(-)

diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
index d961ae3ed96e..4e4231a58f38 100644
--- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
@@ -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)
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 6f7b8cc1bc9f..621ba9c0f17a 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -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));
}
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index ed8ac6bcbafb..708751311786 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -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));
}
diff --git a/block/bsg.c b/block/bsg.c
index 2ab1351eb082..08046bd9207d 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -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));
}
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 8eea2529da20..7a368c90467d 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -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));
}
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 5611d127363e..83bf2a4dcb57 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -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;
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index cba19bfdc44d..88c6995b9a3d 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -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;
diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
index 8f5848aa144f..4d7150791315 100644
--- a/drivers/dma-buf/dma-heap.c
+++ b/drivers/dma-buf/dma-heap.c
@@ -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));
}
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 430e00b16eec..14bf156b3f1b 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -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));
}
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 98cb594cd9a6..f83954180a33 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -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));
}
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index d54434088727..bdb179a09d77 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -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;
diff --git a/drivers/infiniband/hw/hfi1/device.c b/drivers/infiniband/hw/hfi1/device.c
index 8ceff7141baf..1f4496032170 100644
--- a/drivers/infiniband/hw/hfi1/device.c
+++ b/drivers/infiniband/hw/hfi1/device.c
@@ -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;
diff --git a/drivers/input/input.c b/drivers/input/input.c
index ebb2b7f0f8ff..50597165dc54 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -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));
}
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 6ef18bab9648..e73f5240cc2c 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -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);
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index fe833f39698a..ee8087f29b2c 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -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);
}
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index eba0cd30e314..527d9324742b 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -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));
}
diff --git a/drivers/misc/genwqe/card_base.c b/drivers/misc/genwqe/card_base.c
index 693981891870..0f00687f72d4 100644
--- a/drivers/misc/genwqe/card_base.c
+++ b/drivers/misc/genwqe/card_base.c
@@ -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;
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index de06c3c2ff70..aad8171f6c21 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -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;
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 558890ada0e5..da7d88e069e6 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -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;

diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
index 35dceee3ed56..0dd3c1f291da 100644
--- a/drivers/vdpa/vdpa_user/vduse_dev.c
+++ b/drivers/vdpa/vdpa_user/vduse_dev.c
@@ -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));
}
diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index 6e8804fe0095..5bf4b3454918 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -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));
}
diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
index d8542ec2f38c..b31c9c72d90b 100644
--- a/fs/pstore/pmsg.c
+++ b/fs/pstore/pmsg.c
@@ -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;
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index 94b1107258e5..42cc3fb44a84 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -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);
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 3332fe321737..3e7dd6fcb7cf 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -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;
--
2.38.1


2022-11-25 12:10:01

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: 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:

> 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.

Acked-by: Mauro Carvalho Chehab <[email protected]>
>
> 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: [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]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [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(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> index d961ae3ed96e..4e4231a58f38 100644
> --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> @@ -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)
> diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
> index 6f7b8cc1bc9f..621ba9c0f17a 100644
> --- a/arch/x86/kernel/cpuid.c
> +++ b/arch/x86/kernel/cpuid.c
> @@ -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));
> }
> diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
> index ed8ac6bcbafb..708751311786 100644
> --- a/arch/x86/kernel/msr.c
> +++ b/arch/x86/kernel/msr.c
> @@ -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));
> }
> diff --git a/block/bsg.c b/block/bsg.c
> index 2ab1351eb082..08046bd9207d 100644
> --- a/block/bsg.c
> +++ b/block/bsg.c
> @@ -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));
> }
> diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
> index 8eea2529da20..7a368c90467d 100644
> --- a/drivers/block/aoe/aoechr.c
> +++ b/drivers/block/aoe/aoechr.c
> @@ -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));
> }
> diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> index 5611d127363e..83bf2a4dcb57 100644
> --- a/drivers/char/mem.c
> +++ b/drivers/char/mem.c
> @@ -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;
> diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> index cba19bfdc44d..88c6995b9a3d 100644
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -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;
> diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
> index 8f5848aa144f..4d7150791315 100644
> --- a/drivers/dma-buf/dma-heap.c
> +++ b/drivers/dma-buf/dma-heap.c
> @@ -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));
> }
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 430e00b16eec..14bf156b3f1b 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -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));
> }
> diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
> index 98cb594cd9a6..f83954180a33 100644
> --- a/drivers/infiniband/core/user_mad.c
> +++ b/drivers/infiniband/core/user_mad.c
> @@ -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));
> }
> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index d54434088727..bdb179a09d77 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -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;
> diff --git a/drivers/infiniband/hw/hfi1/device.c b/drivers/infiniband/hw/hfi1/device.c
> index 8ceff7141baf..1f4496032170 100644
> --- a/drivers/infiniband/hw/hfi1/device.c
> +++ b/drivers/infiniband/hw/hfi1/device.c
> @@ -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;
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index ebb2b7f0f8ff..50597165dc54 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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));
> }
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 6ef18bab9648..e73f5240cc2c 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -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);
> diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
> index fe833f39698a..ee8087f29b2c 100644
> --- a/drivers/media/pci/ddbridge/ddbridge-core.c
> +++ b/drivers/media/pci/ddbridge/ddbridge-core.c
> @@ -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);
> }
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index eba0cd30e314..527d9324742b 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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));
> }
> diff --git a/drivers/misc/genwqe/card_base.c b/drivers/misc/genwqe/card_base.c
> index 693981891870..0f00687f72d4 100644
> --- a/drivers/misc/genwqe/card_base.c
> +++ b/drivers/misc/genwqe/card_base.c
> @@ -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;
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index de06c3c2ff70..aad8171f6c21 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -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;
> diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
> index 558890ada0e5..da7d88e069e6 100644
> --- a/drivers/usb/core/file.c
> +++ b/drivers/usb/core/file.c
> @@ -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;
>
> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
> index 35dceee3ed56..0dd3c1f291da 100644
> --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> @@ -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));
> }
> diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
> index 6e8804fe0095..5bf4b3454918 100644
> --- a/drivers/vfio/vfio_main.c
> +++ b/drivers/vfio/vfio_main.c
> @@ -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));
> }
> diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
> index d8542ec2f38c..b31c9c72d90b 100644
> --- a/fs/pstore/pmsg.c
> +++ b/fs/pstore/pmsg.c
> @@ -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;
> diff --git a/include/linux/device/class.h b/include/linux/device/class.h
> index 94b1107258e5..42cc3fb44a84 100644
> --- a/include/linux/device/class.h
> +++ b/include/linux/device/class.h
> @@ -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);
> diff --git a/sound/sound_core.c b/sound/sound_core.c
> index 3332fe321737..3e7dd6fcb7cf 100644
> --- a/sound/sound_core.c
> +++ b/sound/sound_core.c
> @@ -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;

2022-11-25 13:10:51

by Sumit Semwal

[permalink] [raw]
Subject: Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *

Hello Greg,

On Fri, 25 Nov 2022 at 17:25, Mauro Carvalho Chehab <[email protected]> wrote:
>
> Em Wed, 23 Nov 2022 13:25:20 +0100
> Greg Kroah-Hartman <[email protected]> escreveu:
>
> > 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.
>
> Acked-by: Mauro Carvalho Chehab <[email protected]>
> >
Please feel free to add my
Acked-by: Sumit Semwal <[email protected]>
for the dma-buf portion.

Best,
Sumit.
> > 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: [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]>
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [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(-)
> >
> > diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> > index d961ae3ed96e..4e4231a58f38 100644
> > --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> > +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
> > @@ -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)
> > diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
> > index 6f7b8cc1bc9f..621ba9c0f17a 100644
> > --- a/arch/x86/kernel/cpuid.c
> > +++ b/arch/x86/kernel/cpuid.c
> > @@ -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));
> > }
> > diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
> > index ed8ac6bcbafb..708751311786 100644
> > --- a/arch/x86/kernel/msr.c
> > +++ b/arch/x86/kernel/msr.c
> > @@ -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));
> > }
> > diff --git a/block/bsg.c b/block/bsg.c
> > index 2ab1351eb082..08046bd9207d 100644
> > --- a/block/bsg.c
> > +++ b/block/bsg.c
> > @@ -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));
> > }
> > diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
> > index 8eea2529da20..7a368c90467d 100644
> > --- a/drivers/block/aoe/aoechr.c
> > +++ b/drivers/block/aoe/aoechr.c
> > @@ -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));
> > }
> > diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> > index 5611d127363e..83bf2a4dcb57 100644
> > --- a/drivers/char/mem.c
> > +++ b/drivers/char/mem.c
> > @@ -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;
> > diff --git a/drivers/char/misc.c b/drivers/char/misc.c
> > index cba19bfdc44d..88c6995b9a3d 100644
> > --- a/drivers/char/misc.c
> > +++ b/drivers/char/misc.c
> > @@ -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;
> > diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
> > index 8f5848aa144f..4d7150791315 100644
> > --- a/drivers/dma-buf/dma-heap.c
> > +++ b/drivers/dma-buf/dma-heap.c
> > @@ -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));
> > }
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index 430e00b16eec..14bf156b3f1b 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -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));
> > }
> > diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
> > index 98cb594cd9a6..f83954180a33 100644
> > --- a/drivers/infiniband/core/user_mad.c
> > +++ b/drivers/infiniband/core/user_mad.c
> > @@ -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));
> > }
> > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> > index d54434088727..bdb179a09d77 100644
> > --- a/drivers/infiniband/core/uverbs_main.c
> > +++ b/drivers/infiniband/core/uverbs_main.c
> > @@ -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;
> > diff --git a/drivers/infiniband/hw/hfi1/device.c b/drivers/infiniband/hw/hfi1/device.c
> > index 8ceff7141baf..1f4496032170 100644
> > --- a/drivers/infiniband/hw/hfi1/device.c
> > +++ b/drivers/infiniband/hw/hfi1/device.c
> > @@ -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;
> > diff --git a/drivers/input/input.c b/drivers/input/input.c
> > index ebb2b7f0f8ff..50597165dc54 100644
> > --- a/drivers/input/input.c
> > +++ b/drivers/input/input.c
> > @@ -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));
> > }
> > diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> > index 6ef18bab9648..e73f5240cc2c 100644
> > --- a/drivers/media/dvb-core/dvbdev.c
> > +++ b/drivers/media/dvb-core/dvbdev.c
> > @@ -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);
> > diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
> > index fe833f39698a..ee8087f29b2c 100644
> > --- a/drivers/media/pci/ddbridge/ddbridge-core.c
> > +++ b/drivers/media/pci/ddbridge/ddbridge-core.c
> > @@ -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);
> > }
> > diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> > index eba0cd30e314..527d9324742b 100644
> > --- a/drivers/media/rc/rc-main.c
> > +++ b/drivers/media/rc/rc-main.c
> > @@ -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));
> > }
> > diff --git a/drivers/misc/genwqe/card_base.c b/drivers/misc/genwqe/card_base.c
> > index 693981891870..0f00687f72d4 100644
> > --- a/drivers/misc/genwqe/card_base.c
> > +++ b/drivers/misc/genwqe/card_base.c
> > @@ -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;
> > diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> > index de06c3c2ff70..aad8171f6c21 100644
> > --- a/drivers/tty/tty_io.c
> > +++ b/drivers/tty/tty_io.c
> > @@ -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;
> > diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
> > index 558890ada0e5..da7d88e069e6 100644
> > --- a/drivers/usb/core/file.c
> > +++ b/drivers/usb/core/file.c
> > @@ -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;
> >
> > diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c
> > index 35dceee3ed56..0dd3c1f291da 100644
> > --- a/drivers/vdpa/vdpa_user/vduse_dev.c
> > +++ b/drivers/vdpa/vdpa_user/vduse_dev.c
> > @@ -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));
> > }
> > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
> > index 6e8804fe0095..5bf4b3454918 100644
> > --- a/drivers/vfio/vfio_main.c
> > +++ b/drivers/vfio/vfio_main.c
> > @@ -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));
> > }
> > diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
> > index d8542ec2f38c..b31c9c72d90b 100644
> > --- a/fs/pstore/pmsg.c
> > +++ b/fs/pstore/pmsg.c
> > @@ -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;
> > diff --git a/include/linux/device/class.h b/include/linux/device/class.h
> > index 94b1107258e5..42cc3fb44a84 100644
> > --- a/include/linux/device/class.h
> > +++ b/include/linux/device/class.h
> > @@ -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);
> > diff --git a/sound/sound_core.c b/sound/sound_core.c
> > index 3332fe321737..3e7dd6fcb7cf 100644
> > --- a/sound/sound_core.c
> > +++ b/sound/sound_core.c
> > @@ -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;



--
Thanks and regards,

Sumit Semwal (he / him)
Tech Lead - LCG, Vertical Technologies
Linaro.org │ Open source software for ARM SoCs