All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
@ 2022-11-23 12:25 Greg Kroah-Hartman
  2022-11-23 12:25   ` Greg Kroah-Hartman
                   ` (7 more replies)
  0 siblings, 8 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Mauro Carvalho Chehab,
	Keith Busch, Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	Sebastian Reichel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Johannes Berg, Wolfram Sang, Raed Salem,
	Chen Zhongjin, Tetsuo Handa, Avihai Horon,
	Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

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 <axboe@kernel.dk>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Russ Weight <russell.h.weight@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Raed Salem <raeds@nvidia.com>
Cc: Chen Zhongjin <chenzhongjin@huawei.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Avihai Horon <avihaih@nvidia.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Jakob Koschel <jakobkoschel@gmail.com>
Cc: Antoine Tenart <atenart@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Cc: Wang Yufen <wangyufen@huawei.com>
Cc: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: linux-nvme@lists.infradead.org
Cc: linux-pm@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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(-)

diff --git a/block/genhd.c b/block/genhd.c
index 0f9769db2de8..3f1124713442 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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);
 }
diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
index 5b66b3d1fa16..56911d75b90a 100644
--- a/drivers/base/firmware_loader/sysfs.c
+++ b/drivers/base/firmware_loader/sysfs.c
@@ -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_env
 	return 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);
diff --git a/drivers/base/firmware_loader/sysfs.h b/drivers/base/firmware_loader/sysfs.h
index df1d5add698f..fd0b4ad9bdbb 100644
--- a/drivers/base/firmware_loader/sysfs.h
+++ b/drivers/base/firmware_loader/sysfs.h
@@ -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);
 }
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 940ddf916202..5f3a3e913d28 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -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;
 
diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
index 1e82b7967570..77a4b280c552 100644
--- a/drivers/gnss/core.c
+++ b/drivers/gnss/core.c
@@ -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));
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index fa65c5d3d395..4186dbf9377f 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -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)))
diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
index 90ee56d07a6e..9120be590325 100644
--- a/drivers/isdn/mISDN/core.c
+++ b/drivers/isdn/mISDN/core.c
@@ -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;
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 675d877a67b2..6ef18bab9648 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -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]);
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index da55ce45ac70..b4778b970dd4 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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;
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index f70197154a36..e3224e49c43f 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -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;
diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
index c310d4f36c10..645eee4d6b6a 100644
--- a/drivers/power/supply/power_supply.h
+++ b/drivers/power/supply/power_supply.h
@@ -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
 
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 5369abaceb5c..6ca7d3985a40 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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;
 
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index c63c0c2cf649..b5994a0604f6 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -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);
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index 20103e0b03c3..94b1107258e5 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -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);
diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
index 7dd1f01ec4f9..7aab4a769736 100644
--- a/include/linux/mISDNif.h
+++ b/include/linux/mISDNif.h
@@ -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);
diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
index 0fdbdfd19474..466353b3dde4 100644
--- a/net/atm/atm_sysfs.c
+++ b/net/atm/atm_sysfs.c
@@ -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;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 9cfc80b8ed25..03a61d1dffbd 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -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. */
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index dac4fdc7488a..b390ff245d5e 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 2/5] driver core: make struct class.devnode() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
  2022-11-23 12:25   ` Greg Kroah-Hartman
  2022-11-23 12:25   ` Greg Kroah-Hartman
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  2022-11-23 12:25 ` [PATCH 5/5] driver core: device_get_devnode() should " Greg Kroah-Hartman
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Fenghua Yu, Reinette Chatre, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	FUJITA Tomonori, Jens Axboe, Justin Sanders, Arnd Bergmann,
	Sumit Semwal, Benjamin Gaignard, Liam Mark, Laura Abbott,
	Brian Starkey, John Stultz, Christian König,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Jason Gunthorpe, Leon Romanovsky,
	Dennis Dalessandro, Dmitry Torokhov, Mauro Carvalho Chehab,
	Sean Young, Frank Haverkamp, Jiri Slaby, Michael S. Tsirkin,
	Jason Wang, Alex Williamson, Cornelia Huck, Kees Cook,
	Anton Vorontsov, Colin Cross, Tony Luck, Jaroslav Kysela,
	Takashi Iwai, Hans Verkuil, Christophe JAILLET, Xie Yongji,
	Gautam Dawar, Dan Carpenter, Eli Cohen, Parav Pandit,
	Maxime Coquelin, alsa-devel, dri-devel, kvm, linaro-mm-sig,
	linux-block, linux-input, linux-media, linux-rdma, linux-scsi,
	linux-usb, virtualization

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Dave Hansen, dri-devel, Jaroslav Kysela,
	John Stultz, H. Peter Anvin, Eli Cohen, David Airlie,
	Sumit Semwal, Kees Cook, Mauro Carvalho Chehab,
	Benjamin Gaignard, kvm, Leon Romanovsky, Dennis Dalessandro,
	linux-rdma, Jiri Slaby, x86, Frank Haverkamp, Dan Carpenter,
	Jason Gunthorpe, Ingo Molnar, linux-input, Laura Abbott,
	virtualization, linux-media, Fenghua Yu, Daniel Vetter,
	Arnd Bergmann, Colin Cross, Maarten Lankhorst, Maxime Ripard,
	linaro-mm-sig, Gautam Dawar, Borislav Petkov, Thomas Gleixner,
	Reinette Chatre, Jens Axboe, linux-block, Tony Luck, linux-scsi,
	Greg Kroah-Hartman, Dmitry Torokhov, Takashi Iwai, Liam Mark,
	Brian Starkey, FUJITA Tomonori, Xie Yongji, Maxime Coquelin,
	linux-usb, Thomas Zimmermann, Cornelia Huck, Hans Verkuil,
	Christophe JAILLET, Christian König

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Jason Wang, Dave Hansen, dri-devel,
	Jaroslav Kysela, John Stultz, H. Peter Anvin, Eli Cohen,
	Sumit Semwal, Kees Cook, Parav Pandit, Mauro Carvalho Chehab,
	Benjamin Gaignard, kvm, Leon Romanovsky, Dennis Dalessandro,
	linux-rdma, Jiri Slaby, x86, Frank Haverkamp, Dan Carpenter,
	Jason Gunthorpe, Ingo Molnar, linux-input, Laura Abbott,
	virtualization, linux-media, Fenghua Yu, Arnd Bergmann,
	Colin Cross, linaro-mm-sig, Gautam Dawar, Alex Williamson,
	Borislav Petkov, Thomas Gleixner, Reinette Chatre, Jens Axboe,
	linux-block, Tony Luck, linux-scsi, Greg Kroah-Hartman,
	Dmitry Torokhov, Takashi Iwai, Liam Mark, FUJITA Tomonori,
	Xie Yongji, Maxime Coquelin, linux-usb, Thomas Zimmermann,
	Cornelia Huck, Hans Verkuil, Christophe JAILLET,
	Christian König

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Jason Wang, Dave Hansen, dri-devel,
	John Stultz, H. Peter Anvin, Eli Cohen, David Airlie,
	Sumit Semwal, Kees Cook, Parav Pandit, Mauro Carvalho Chehab,
	Benjamin Gaignard, kvm, Leon Romanovsky, Dennis Dalessandro,
	linux-rdma, Jiri Slaby, x86, Frank Haverkamp, Dan Carpenter,
	Jason Gunthorpe, Ingo Molnar, linux-input, Laura Abbott,
	virtualization, linux-media, Fenghua Yu, Daniel Vetter,
	Arnd Bergmann, Colin Cross, Maarten Lankhorst, Maxime Ripard,
	linaro-mm-sig, Gautam Dawar, Alex Williamson, Borislav Petkov,
	Thomas Gleixner, Reinette Chatre, Jens Axboe, linux-block,
	Tony Luck, linux-scsi, Greg Kroah-Hartman, Dmitry Torokhov,
	Takashi Iwai, Liam Mark, Brian Starkey, FUJITA Tomonori,
	Xie Yongji, Maxime Coquelin, linux-usb, Thomas Zimmermann,
	Cornelia Huck, Hans Verkuil, Christophe JAILLET,
	Christian König

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
  2022-11-23 12:25   ` Greg Kroah-Hartman
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  2022-11-23 12:25 ` [PATCH 4/5] driver core: make struct device_type.devnode() " Greg Kroah-Hartman
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

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

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

diff --git a/block/partitions/core.c b/block/partitions/core.c
index b8112f52d388..7b8ef6296abd 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -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])
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 120873dad2cc..daff2c0c5c52 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -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);
 }
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 219c02df9a08..d422884eb3d0 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -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);
 
 /* --------------------------------------------------------------------------
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index adddd8c45d0c..aa597cda0d88 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -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));
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index b4edf10e8fd0..fb16e33e52c6 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -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);
diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
index e92d3e9a52bd..05f8ab762e34 100644
--- a/drivers/i3c/device.c
+++ b/drivers/i3c/device.c
@@ -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);
 }
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 351c81a929a6..bf1a2b2f34c4 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -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;
 
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 50597165dc54..a612afffa196 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -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,
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 527d9324742b..6bdad6341844 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -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;
diff --git a/drivers/of/device.c b/drivers/of/device.c
index c674a13c3055..dda51b7ce597 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -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;
 
diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
index de539938896e..407eb55050a6 100644
--- a/drivers/platform/surface/aggregator/bus.c
+++ b/drivers/platform/surface/aggregator/bus.c
@@ -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,
diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
index 04b3529f8929..26c9a0a85d49 100644
--- a/drivers/soundwire/bus_type.c
+++ b/drivers/soundwire/bus_type.c
@@ -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));
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 60da5c23ccaf..2f4ef156b210 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -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) {
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index f9786976f5ec..909da0a98134 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -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);
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index f00b2f62d8e3..aeb40a384bea 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -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));
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 0180e1e4e75d..aa80de3a8194 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -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;
 
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 4d59d927ae3e..c397574a6570 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 11b15d7b357a..8527c06b65e6 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -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);
 
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 1b24492bb4e5..4b468bde19cf 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -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;
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index a3575a5a18ce..3708fb70b693 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -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;
 
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index bd5e5dd70431..8e2b2077f262 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -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;
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3015235d65e3..fc956c3f8324 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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;
diff --git a/include/linux/device.h b/include/linux/device.h
index 84ae52de6746..46093bae6905 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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);
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 980019053e54..4c882d57df02 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -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);
 }
diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index 8242e13e7b0b..cda61c1d6d60 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -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;
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index ab7d557d541d..f4b57614979d 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -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;
diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
index 52eb66cd11bc..d8c27f1e5559 100644
--- a/include/linux/soundwire/sdw_type.h
+++ b/include/linux/soundwire/sdw_type.h
@@ -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
diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
index 46c45d1b6368..a5dff729edb7 100644
--- a/include/linux/surface_aggregator/device.h
+++ b/include/linux/surface_aggregator/device.h
@@ -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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

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

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

diff --git a/block/partitions/core.c b/block/partitions/core.c
index b8112f52d388..7b8ef6296abd 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -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])
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 120873dad2cc..daff2c0c5c52 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -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);
 }
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 219c02df9a08..d422884eb3d0 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -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);
 
 /* --------------------------------------------------------------------------
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index adddd8c45d0c..aa597cda0d88 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -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));
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index b4edf10e8fd0..fb16e33e52c6 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -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);
diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
index e92d3e9a52bd..05f8ab762e34 100644
--- a/drivers/i3c/device.c
+++ b/drivers/i3c/device.c
@@ -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);
 }
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 351c81a929a6..bf1a2b2f34c4 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -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;
 
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 50597165dc54..a612afffa196 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -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,
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 527d9324742b..6bdad6341844 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -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;
diff --git a/drivers/of/device.c b/drivers/of/device.c
index c674a13c3055..dda51b7ce597 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -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;
 
diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
index de539938896e..407eb55050a6 100644
--- a/drivers/platform/surface/aggregator/bus.c
+++ b/drivers/platform/surface/aggregator/bus.c
@@ -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,
diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
index 04b3529f8929..26c9a0a85d49 100644
--- a/drivers/soundwire/bus_type.c
+++ b/drivers/soundwire/bus_type.c
@@ -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));
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 60da5c23ccaf..2f4ef156b210 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -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) {
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index f9786976f5ec..909da0a98134 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -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);
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index f00b2f62d8e3..aeb40a384bea 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -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));
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 0180e1e4e75d..aa80de3a8194 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -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;
 
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 4d59d927ae3e..c397574a6570 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 11b15d7b357a..8527c06b65e6 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -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);
 
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 1b24492bb4e5..4b468bde19cf 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -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;
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index a3575a5a18ce..3708fb70b693 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -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;
 
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index bd5e5dd70431..8e2b2077f262 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -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;
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3015235d65e3..fc956c3f8324 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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;
diff --git a/include/linux/device.h b/include/linux/device.h
index 84ae52de6746..46093bae6905 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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);
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 980019053e54..4c882d57df02 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -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);
 }
diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index 8242e13e7b0b..cda61c1d6d60 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -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;
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index ab7d557d541d..f4b57614979d 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -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;
diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
index 52eb66cd11bc..d8c27f1e5559 100644
--- a/include/linux/soundwire/sdw_type.h
+++ b/include/linux/soundwire/sdw_type.h
@@ -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
diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
index 46c45d1b6368..a5dff729edb7 100644
--- a/include/linux/surface_aggregator/device.h
+++ b/include/linux/surface_aggregator/device.h
@@ -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


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 12:25   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab,
	Mika Westerberg, Jens Axboe, linux-block, Jilin Yuan,
	Martin K. Petersen, Greg Kroah-Hartman, Dmitry Torokhov,
	Wolfram Sang, Vinod Koul, Stefan Richter, Sakari Ailus,
	Yehezkel Bernat, Sanyog Kale, linux-media, Maximilian Luz,
	linux-usb

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

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

diff --git a/block/partitions/core.c b/block/partitions/core.c
index b8112f52d388..7b8ef6296abd 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -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])
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index 120873dad2cc..daff2c0c5c52 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -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);
 }
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 219c02df9a08..d422884eb3d0 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -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);
 
 /* --------------------------------------------------------------------------
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index adddd8c45d0c..aa597cda0d88 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -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));
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index b4edf10e8fd0..fb16e33e52c6 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -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);
diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
index e92d3e9a52bd..05f8ab762e34 100644
--- a/drivers/i3c/device.c
+++ b/drivers/i3c/device.c
@@ -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);
 }
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 351c81a929a6..bf1a2b2f34c4 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -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;
 
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 50597165dc54..a612afffa196 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -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,
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 527d9324742b..6bdad6341844 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -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;
diff --git a/drivers/of/device.c b/drivers/of/device.c
index c674a13c3055..dda51b7ce597 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -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;
 
diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
index de539938896e..407eb55050a6 100644
--- a/drivers/platform/surface/aggregator/bus.c
+++ b/drivers/platform/surface/aggregator/bus.c
@@ -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,
diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
index 04b3529f8929..26c9a0a85d49 100644
--- a/drivers/soundwire/bus_type.c
+++ b/drivers/soundwire/bus_type.c
@@ -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));
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 60da5c23ccaf..2f4ef156b210 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -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) {
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index f9786976f5ec..909da0a98134 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -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);
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index f00b2f62d8e3..aeb40a384bea 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -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));
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 0180e1e4e75d..aa80de3a8194 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -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;
 
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 4d59d927ae3e..c397574a6570 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 11b15d7b357a..8527c06b65e6 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -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);
 
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 1b24492bb4e5..4b468bde19cf 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -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;
diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index a3575a5a18ce..3708fb70b693 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -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;
 
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index bd5e5dd70431..8e2b2077f262 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -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;
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3015235d65e3..fc956c3f8324 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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;
diff --git a/include/linux/device.h b/include/linux/device.h
index 84ae52de6746..46093bae6905 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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);
diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index 980019053e54..4c882d57df02 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -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);
 }
diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
index 8242e13e7b0b..cda61c1d6d60 100644
--- a/include/linux/i3c/device.h
+++ b/include/linux/i3c/device.h
@@ -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;
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index ab7d557d541d..f4b57614979d 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -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;
diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
index 52eb66cd11bc..d8c27f1e5559 100644
--- a/include/linux/soundwire/sdw_type.h
+++ b/include/linux/soundwire/sdw_type.h
@@ -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
diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
index 46c45d1b6368..a5dff729edb7 100644
--- a/include/linux/surface_aggregator/device.h
+++ b/include/linux/surface_aggregator/device.h
@@ -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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 4/5] driver core: make struct device_type.devnode() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
  2022-11-23 12:25   ` Greg Kroah-Hartman
  2022-11-23 12:25   ` Greg Kroah-Hartman
@ 2022-11-23 12:25 ` Greg Kroah-Hartman
  2022-11-23 19:23   ` Dan Williams
  2022-11-23 12:25 ` [PATCH 5/5] driver core: device_get_devnode() should " Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Jens Axboe, Alison Schofield, Vishal Verma,
	Ira Weiny, Ben Widawsky, Dan Williams, Jeremy Kerr, Joel Stanley,
	Alistar Popple, Eddie James, Alexander Shishkin,
	Jonathan Cameron, Jilin Yuan, Heikki Krogerus, Alan Stern,
	Andy Shevchenko, Thomas Gleixner, Jason Gunthorpe,
	Rafael J. Wysocki, Won Chung, linux-block, linux-cxl, linux-fsi,
	linux-usb

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

Cc: Jens Axboe <axboe@kernel.dk>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Ben Widawsky <bwidawsk@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jeremy Kerr <jk@ozlabs.org>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Alistar Popple <alistair@popple.id.au>
Cc: Eddie James <eajames@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Won Chung <wonchung@google.com>
Cc: linux-block@vger.kernel.org
Cc: linux-cxl@vger.kernel.org
Cc: linux-fsi@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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(-)

diff --git a/block/genhd.c b/block/genhd.c
index 3f1124713442..391b52655b97 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -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);
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index 20ce488a7754..6ae8d0bdc61b 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -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));
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 694e80c06665..0b927c9f4267 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -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
diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
index 7e753a75d23b..cc7f879bb175 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -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)
diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
index 0ffb42990175..6cbba733f259 100644
--- a/drivers/hwtracing/intel_th/intel_th.h
+++ b/drivers/hwtracing/intel_th/intel_th.h
@@ -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);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 8527c06b65e6..4df26f4f76e6 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -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",
diff --git a/include/linux/device.h b/include/linux/device.h
index 46093bae6905..4ad1280713e6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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);
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* [PATCH 5/5] driver core: device_get_devnode() should take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2022-11-23 12:25 ` [PATCH 4/5] driver core: make struct device_type.devnode() " Greg Kroah-Hartman
@ 2022-11-23 12:25 ` Greg Kroah-Hartman
  2022-11-23 12:39   ` Rafael J. Wysocki
  2022-11-23 13:36   ` Andy Shevchenko
  2022-11-23 12:38 ` [PATCH 1/5] driver core: make struct class.dev_uevent() " Rafael J. Wysocki
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 12:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Thomas Gleixner,
	Jason Gunthorpe, Ira Weiny, Dan Williams, Andy Shevchenko,
	Won Chung

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 of device.h as it does not need to be exposed to
the whole kernel tree.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Won Chung <wonchung@google.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/base.h    | 2 ++
 drivers/base/core.c    | 2 +-
 include/linux/device.h | 2 --
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index 7d4803c03d3e..a8a119c36bdc 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -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;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a3e14143ec0c..72ec54a8a4e1 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -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)
 {
diff --git a/include/linux/device.h b/include/linux/device.h
index 4ad1280713e6..e4498389e866 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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


^ permalink raw reply related	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 12:25   ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 12:38     ` Rafael J. Wysocki
  -1 siblings, 0 replies; 103+ messages in thread
From: Rafael J. Wysocki @ 2022-11-23 12:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.
>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Chaitanya Kulkarni <kch@nvidia.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: alsa-devel@alsa-project.org
> Cc: devicetree@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-i3c@lists.infradead.org
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux1394-devel@lists.sourceforge.net
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

(which my ACPI maintainer hat on).

Thanks!

> ---
>  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(-)
>
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index b8112f52d388..7b8ef6296abd 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -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])
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 120873dad2cc..daff2c0c5c52 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 219c02df9a08..d422884eb3d0 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -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);
>
>  /* --------------------------------------------------------------------------
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
> index adddd8c45d0c..aa597cda0d88 100644
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -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));
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index b4edf10e8fd0..fb16e33e52c6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
> index e92d3e9a52bd..05f8ab762e34 100644
> --- a/drivers/i3c/device.c
> +++ b/drivers/i3c/device.c
> @@ -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);
>  }
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 351c81a929a6..bf1a2b2f34c4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -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;
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 50597165dc54..a612afffa196 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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,
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 527d9324742b..6bdad6341844 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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;
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index c674a13c3055..dda51b7ce597 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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;
>
> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 04b3529f8929..26c9a0a85d49 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -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));
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 60da5c23ccaf..2f4ef156b210 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -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) {
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index f9786976f5ec..909da0a98134 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -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);
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index f00b2f62d8e3..aeb40a384bea 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -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));
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..aa80de3a8194 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -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;
>
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 4d59d927ae3e..c397574a6570 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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);
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 11b15d7b357a..8527c06b65e6 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -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);
>
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 1b24492bb4e5..4b468bde19cf 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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;
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index a3575a5a18ce..3708fb70b693 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -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;
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index bd5e5dd70431..8e2b2077f262 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -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;
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..fc956c3f8324 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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;
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 84ae52de6746..46093bae6905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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);
> diff --git a/include/linux/firewire.h b/include/linux/firewire.h
> index 980019053e54..4c882d57df02 100644
> --- a/include/linux/firewire.h
> +++ b/include/linux/firewire.h
> @@ -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);
>  }
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 8242e13e7b0b..cda61c1d6d60 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ab7d557d541d..f4b57614979d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -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;
> diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
> index 52eb66cd11bc..d8c27f1e5559 100644
> --- a/include/linux/soundwire/sdw_type.h
> +++ b/include/linux/soundwire/sdw_type.h
> @@ -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
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 46c45d1b6368..a5dff729edb7 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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
>

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 12:38     ` Rafael J. Wysocki
  0 siblings, 0 replies; 103+ messages in thread
From: Rafael J. Wysocki @ 2022-11-23 12:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.
>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Chaitanya Kulkarni <kch@nvidia.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: alsa-devel@alsa-project.org
> Cc: devicetree@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-i3c@lists.infradead.org
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux1394-devel@lists.sourceforge.net
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

(which my ACPI maintainer hat on).

Thanks!

> ---
>  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(-)
>
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index b8112f52d388..7b8ef6296abd 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -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])
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 120873dad2cc..daff2c0c5c52 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 219c02df9a08..d422884eb3d0 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -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);
>
>  /* --------------------------------------------------------------------------
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
> index adddd8c45d0c..aa597cda0d88 100644
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -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));
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index b4edf10e8fd0..fb16e33e52c6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
> index e92d3e9a52bd..05f8ab762e34 100644
> --- a/drivers/i3c/device.c
> +++ b/drivers/i3c/device.c
> @@ -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);
>  }
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 351c81a929a6..bf1a2b2f34c4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -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;
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 50597165dc54..a612afffa196 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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,
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 527d9324742b..6bdad6341844 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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;
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index c674a13c3055..dda51b7ce597 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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;
>
> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 04b3529f8929..26c9a0a85d49 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -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));
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 60da5c23ccaf..2f4ef156b210 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -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) {
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index f9786976f5ec..909da0a98134 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -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);
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index f00b2f62d8e3..aeb40a384bea 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -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));
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..aa80de3a8194 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -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;
>
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 4d59d927ae3e..c397574a6570 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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);
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 11b15d7b357a..8527c06b65e6 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -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);
>
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 1b24492bb4e5..4b468bde19cf 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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;
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index a3575a5a18ce..3708fb70b693 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -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;
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index bd5e5dd70431..8e2b2077f262 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -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;
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..fc956c3f8324 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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;
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 84ae52de6746..46093bae6905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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);
> diff --git a/include/linux/firewire.h b/include/linux/firewire.h
> index 980019053e54..4c882d57df02 100644
> --- a/include/linux/firewire.h
> +++ b/include/linux/firewire.h
> @@ -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);
>  }
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 8242e13e7b0b..cda61c1d6d60 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ab7d557d541d..f4b57614979d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -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;
> diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
> index 52eb66cd11bc..d8c27f1e5559 100644
> --- a/include/linux/soundwire/sdw_type.h
> +++ b/include/linux/soundwire/sdw_type.h
> @@ -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
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 46c45d1b6368..a5dff729edb7 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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
>

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 12:38     ` Rafael J. Wysocki
  0 siblings, 0 replies; 103+ messages in thread
From: Rafael J. Wysocki @ 2022-11-23 12:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab,
	Mika Westerberg, Jens Axboe, linux-block, Jilin Yuan,
	Martin K. Petersen, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.
>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Chaitanya Kulkarni <kch@nvidia.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: alsa-devel@alsa-project.org
> Cc: devicetree@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-i3c@lists.infradead.org
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux1394-devel@lists.sourceforge.net
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

(which my ACPI maintainer hat on).

Thanks!

> ---
>  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(-)
>
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index b8112f52d388..7b8ef6296abd 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -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])
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 120873dad2cc..daff2c0c5c52 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 219c02df9a08..d422884eb3d0 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -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);
>
>  /* --------------------------------------------------------------------------
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
> index adddd8c45d0c..aa597cda0d88 100644
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -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));
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index b4edf10e8fd0..fb16e33e52c6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
> index e92d3e9a52bd..05f8ab762e34 100644
> --- a/drivers/i3c/device.c
> +++ b/drivers/i3c/device.c
> @@ -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);
>  }
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 351c81a929a6..bf1a2b2f34c4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -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;
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 50597165dc54..a612afffa196 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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,
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 527d9324742b..6bdad6341844 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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;
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index c674a13c3055..dda51b7ce597 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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;
>
> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 04b3529f8929..26c9a0a85d49 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -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));
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 60da5c23ccaf..2f4ef156b210 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -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) {
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index f9786976f5ec..909da0a98134 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -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);
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index f00b2f62d8e3..aeb40a384bea 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -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));
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..aa80de3a8194 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -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;
>
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 4d59d927ae3e..c397574a6570 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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);
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 11b15d7b357a..8527c06b65e6 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -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);
>
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 1b24492bb4e5..4b468bde19cf 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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;
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index a3575a5a18ce..3708fb70b693 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -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;
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index bd5e5dd70431..8e2b2077f262 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -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;
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..fc956c3f8324 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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;
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 84ae52de6746..46093bae6905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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);
> diff --git a/include/linux/firewire.h b/include/linux/firewire.h
> index 980019053e54..4c882d57df02 100644
> --- a/include/linux/firewire.h
> +++ b/include/linux/firewire.h
> @@ -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);
>  }
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 8242e13e7b0b..cda61c1d6d60 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ab7d557d541d..f4b57614979d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -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;
> diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
> index 52eb66cd11bc..d8c27f1e5559 100644
> --- a/include/linux/soundwire/sdw_type.h
> +++ b/include/linux/soundwire/sdw_type.h
> @@ -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
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 46c45d1b6368..a5dff729edb7 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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
>

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2022-11-23 12:25 ` [PATCH 5/5] driver core: device_get_devnode() should " Greg Kroah-Hartman
@ 2022-11-23 12:38 ` Rafael J. Wysocki
  2022-11-24 15:03 ` Sebastian Reichel
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 103+ messages in thread
From: Rafael J. Wysocki @ 2022-11-23 12:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Mauro Carvalho Chehab,
	Keith Busch, Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	Sebastian Reichel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Johannes Berg, Wolfram Sang, Raed Salem,
	Chen Zhongjin, Tetsuo Handa, Avihai Horon,
	Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> 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 <axboe@kernel.dk>
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Russ Weight <russell.h.weight@intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Karsten Keil <isdn@linux-pingi.de>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: Raed Salem <raeds@nvidia.com>
> Cc: Chen Zhongjin <chenzhongjin@huawei.com>
> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Cc: Avihai Horon <avihaih@nvidia.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Colin Ian King <colin.i.king@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Jakob Koschel <jakobkoschel@gmail.com>
> Cc: Antoine Tenart <atenart@kernel.org>
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: Wang Yufen <wangyufen@huawei.com>
> Cc: linux-block@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-nvme@lists.infradead.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
>  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(-)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 0f9769db2de8..3f1124713442 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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);
>  }
> diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
> index 5b66b3d1fa16..56911d75b90a 100644
> --- a/drivers/base/firmware_loader/sysfs.c
> +++ b/drivers/base/firmware_loader/sysfs.c
> @@ -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_env
>         return 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);
> diff --git a/drivers/base/firmware_loader/sysfs.h b/drivers/base/firmware_loader/sysfs.h
> index df1d5add698f..fd0b4ad9bdbb 100644
> --- a/drivers/base/firmware_loader/sysfs.h
> +++ b/drivers/base/firmware_loader/sysfs.h
> @@ -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);
>  }
> diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
> index 940ddf916202..5f3a3e913d28 100644
> --- a/drivers/firmware/dmi-id.c
> +++ b/drivers/firmware/dmi-id.c
> @@ -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;
>
> diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
> index 1e82b7967570..77a4b280c552 100644
> --- a/drivers/gnss/core.c
> +++ b/drivers/gnss/core.c
> @@ -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));
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index fa65c5d3d395..4186dbf9377f 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -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)))
> diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
> index 90ee56d07a6e..9120be590325 100644
> --- a/drivers/isdn/mISDN/core.c
> +++ b/drivers/isdn/mISDN/core.c
> @@ -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;
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 675d877a67b2..6ef18bab9648 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -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]);
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index da55ce45ac70..b4778b970dd4 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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;
> diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
> index f70197154a36..e3224e49c43f 100644
> --- a/drivers/pcmcia/cs.c
> +++ b/drivers/pcmcia/cs.c
> @@ -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;
> diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
> index c310d4f36c10..645eee4d6b6a 100644
> --- a/drivers/power/supply/power_supply.h
> +++ b/drivers/power/supply/power_supply.h
> @@ -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
>
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 5369abaceb5c..6ca7d3985a40 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -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;
>
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index c63c0c2cf649..b5994a0604f6 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -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);
> diff --git a/include/linux/device/class.h b/include/linux/device/class.h
> index 20103e0b03c3..94b1107258e5 100644
> --- a/include/linux/device/class.h
> +++ b/include/linux/device/class.h
> @@ -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);
> diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
> index 7dd1f01ec4f9..7aab4a769736 100644
> --- a/include/linux/mISDNif.h
> +++ b/include/linux/mISDNif.h
> @@ -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);
> diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
> index 0fdbdfd19474..466353b3dde4 100644
> --- a/net/atm/atm_sysfs.c
> +++ b/net/atm/atm_sysfs.c
> @@ -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;
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 9cfc80b8ed25..03a61d1dffbd 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -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. */
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index dac4fdc7488a..b390ff245d5e 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 5/5] driver core: device_get_devnode() should take a const *
  2022-11-23 12:25 ` [PATCH 5/5] driver core: device_get_devnode() should " Greg Kroah-Hartman
@ 2022-11-23 12:39   ` Rafael J. Wysocki
  2022-11-23 13:36   ` Andy Shevchenko
  1 sibling, 0 replies; 103+ messages in thread
From: Rafael J. Wysocki @ 2022-11-23 12:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Rafael J. Wysocki, Thomas Gleixner,
	Jason Gunthorpe, Ira Weiny, Dan Williams, Andy Shevchenko,
	Won Chung

On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> 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 of device.h as it does not need to be exposed to
> the whole kernel tree.
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
>  drivers/base/base.h    | 2 ++
>  drivers/base/core.c    | 2 +-
>  include/linux/device.h | 2 --
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/base.h b/drivers/base/base.h
> index 7d4803c03d3e..a8a119c36bdc 100644
> --- a/drivers/base/base.h
> +++ b/drivers/base/base.h
> @@ -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;
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index a3e14143ec0c..72ec54a8a4e1 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -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)
>  {
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 4ad1280713e6..e4498389e866 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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
>

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 12:25   ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 13:14     ` Maximilian Luz
  -1 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 13:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

Hi,

On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.

[...]

> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,

[...]

> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:14     ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 13:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

Hi,

On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.

[...]

> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,

[...]

> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:14     ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 13:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, Frank Rowand, linux-acpi,
	Jiri Slaby, Pierre-Louis Bossart, Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, Wolfram Sang, Vinod Koul, Stefan Richter,
	Sakari Ailus, Yehezkel Bernat, Sanyog Kale, linux-media,
	linux-usb

Hi,

On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.

[...]

> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,

[...]

> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 13:14     ` Maximilian Luz
  (?)
@ 2022-11-23 13:34       ` Andy Shevchenko
  -1 siblings, 0 replies; 103+ messages in thread
From: Andy Shevchenko @ 2022-11-23 13:34 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Greg Kroah-Hartman, linux-kernel, Jens Axboe, Rafael J. Wysocki,
	Len Brown, Stefan Richter, Wolfram Sang, Alexandre Belloni,
	Dmitry Torokhov, Sean Young, Mauro Carvalho Chehab, Rob Herring,
	Frank Rowand, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Jason Gunthorpe, Thomas Gleixner,
	Ira Weiny, Dan Williams, Won Chung, alsa-devel, devicetree,
	linux-acpi, linux-block, linux-i2c, linux-i3c, linux-input,
	linux-media, linux-serial, linux-usb, linux1394-devel,
	platform-driver-x86

On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.

[...]

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

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.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:34       ` Andy Shevchenko
  0 siblings, 0 replies; 103+ messages in thread
From: Andy Shevchenko @ 2022-11-23 13:34 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Greg Kroah-Hartman, linux-kernel, Jens Axboe, Rafael J. Wysocki,
	Len Brown, Stefan Richter, Wolfram Sang, Alexandre Belloni,
	Dmitry Torokhov, Sean Young, Mauro Carvalho Chehab, Rob Herring,
	Frank Rowand, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Jason Gunthorpe, Thomas Gleixner,
	Ira Weiny, Dan Williams, Won Chung, alsa-devel, devicetree,
	linux-acpi, linux-block, linux-i2c, linux-i3c, linux-input,
	linux-media, linux-serial, linux-usb, linux1394-devel,
	platform-driver-x86

On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.

[...]

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

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.

-- 
With Best Regards,
Andy Shevchenko



-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:34       ` Andy Shevchenko
  0 siblings, 0 replies; 103+ messages in thread
From: Andy Shevchenko @ 2022-11-23 13:34 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, linux-acpi, Frank Rowand, Pierre-Louis Bossart,
	Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab,
	Mika Westerberg, Jens Axboe, linux-block, Jilin Yuan,
	Martin K. Petersen, Greg Kroah-Hartman, Dmitry Torokhov,
	linux-kernel, Wolfram Sang, Vinod Koul, Stefan Richter,
	Sakari Ailus, Yehezkel Bernat, Sanyog Kale, linux-media,
	linux-usb

On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.

[...]

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

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.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 5/5] driver core: device_get_devnode() should take a const *
  2022-11-23 12:25 ` [PATCH 5/5] driver core: device_get_devnode() should " Greg Kroah-Hartman
  2022-11-23 12:39   ` Rafael J. Wysocki
@ 2022-11-23 13:36   ` Andy Shevchenko
  2023-01-11  9:47     ` Greg Kroah-Hartman
  1 sibling, 1 reply; 103+ messages in thread
From: Andy Shevchenko @ 2022-11-23 13:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Rafael J. Wysocki, Thomas Gleixner,
	Jason Gunthorpe, Ira Weiny, Dan Williams, Won Chung

On Wed, Nov 23, 2022 at 01:25:23PM +0100, Greg Kroah-Hartman wrote:
> 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 of device.h as it does not need to be exposed to
> the whole kernel tree.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

(see one nit-pick below)

> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/base/base.h    | 2 ++
>  drivers/base/core.c    | 2 +-
>  include/linux/device.h | 2 --
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/base.h b/drivers/base/base.h
> index 7d4803c03d3e..a8a119c36bdc 100644
> --- a/drivers/base/base.h
> +++ b/drivers/base/base.h
> @@ -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.

> +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;
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index a3e14143ec0c..72ec54a8a4e1 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -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)
>  {
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 4ad1280713e6..e4498389e866 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 12:25   ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 13:56     ` Mika Westerberg
  -1 siblings, 0 replies; 103+ messages in thread
From: Mika Westerberg @ 2022-11-23 13:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:25:21PM +0100, Greg Kroah-Hartman wrote:
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:56     ` Mika Westerberg
  0 siblings, 0 replies; 103+ messages in thread
From: Mika Westerberg @ 2022-11-23 13:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:25:21PM +0100, Greg Kroah-Hartman wrote:
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:56     ` Mika Westerberg
  0 siblings, 0 replies; 103+ messages in thread
From: Mika Westerberg @ 2022-11-23 13:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab, Jens Axboe,
	linux-block, Jilin Yuan, Martin K. Petersen, Dmitry Torokhov,
	linux-kernel, Wolfram Sang, Vinod Koul, Stefan Richter,
	Sakari Ailus, Yehezkel Bernat, Sanyog Kale, linux-media,
	Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 01:25:21PM +0100, Greg Kroah-Hartman wrote:
> The uevent() callback in struct device_type should not be modifying the
> device that is passed into it, so mark it as a const * and propagate the
> function signature changes out into all relevant subsystems that use
> this callback.
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 13:34       ` Andy Shevchenko
  (?)
@ 2022-11-23 13:59         ` Maximilian Luz
  -1 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 13:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Jens Axboe, Rafael J. Wysocki,
	Len Brown, Stefan Richter, Wolfram Sang, Alexandre Belloni,
	Dmitry Torokhov, Sean Young, Mauro Carvalho Chehab, Rob Herring,
	Frank Rowand, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Jason Gunthorpe, Thomas Gleixner,
	Ira Weiny, Dan Williams, Won Chung, alsa-devel, devicetree,
	linux-acpi, linux-block, linux-i2c, linux-i3c, linux-input,
	linux-media, linux-serial, linux-usb, linux1394-devel,
	platform-driver-x86

On 11/23/22 14:34, Andy Shevchenko wrote:
> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>> The uevent() callback in struct device_type should not be modifying the
>>> device that is passed into it, so mark it as a const * and propagate the
>>> function signature changes out into all relevant subsystems that use
>>> this callback.
> 
> [...]
> 
>>> -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.
> 
> 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.

Thanks! I assume you are referring to the following?

	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:59         ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 13:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, linux-kernel, Jens Axboe, Rafael J. Wysocki,
	Len Brown, Stefan Richter, Wolfram Sang, Alexandre Belloni,
	Dmitry Torokhov, Sean Young, Mauro Carvalho Chehab, Rob Herring,
	Frank Rowand, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Jason Gunthorpe, Thomas Gleixner,
	Ira Weiny, Dan Williams, Won Chung, alsa-devel, devicetree,
	linux-acpi, linux-block, linux-i2c, linux-i3c, linux-input,
	linux-media, linux-serial, linux-usb, linux1394-devel,
	platform-driver-x86

On 11/23/22 14:34, Andy Shevchenko wrote:
> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>> The uevent() callback in struct device_type should not be modifying the
>>> device that is passed into it, so mark it as a const * and propagate the
>>> function signature changes out into all relevant subsystems that use
>>> this callback.
> 
> [...]
> 
>>> -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.
> 
> 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.

Thanks! I assume you are referring to the following?

	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 13:59         ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 13:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, linux-acpi, Frank Rowand, Pierre-Louis Bossart,
	Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab,
	Mika Westerberg, Jens Axboe, linux-block, Jilin Yuan,
	Martin K. Petersen, Greg Kroah-Hartman, Dmitry Torokhov,
	linux-kernel, Wolfram Sang, Vinod Koul, Stefan Richter,
	Sakari Ailus, Yehezkel Bernat, Sanyog Kale, linux-media,
	linux-usb

On 11/23/22 14:34, Andy Shevchenko wrote:
> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>> The uevent() callback in struct device_type should not be modifying the
>>> device that is passed into it, so mark it as a const * and propagate the
>>> function signature changes out into all relevant subsystems that use
>>> this callback.
> 
> [...]
> 
>>> -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.
> 
> 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.

Thanks! I assume you are referring to the following?

	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 13:59         ` Maximilian Luz
  (?)
@ 2022-11-23 14:52           ` Matthew Wilcox
  -1 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 14:52 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> On 11/23/22 14:34, Andy Shevchenko wrote:
> > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > The uevent() callback in struct device_type should not be modifying the
> > > > device that is passed into it, so mark it as a const * and propagate the
> > > > function signature changes out into all relevant subsystems that use
> > > > this callback.
> > 
> > [...]
> > 
> > > > -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.
> > 
> > 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.
> 
> Thanks! I assume you are referring to the following?
> 
> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.

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);
}


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 14:52           ` Matthew Wilcox
  0 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 14:52 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> On 11/23/22 14:34, Andy Shevchenko wrote:
> > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > The uevent() callback in struct device_type should not be modifying the
> > > > device that is passed into it, so mark it as a const * and propagate the
> > > > function signature changes out into all relevant subsystems that use
> > > > this callback.
> > 
> > [...]
> > 
> > > > -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.
> > 
> > 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.
> 
> Thanks! I assume you are referring to the following?
> 
> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.

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);
}


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 14:52           ` Matthew Wilcox
  0 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 14:52 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Jason Gunthorpe, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, linux-usb

On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> On 11/23/22 14:34, Andy Shevchenko wrote:
> > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > The uevent() callback in struct device_type should not be modifying the
> > > > device that is passed into it, so mark it as a const * and propagate the
> > > > function signature changes out into all relevant subsystems that use
> > > > this callback.
> > 
> > [...]
> > 
> > > > -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.
> > 
> > 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.
> 
> Thanks! I assume you are referring to the following?
> 
> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.

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);
}


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 14:52           ` Matthew Wilcox
  (?)
@ 2022-11-23 15:14             ` Maximilian Luz
  -1 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 15:14 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On 11/23/22 15:52, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
>> On 11/23/22 14:34, Andy Shevchenko wrote:
>>> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>>>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>>>> The uevent() callback in struct device_type should not be modifying the
>>>>> device that is passed into it, so mark it as a const * and propagate the
>>>>> function signature changes out into all relevant subsystems that use
>>>>> this callback.
>>>
>>> [...]
>>>
>>>>> -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.
>>>
>>> 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.
>>
>> Thanks! I assume you are referring to the following?
>>
>> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:14             ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 15:14 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Andy Shevchenko, Greg Kroah-Hartman, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On 11/23/22 15:52, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
>> On 11/23/22 14:34, Andy Shevchenko wrote:
>>> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>>>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>>>> The uevent() callback in struct device_type should not be modifying the
>>>>> device that is passed into it, so mark it as a const * and propagate the
>>>>> function signature changes out into all relevant subsystems that use
>>>>> this callback.
>>>
>>> [...]
>>>
>>>>> -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.
>>>
>>> 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.
>>
>> Thanks! I assume you are referring to the following?
>>
>> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> 
> 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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:14             ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 15:14 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Jason Gunthorpe, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, linux-usb

On 11/23/22 15:52, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
>> On 11/23/22 14:34, Andy Shevchenko wrote:
>>> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>>>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>>>> The uevent() callback in struct device_type should not be modifying the
>>>>> device that is passed into it, so mark it as a const * and propagate the
>>>>> function signature changes out into all relevant subsystems that use
>>>>> this callback.
>>>
>>> [...]
>>>
>>>>> -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.
>>>
>>> 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.
>>
>> Thanks! I assume you are referring to the following?
>>
>> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 14:52           ` Matthew Wilcox
  (?)
@ 2022-11-23 15:37             ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 15:37 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Maximilian Luz, Andy Shevchenko, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> > On 11/23/22 14:34, Andy Shevchenko wrote:
> > > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > > The uevent() callback in struct device_type should not be modifying the
> > > > > device that is passed into it, so mark it as a const * and propagate the
> > > > > function signature changes out into all relevant subsystems that use
> > > > > this callback.
> > > 
> > > [...]
> > > 
> > > > > -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.
> > > 
> > > 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.
> > 
> > Thanks! I assume you are referring to the following?
> > 
> > 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> 
> 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




^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:37             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 15:37 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Maximilian Luz, Andy Shevchenko, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> > On 11/23/22 14:34, Andy Shevchenko wrote:
> > > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > > The uevent() callback in struct device_type should not be modifying the
> > > > > device that is passed into it, so mark it as a const * and propagate the
> > > > > function signature changes out into all relevant subsystems that use
> > > > > this callback.
> > > 
> > > [...]
> > > 
> > > > > -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.
> > > 
> > > 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.
> > 
> > Thanks! I assume you are referring to the following?
> > 
> > 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> 
> 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




-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:37             ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 15:37 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, linux-acpi, Bard Liao,
	Pierre-Louis Bossart, Jason Gunthorpe, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> > On 11/23/22 14:34, Andy Shevchenko wrote:
> > > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > > The uevent() callback in struct device_type should not be modifying the
> > > > > device that is passed into it, so mark it as a const * and propagate the
> > > > > function signature changes out into all relevant subsystems that use
> > > > > this callback.
> > > 
> > > [...]
> > > 
> > > > > -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.
> > > 
> > > 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.
> > 
> > Thanks! I assume you are referring to the following?
> > 
> > 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> 
> 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




^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 15:37             ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 15:48               ` Maximilian Luz
  -1 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 15:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Matthew Wilcox
  Cc: Andy Shevchenko, linux-kernel, Jens Axboe, Rafael J. Wysocki,
	Len Brown, Stefan Richter, Wolfram Sang, Alexandre Belloni,
	Dmitry Torokhov, Sean Young, Mauro Carvalho Chehab, Rob Herring,
	Frank Rowand, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Jason Gunthorpe, Thomas Gleixner,
	Ira Weiny, Dan Williams, Won Chung, alsa-devel, devicetree,
	linux-acpi, linux-block, linux-i2c, linux-i3c, linux-input,
	linux-media, linux-serial, linux-usb, linux1394-devel,
	platform-driver-x86

On 11/23/22 16:37, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
>> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
>>> On 11/23/22 14:34, Andy Shevchenko wrote:
>>>> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>>>>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>>>>> The uevent() callback in struct device_type should not be modifying the
>>>>>> device that is passed into it, so mark it as a const * and propagate the
>>>>>> function signature changes out into all relevant subsystems that use
>>>>>> this callback.
>>>>
>>>> [...]
>>>>
>>>>>> -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.
>>>>
>>>> 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.
>>>
>>> Thanks! I assume you are referring to the following?
>>>
>>> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
>>
>> 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?

That looks great! Thanks!

I would very much prefer that.

Regards,
Max

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:48               ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 15:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Matthew Wilcox
  Cc: Andy Shevchenko, linux-kernel, Jens Axboe, Rafael J. Wysocki,
	Len Brown, Stefan Richter, Wolfram Sang, Alexandre Belloni,
	Dmitry Torokhov, Sean Young, Mauro Carvalho Chehab, Rob Herring,
	Frank Rowand, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Jason Gunthorpe, Thomas Gleixner,
	Ira Weiny, Dan Williams, Won Chung, alsa-devel, devicetree,
	linux-acpi, linux-block, linux-i2c, linux-i3c, linux-input,
	linux-media, linux-serial, linux-usb, linux1394-devel,
	platform-driver-x86

On 11/23/22 16:37, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
>> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
>>> On 11/23/22 14:34, Andy Shevchenko wrote:
>>>> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>>>>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>>>>> The uevent() callback in struct device_type should not be modifying the
>>>>>> device that is passed into it, so mark it as a const * and propagate the
>>>>>> function signature changes out into all relevant subsystems that use
>>>>>> this callback.
>>>>
>>>> [...]
>>>>
>>>>>> -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.
>>>>
>>>> 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.
>>>
>>> Thanks! I assume you are referring to the following?
>>>
>>> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
>>
>> 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?

That looks great! Thanks!

I would very much prefer that.

Regards,
Max

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:48               ` Maximilian Luz
  0 siblings, 0 replies; 103+ messages in thread
From: Maximilian Luz @ 2022-11-23 15:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Matthew Wilcox
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Jason Gunthorpe, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, linux-usb

On 11/23/22 16:37, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
>> On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
>>> On 11/23/22 14:34, Andy Shevchenko wrote:
>>>> On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
>>>>> On 11/23/22 13:25, Greg Kroah-Hartman wrote:
>>>>>> The uevent() callback in struct device_type should not be modifying the
>>>>>> device that is passed into it, so mark it as a const * and propagate the
>>>>>> function signature changes out into all relevant subsystems that use
>>>>>> this callback.
>>>>
>>>> [...]
>>>>
>>>>>> -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.
>>>>
>>>> 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.
>>>
>>> Thanks! I assume you are referring to the following?
>>>
>>> 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
>>
>> 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?

That looks great! Thanks!

I would very much prefer that.

Regards,
Max

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 15:48               ` Maximilian Luz
  (?)
@ 2022-11-23 15:52                 ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 15:52 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Matthew Wilcox, Andy Shevchenko, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 04:48:41PM +0100, Maximilian Luz wrote:
> On 11/23/22 16:37, Greg Kroah-Hartman wrote:
> > On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> > > > On 11/23/22 14:34, Andy Shevchenko wrote:
> > > > > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > > > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > > > > The uevent() callback in struct device_type should not be modifying the
> > > > > > > device that is passed into it, so mark it as a const * and propagate the
> > > > > > > function signature changes out into all relevant subsystems that use
> > > > > > > this callback.
> > > > > 
> > > > > [...]
> > > > > 
> > > > > > > -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.
> > > > > 
> > > > > 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.
> > > > 
> > > > Thanks! I assume you are referring to the following?
> > > > 
> > > > 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> > > 
> > > 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?
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:52                 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 15:52 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Matthew Wilcox, Andy Shevchenko, linux-kernel, Jens Axboe,
	Rafael J. Wysocki, Len Brown, Stefan Richter, Wolfram Sang,
	Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Jason Gunthorpe, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 04:48:41PM +0100, Maximilian Luz wrote:
> On 11/23/22 16:37, Greg Kroah-Hartman wrote:
> > On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> > > > On 11/23/22 14:34, Andy Shevchenko wrote:
> > > > > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > > > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > > > > The uevent() callback in struct device_type should not be modifying the
> > > > > > > device that is passed into it, so mark it as a const * and propagate the
> > > > > > > function signature changes out into all relevant subsystems that use
> > > > > > > this callback.
> > > > > 
> > > > > [...]
> > > > > 
> > > > > > > -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.
> > > > > 
> > > > > 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.
> > > > 
> > > > Thanks! I assume you are referring to the following?
> > > > 
> > > > 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> > > 
> > > 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?
> 
> 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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 15:52                 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 15:52 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Matthew Wilcox, Jason Gunthorpe,
	Alan Stern, linux-serial, linux-input, Won Chung, Len Brown,
	devicetree, Chaitanya Kulkarni, Ira Weiny, Michael Jamet,
	Ming Lei, Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, linux-usb

On Wed, Nov 23, 2022 at 04:48:41PM +0100, Maximilian Luz wrote:
> On 11/23/22 16:37, Greg Kroah-Hartman wrote:
> > On Wed, Nov 23, 2022 at 02:52:59PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 02:59:00PM +0100, Maximilian Luz wrote:
> > > > On 11/23/22 14:34, Andy Shevchenko wrote:
> > > > > On Wed, Nov 23, 2022 at 02:14:31PM +0100, Maximilian Luz wrote:
> > > > > > On 11/23/22 13:25, Greg Kroah-Hartman wrote:
> > > > > > > The uevent() callback in struct device_type should not be modifying the
> > > > > > > device that is passed into it, so mark it as a const * and propagate the
> > > > > > > function signature changes out into all relevant subsystems that use
> > > > > > > this callback.
> > > > > 
> > > > > [...]
> > > > > 
> > > > > > > -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.
> > > > > 
> > > > > 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.
> > > > 
> > > > Thanks! I assume you are referring to the following?
> > > > 
> > > > 	https://lore.kernel.org/lkml/4218173bd72b4f1899d4c41a8e251f0d@AcuMS.aculab.com/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.
> > > 
> > > 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?
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 15:37             ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 16:25               ` Jason Gunthorpe
  -1 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 16:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> 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?

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 16:25               ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 16:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> 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?

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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 16:25               ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 16:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, Bard Liao, Pierre-Louis Bossart,
	Matthew Wilcox, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> 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?

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 16:25               ` Jason Gunthorpe
  (?)
@ 2022-11-23 17:01                 ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 17:01 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 12:25:32PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> > 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?
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:01                 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 17:01 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 12:25:32PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> > 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?
> 
> 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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:01                 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 17:01 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, Bard Liao, Pierre-Louis Bossart,
	Matthew Wilcox, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 12:25:32PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> > 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?
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 17:01                 ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 17:29                   ` Jason Gunthorpe
  -1 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 17:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 06:01:47PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 12:25:32PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> > > 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?
> > 
> > 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:29                   ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 17:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 06:01:47PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 12:25:32PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> > > 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?
> > 
> > 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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:29                   ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 17:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, Bard Liao, Pierre-Louis Bossart,
	Matthew Wilcox, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 06:01:47PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 12:25:32PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 04:37:59PM +0100, Greg Kroah-Hartman wrote:
> > > 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?
> > 
> > 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 17:29                   ` Jason Gunthorpe
  (?)
@ 2022-11-23 17:49                     ` Matthew Wilcox
  -1 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 17:49 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Greg Kroah-Hartman, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> #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 ;-)

> #define kobj_to_dev(__kobj) \
> 	generic_container_of(struct kobject, __kobj, struct device, kobj)
> 
> Jason

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:49                     ` Matthew Wilcox
  0 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 17:49 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Greg Kroah-Hartman, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> #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 ;-)

> #define kobj_to_dev(__kobj) \
> 	generic_container_of(struct kobject, __kobj, struct device, kobj)
> 
> Jason

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:49                     ` Matthew Wilcox
  0 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 17:49 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, Frank Rowand,
	Pierre-Louis Bossart, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> #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 ;-)

> #define kobj_to_dev(__kobj) \
> 	generic_container_of(struct kobject, __kobj, struct device, kobj)
> 
> Jason

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 17:49                     ` Matthew Wilcox
  (?)
@ 2022-11-23 17:55                       ` Jason Gunthorpe
  -1 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 17:55 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Greg Kroah-Hartman, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > #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 ;-)

Aside from less letters, is their another benifit to using *(in) ?

Jason

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:55                       ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 17:55 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Greg Kroah-Hartman, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > #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 ;-)

Aside from less letters, is their another benifit to using *(in) ?

Jason

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 17:55                       ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 17:55 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, Frank Rowand,
	Pierre-Louis Bossart, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > #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 ;-)

Aside from less letters, is their another benifit to using *(in) ?

Jason

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 17:55                       ` Jason Gunthorpe
  (?)
@ 2022-11-23 18:00                         ` Matthew Wilcox
  -1 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 18:00 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Greg Kroah-Hartman, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > #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 ;-)
> 
> 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.

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 18:00                         ` Matthew Wilcox
  0 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 18:00 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Greg Kroah-Hartman, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > #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 ;-)
> 
> 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.

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 18:00                         ` Matthew Wilcox
  0 siblings, 0 replies; 103+ messages in thread
From: Matthew Wilcox @ 2022-11-23 18:00 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, Frank Rowand,
	Pierre-Louis Bossart, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > #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 ;-)
> 
> 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.

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 17:49                     ` Matthew Wilcox
  (?)
@ 2022-11-23 18:10                       ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 18:10 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Jason Gunthorpe, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > #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 ;-)

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 18:10                       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 18:10 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Jason Gunthorpe, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > #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 ;-)

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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 18:10                       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 18:10 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, linux-acpi, Bard Liao,
	Pierre-Louis Bossart, Jason Gunthorpe, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > #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 ;-)

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 18:10                       ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 18:25                         ` Jason Gunthorpe
  -1 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 18:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > #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 ;-)
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 18:25                         ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 18:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > #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 ;-)
> 
> 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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 18:25                         ` Jason Gunthorpe
  0 siblings, 0 replies; 103+ messages in thread
From: Jason Gunthorpe @ 2022-11-23 18:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, Bard Liao, Pierre-Louis Bossart,
	Matthew Wilcox, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > #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 ;-)
> 
> 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 18:25                         ` Jason Gunthorpe
  (?)
@ 2022-11-23 19:06                           ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 19:06 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 02:25:59PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #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 ;-)
> > 
> > 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.

I think we might be able to now, my previous attempts with inline
functions prevented that.  I'll beat on that tomorrow...

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

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 19:06                           ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 19:06 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Matthew Wilcox, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 02:25:59PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #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 ;-)
> > 
> > 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.

I think we might be able to now, my previous attempts with inline
functions prevented that.  I'll beat on that tomorrow...

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

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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 19:06                           ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-23 19:06 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, Bard Liao, Pierre-Louis Bossart,
	Matthew Wilcox, linux-acpi, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 02:25:59PM -0400, Jason Gunthorpe wrote:
> On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #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 ;-)
> > 
> > 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.

I think we might be able to now, my previous attempts with inline
functions prevented that.  I'll beat on that tomorrow...

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

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* RE: [PATCH 4/5] driver core: make struct device_type.devnode() take a const *
  2022-11-23 12:25 ` [PATCH 4/5] driver core: make struct device_type.devnode() " Greg Kroah-Hartman
@ 2022-11-23 19:23   ` Dan Williams
  2023-01-11  9:46     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 103+ messages in thread
From: Dan Williams @ 2022-11-23 19:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Greg Kroah-Hartman, Jens Axboe, Alison Schofield, Vishal Verma,
	Ira Weiny, Ben Widawsky, Dan Williams, Jeremy Kerr, Joel Stanley,
	Alistar Popple, Eddie James, Alexander Shishkin,
	Jonathan Cameron, Jilin Yuan, Heikki Krogerus, Alan Stern,
	Andy Shevchenko, Thomas Gleixner, Jason Gunthorpe,
	Rafael J. Wysocki, Won Chung, linux-block, linux-cxl, linux-fsi,
	linux-usb

Greg Kroah-Hartman wrote:
> The 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.
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Jeremy Kerr <jk@ozlabs.org>
> Cc: Joel Stanley <joel@jms.id.au>
> Cc: Alistar Popple <alistair@popple.id.au>
> Cc: Eddie James <eajames@linux.ibm.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: linux-block@vger.kernel.org
> Cc: linux-cxl@vger.kernel.org
> Cc: linux-fsi@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[..]
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index 20ce488a7754..6ae8d0bdc61b 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -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:

Acked-by: Dan Williams <dan.j.williams@intel.com>

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 19:06                           ` Greg Kroah-Hartman
  (?)
@ 2022-11-23 23:24                             ` Barnabás Pőcze
  -1 siblings, 0 replies; 103+ messages in thread
From: Barnabás Pőcze @ 2022-11-23 23:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jason Gunthorpe, Matthew Wilcox, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86


Hi


2022. november 23., szerda 20:06 keltezéssel, Greg Kroah-Hartman írta:


> On Wed, Nov 23, 2022 at 02:25:59PM -0400, Jason Gunthorpe wrote:
> 
> > On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> > 
> > > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > 
> > > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > 
> > > > > #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 ;-)
> > > 
> > > 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.
> 
> 
> I think we might be able to now, my previous attempts with inline
> functions prevented that. I'll beat on that tomorrow...
> 
> > 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..
> 
> 
> 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.


> [...]


Regards,
Barnabás Pőcze

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 23:24                             ` Barnabás Pőcze
  0 siblings, 0 replies; 103+ messages in thread
From: Barnabás Pőcze @ 2022-11-23 23:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jason Gunthorpe, Matthew Wilcox, Maximilian Luz, Andy Shevchenko,
	linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Sakari Ailus, Thomas Gleixner, Ira Weiny,
	Dan Williams, Won Chung, alsa-devel, devicetree, linux-acpi,
	linux-block, linux-i2c, linux-i3c, linux-input, linux-media,
	linux-serial, linux-usb, linux1394-devel, platform-driver-x86


Hi


2022. november 23., szerda 20:06 keltezéssel, Greg Kroah-Hartman írta:


> On Wed, Nov 23, 2022 at 02:25:59PM -0400, Jason Gunthorpe wrote:
> 
> > On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> > 
> > > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > 
> > > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > 
> > > > > #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 ;-)
> > > 
> > > 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.
> 
> 
> I think we might be able to now, my previous attempts with inline
> functions prevented that. I'll beat on that tomorrow...
> 
> > 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..
> 
> 
> 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.


> [...]


Regards,
Barnabás Pőcze

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-23 23:24                             ` Barnabás Pőcze
  0 siblings, 0 replies; 103+ messages in thread
From: Barnabás Pőcze @ 2022-11-23 23:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, linux-acpi, Bard Liao,
	Pierre-Louis Bossart, Matthew Wilcox, Jason Gunthorpe,
	Alan Stern, linux-serial, linux-input, Won Chung, Len Brown,
	devicetree, Chaitanya Kulkarni, Ira Weiny, Michael Jamet,
	Ming Lei, Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb


Hi


2022. november 23., szerda 20:06 keltezéssel, Greg Kroah-Hartman írta:


> On Wed, Nov 23, 2022 at 02:25:59PM -0400, Jason Gunthorpe wrote:
> 
> > On Wed, Nov 23, 2022 at 07:10:49PM +0100, Greg Kroah-Hartman wrote:
> > 
> > > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > 
> > > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > 
> > > > > #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 ;-)
> > > 
> > > 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.
> 
> 
> I think we might be able to now, my previous attempts with inline
> functions prevented that. I'll beat on that tomorrow...
> 
> > 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..
> 
> 
> 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.


> [...]


Regards,
Barnabás Pőcze

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2022-11-23 12:38 ` [PATCH 1/5] driver core: make struct class.dev_uevent() " Rafael J. Wysocki
@ 2022-11-24 15:03 ` Sebastian Reichel
  2022-11-25 11:54 ` Mauro Carvalho Chehab
  2022-11-25 23:51 ` Bart Van Assche
  7 siblings, 0 replies; 103+ messages in thread
From: Sebastian Reichel @ 2022-11-24 15:03 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Mauro Carvalho Chehab,
	Keith Busch, Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Johannes Berg, Wolfram Sang, Raed Salem, Chen Zhongjin,
	Tetsuo Handa, Avihai Horon, Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

[-- Attachment #1: Type: text/plain, Size: 15799 bytes --]

Hi,

On Wed, Nov 23, 2022 at 01:25:19PM +0100, Greg Kroah-Hartman wrote:
> 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 <axboe@kernel.dk>
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Russ Weight <russell.h.weight@intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Karsten Keil <isdn@linux-pingi.de>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: Raed Salem <raeds@nvidia.com>
> Cc: Chen Zhongjin <chenzhongjin@huawei.com>
> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Cc: Avihai Horon <avihaih@nvidia.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Colin Ian King <colin.i.king@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Jakob Koschel <jakobkoschel@gmail.com>
> Cc: Antoine Tenart <atenart@kernel.org>
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: Wang Yufen <wangyufen@huawei.com>
> Cc: linux-block@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-nvme@lists.infradead.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---

Acked-by: Sebastian Reichel <sre@kernel.org>

-- Sebastian

>  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(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 0f9769db2de8..3f1124713442 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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);
>  }
> diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
> index 5b66b3d1fa16..56911d75b90a 100644
> --- a/drivers/base/firmware_loader/sysfs.c
> +++ b/drivers/base/firmware_loader/sysfs.c
> @@ -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_env
>  	return 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);
> diff --git a/drivers/base/firmware_loader/sysfs.h b/drivers/base/firmware_loader/sysfs.h
> index df1d5add698f..fd0b4ad9bdbb 100644
> --- a/drivers/base/firmware_loader/sysfs.h
> +++ b/drivers/base/firmware_loader/sysfs.h
> @@ -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);
>  }
> diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
> index 940ddf916202..5f3a3e913d28 100644
> --- a/drivers/firmware/dmi-id.c
> +++ b/drivers/firmware/dmi-id.c
> @@ -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;
>  
> diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
> index 1e82b7967570..77a4b280c552 100644
> --- a/drivers/gnss/core.c
> +++ b/drivers/gnss/core.c
> @@ -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));
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index fa65c5d3d395..4186dbf9377f 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -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)))
> diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
> index 90ee56d07a6e..9120be590325 100644
> --- a/drivers/isdn/mISDN/core.c
> +++ b/drivers/isdn/mISDN/core.c
> @@ -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;
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 675d877a67b2..6ef18bab9648 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -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]);
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index da55ce45ac70..b4778b970dd4 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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;
> diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
> index f70197154a36..e3224e49c43f 100644
> --- a/drivers/pcmcia/cs.c
> +++ b/drivers/pcmcia/cs.c
> @@ -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;
> diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
> index c310d4f36c10..645eee4d6b6a 100644
> --- a/drivers/power/supply/power_supply.h
> +++ b/drivers/power/supply/power_supply.h
> @@ -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
>  
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 5369abaceb5c..6ca7d3985a40 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -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;
>  
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index c63c0c2cf649..b5994a0604f6 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -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);
> diff --git a/include/linux/device/class.h b/include/linux/device/class.h
> index 20103e0b03c3..94b1107258e5 100644
> --- a/include/linux/device/class.h
> +++ b/include/linux/device/class.h
> @@ -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);
> diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
> index 7dd1f01ec4f9..7aab4a769736 100644
> --- a/include/linux/mISDNif.h
> +++ b/include/linux/mISDNif.h
> @@ -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);
> diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
> index 0fdbdfd19474..466353b3dde4 100644
> --- a/net/atm/atm_sysfs.c
> +++ b/net/atm/atm_sysfs.c
> @@ -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;
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 9cfc80b8ed25..03a61d1dffbd 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -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. */
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index dac4fdc7488a..b390ff245d5e 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -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
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2022-11-24 15:03 ` Sebastian Reichel
@ 2022-11-25 11:54 ` Mauro Carvalho Chehab
  2022-11-25 23:51 ` Bart Van Assche
  7 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Keith Busch, Christoph Hellwig,
	Sagi Grimberg, Dominik Brodowski, Sebastian Reichel,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Johannes Berg, Wolfram Sang, Raed Salem, Chen Zhongjin,
	Tetsuo Handa, Avihai Horon, Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

Em Wed, 23 Nov 2022 13:25:19 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:

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

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Russ Weight <russell.h.weight@intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Jean Delvare <jdelvare@suse.com>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Karsten Keil <isdn@linux-pingi.de>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Keith Busch <kbusch@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Sagi Grimberg <sagi@grimberg.me>
> Cc: Dominik Brodowski <linux@dominikbrodowski.net>
> Cc: Sebastian Reichel <sre@kernel.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Cc: Raed Salem <raeds@nvidia.com>
> Cc: Chen Zhongjin <chenzhongjin@huawei.com>
> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Cc: Avihai Horon <avihaih@nvidia.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Colin Ian King <colin.i.king@gmail.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Cc: Jakob Koschel <jakobkoschel@gmail.com>
> Cc: Antoine Tenart <atenart@kernel.org>
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: Wang Yufen <wangyufen@huawei.com>
> Cc: linux-block@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-nvme@lists.infradead.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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(-)
> 
> diff --git a/block/genhd.c b/block/genhd.c
> index 0f9769db2de8..3f1124713442 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -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);
>  }
> diff --git a/drivers/base/firmware_loader/sysfs.c b/drivers/base/firmware_loader/sysfs.c
> index 5b66b3d1fa16..56911d75b90a 100644
> --- a/drivers/base/firmware_loader/sysfs.c
> +++ b/drivers/base/firmware_loader/sysfs.c
> @@ -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_env
>  	return 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);
> diff --git a/drivers/base/firmware_loader/sysfs.h b/drivers/base/firmware_loader/sysfs.h
> index df1d5add698f..fd0b4ad9bdbb 100644
> --- a/drivers/base/firmware_loader/sysfs.h
> +++ b/drivers/base/firmware_loader/sysfs.h
> @@ -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);
>  }
> diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
> index 940ddf916202..5f3a3e913d28 100644
> --- a/drivers/firmware/dmi-id.c
> +++ b/drivers/firmware/dmi-id.c
> @@ -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;
>  
> diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
> index 1e82b7967570..77a4b280c552 100644
> --- a/drivers/gnss/core.c
> +++ b/drivers/gnss/core.c
> @@ -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));
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index fa65c5d3d395..4186dbf9377f 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -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)))
> diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
> index 90ee56d07a6e..9120be590325 100644
> --- a/drivers/isdn/mISDN/core.c
> +++ b/drivers/isdn/mISDN/core.c
> @@ -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;
> diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
> index 675d877a67b2..6ef18bab9648 100644
> --- a/drivers/media/dvb-core/dvbdev.c
> +++ b/drivers/media/dvb-core/dvbdev.c
> @@ -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]);
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index da55ce45ac70..b4778b970dd4 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -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;
> diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
> index f70197154a36..e3224e49c43f 100644
> --- a/drivers/pcmcia/cs.c
> +++ b/drivers/pcmcia/cs.c
> @@ -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;
> diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
> index c310d4f36c10..645eee4d6b6a 100644
> --- a/drivers/power/supply/power_supply.h
> +++ b/drivers/power/supply/power_supply.h
> @@ -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
>  
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 5369abaceb5c..6ca7d3985a40 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -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;
>  
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index c63c0c2cf649..b5994a0604f6 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -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);
> diff --git a/include/linux/device/class.h b/include/linux/device/class.h
> index 20103e0b03c3..94b1107258e5 100644
> --- a/include/linux/device/class.h
> +++ b/include/linux/device/class.h
> @@ -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);
> diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
> index 7dd1f01ec4f9..7aab4a769736 100644
> --- a/include/linux/mISDNif.h
> +++ b/include/linux/mISDNif.h
> @@ -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);
> diff --git a/net/atm/atm_sysfs.c b/net/atm/atm_sysfs.c
> index 0fdbdfd19474..466353b3dde4 100644
> --- a/net/atm/atm_sysfs.c
> +++ b/net/atm/atm_sysfs.c
> @@ -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;
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 9cfc80b8ed25..03a61d1dffbd 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -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. */
> diff --git a/net/rfkill/core.c b/net/rfkill/core.c
> index dac4fdc7488a..b390ff245d5e 100644
> --- a/net/rfkill/core.c
> +++ b/net/rfkill/core.c
> @@ -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;

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
  2022-11-23 12:25   ` Greg Kroah-Hartman
  (?)
@ 2022-11-25 11:55     ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Fenghua Yu, Reinette Chatre, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	FUJITA Tomonori, Jens Axboe, Justin Sanders, Arnd Bergmann,
	Sumit Semwal, Benjamin Gaignard, Liam Mark, Laura Abbott,
	Brian Starkey, John Stultz, Christian König,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Jason Gunthorpe, Leon Romanovsky,
	Dennis Dalessandro, Dmitry Torokhov, Sean Young, Frank Haverkamp,
	Jiri Slaby, Michael S. Tsirkin, Jason Wang, Alex Williamson,
	Cornelia Huck, Kees Cook, Anton Vorontsov, Colin Cross,
	Tony Luck, Jaroslav Kysela, Takashi Iwai, Hans Verkuil,
	Christophe JAILLET, Xie Yongji, Gautam Dawar, Dan Carpenter,
	Eli Cohen, Parav Pandit, Maxime Coquelin, alsa-devel, dri-devel,
	kvm, linaro-mm-sig, linux-block, linux-input, linux-media,
	linux-rdma, linux-scsi, linux-usb, virtualization

Em Wed, 23 Nov 2022 13:25:20 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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 <mchehab@kernel.org>
> 
> 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
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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;

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-25 11:55     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Jason Wang, Dave Hansen, dri-devel,
	Jaroslav Kysela, John Stultz, H. Peter Anvin, Eli Cohen,
	Sumit Semwal, Kees Cook, Parav Pandit, Benjamin Gaignard, kvm,
	Leon Romanovsky, Dennis Dalessandro, linux-rdma, Jiri Slaby, x86,
	Frank Haverkamp, Dan Carpenter, Jason Gunthorpe, Ingo Molnar,
	linux-input, Laura Abbott, virtualization, linux-media,
	Fenghua Yu, Arnd Bergmann, Colin Cross, linaro-mm-sig,
	Gautam Dawar, Alex Williamson, Borislav Petkov, Takashi Iwai,
	Thomas Gleixner, Reinette Chatre, Jens Axboe, linux-block,
	Tony Luck, linux-scsi, Dmitry Torokhov, linux-kernel, Liam Mark,
	FUJITA Tomonori, Xie Yongji, Maxime Coquelin, linux-usb,
	Thomas Zimmermann, Cornelia Huck, Hans Verkuil,
	Christophe JAILLET, Christian König

Em Wed, 23 Nov 2022 13:25:20 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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 <mchehab@kernel.org>
> 
> 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
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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;

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-25 11:55     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Jason Wang, Dave Hansen, dri-devel,
	John Stultz, H. Peter Anvin, Eli Cohen, David Airlie,
	Sumit Semwal, Kees Cook, Parav Pandit, Benjamin Gaignard, kvm,
	Leon Romanovsky, Dennis Dalessandro, linux-rdma, Jiri Slaby, x86,
	Frank Haverkamp, Dan Carpenter, Jason Gunthorpe, Ingo Molnar,
	linux-input, Laura Abbott, virtualization, linux-media,
	Fenghua Yu, Daniel Vetter, Arnd Bergmann, Colin Cross,
	Maarten Lankhorst, Maxime Ripard, linaro-mm-sig, Gautam Dawar,
	Alex Williamson, Borislav Petkov, Takashi Iwai, Thomas Gleixner,
	Reinette Chatre, Jens Axboe, linux-block, Tony Luck, linux-scsi,
	Dmitry Torokhov, linux-kernel, Liam Mark, Brian Starkey,
	FUJITA Tomonori, Xie Yongji, Maxime Coquelin, linux-usb,
	Thomas Zimmermann, Cornelia Huck, Hans Verkuil,
	Christophe JAILLET, Christian König

Em Wed, 23 Nov 2022 13:25:20 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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 <mchehab@kernel.org>
> 
> 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
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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;

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 12:25   ` Greg Kroah-Hartman
  (?)
@ 2022-11-25 11:56     ` Mauro Carvalho Chehab
  -1 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Rob Herring, Frank Rowand, Maximilian Luz,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

Em Wed, 23 Nov 2022 13:25:21 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:

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

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Chaitanya Kulkarni <kch@nvidia.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: alsa-devel@alsa-project.org
> Cc: devicetree@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-i3c@lists.infradead.org
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux1394-devel@lists.sourceforge.net
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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(-)
> 
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index b8112f52d388..7b8ef6296abd 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -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])
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 120873dad2cc..daff2c0c5c52 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 219c02df9a08..d422884eb3d0 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -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);
>  
>  /* --------------------------------------------------------------------------
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
> index adddd8c45d0c..aa597cda0d88 100644
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -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));
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index b4edf10e8fd0..fb16e33e52c6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
> index e92d3e9a52bd..05f8ab762e34 100644
> --- a/drivers/i3c/device.c
> +++ b/drivers/i3c/device.c
> @@ -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);
>  }
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 351c81a929a6..bf1a2b2f34c4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -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;
>  
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 50597165dc54..a612afffa196 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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,
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 527d9324742b..6bdad6341844 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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;
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index c674a13c3055..dda51b7ce597 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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;
>  
> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 04b3529f8929..26c9a0a85d49 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -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));
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 60da5c23ccaf..2f4ef156b210 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -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) {
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index f9786976f5ec..909da0a98134 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -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);
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index f00b2f62d8e3..aeb40a384bea 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -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));
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..aa80de3a8194 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -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;
>  
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 4d59d927ae3e..c397574a6570 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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);
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 11b15d7b357a..8527c06b65e6 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -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);
>  
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 1b24492bb4e5..4b468bde19cf 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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;
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index a3575a5a18ce..3708fb70b693 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -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;
>  
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index bd5e5dd70431..8e2b2077f262 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -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;
>  
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..fc956c3f8324 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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;
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 84ae52de6746..46093bae6905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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);
> diff --git a/include/linux/firewire.h b/include/linux/firewire.h
> index 980019053e54..4c882d57df02 100644
> --- a/include/linux/firewire.h
> +++ b/include/linux/firewire.h
> @@ -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);
>  }
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 8242e13e7b0b..cda61c1d6d60 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ab7d557d541d..f4b57614979d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -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;
> diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
> index 52eb66cd11bc..d8c27f1e5559 100644
> --- a/include/linux/soundwire/sdw_type.h
> +++ b/include/linux/soundwire/sdw_type.h
> @@ -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
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 46c45d1b6368..a5dff729edb7 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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);
>  }

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-25 11:56     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Rob Herring, Frank Rowand, Maximilian Luz,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

Em Wed, 23 Nov 2022 13:25:21 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:

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

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Chaitanya Kulkarni <kch@nvidia.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: alsa-devel@alsa-project.org
> Cc: devicetree@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-i3c@lists.infradead.org
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux1394-devel@lists.sourceforge.net
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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(-)
> 
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index b8112f52d388..7b8ef6296abd 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -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])
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 120873dad2cc..daff2c0c5c52 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 219c02df9a08..d422884eb3d0 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -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);
>  
>  /* --------------------------------------------------------------------------
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
> index adddd8c45d0c..aa597cda0d88 100644
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -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));
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index b4edf10e8fd0..fb16e33e52c6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
> index e92d3e9a52bd..05f8ab762e34 100644
> --- a/drivers/i3c/device.c
> +++ b/drivers/i3c/device.c
> @@ -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);
>  }
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 351c81a929a6..bf1a2b2f34c4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -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;
>  
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 50597165dc54..a612afffa196 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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,
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 527d9324742b..6bdad6341844 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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;
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index c674a13c3055..dda51b7ce597 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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;
>  
> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 04b3529f8929..26c9a0a85d49 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -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));
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 60da5c23ccaf..2f4ef156b210 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -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) {
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index f9786976f5ec..909da0a98134 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -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);
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index f00b2f62d8e3..aeb40a384bea 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -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));
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..aa80de3a8194 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -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;
>  
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 4d59d927ae3e..c397574a6570 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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);
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 11b15d7b357a..8527c06b65e6 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -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);
>  
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 1b24492bb4e5..4b468bde19cf 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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;
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index a3575a5a18ce..3708fb70b693 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -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;
>  
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index bd5e5dd70431..8e2b2077f262 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -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;
>  
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..fc956c3f8324 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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;
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 84ae52de6746..46093bae6905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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);
> diff --git a/include/linux/firewire.h b/include/linux/firewire.h
> index 980019053e54..4c882d57df02 100644
> --- a/include/linux/firewire.h
> +++ b/include/linux/firewire.h
> @@ -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);
>  }
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 8242e13e7b0b..cda61c1d6d60 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ab7d557d541d..f4b57614979d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -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;
> diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
> index 52eb66cd11bc..d8c27f1e5559 100644
> --- a/include/linux/soundwire/sdw_type.h
> +++ b/include/linux/soundwire/sdw_type.h
> @@ -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
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 46c45d1b6368..a5dff729edb7 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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);
>  }

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-11-25 11:56     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 103+ messages in thread
From: Mauro Carvalho Chehab @ 2022-11-25 11:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, linux-acpi, Frank Rowand, Pierre-Louis Bossart,
	Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Andy Shevchenko, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

Em Wed, 23 Nov 2022 13:25:21 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:

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

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Cc: Wolfram Sang <wsa@kernel.org>
> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Sean Young <sean@mess.org>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Maximilian Luz <luzmaximilian@gmail.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> Cc: Jiri Slaby <jirislaby@kernel.org>
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Chaitanya Kulkarni <kch@nvidia.com>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Won Chung <wonchung@google.com>
> Cc: alsa-devel@alsa-project.org
> Cc: devicetree@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-i3c@lists.infradead.org
> Cc: linux-input@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linux-serial@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: linux1394-devel@lists.sourceforge.net
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  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(-)
> 
> diff --git a/block/partitions/core.c b/block/partitions/core.c
> index b8112f52d388..7b8ef6296abd 100644
> --- a/block/partitions/core.c
> +++ b/block/partitions/core.c
> @@ -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])
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index 120873dad2cc..daff2c0c5c52 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
>  }
> diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
> index 219c02df9a08..d422884eb3d0 100644
> --- a/drivers/acpi/internal.h
> +++ b/drivers/acpi/internal.h
> @@ -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);
>  
>  /* --------------------------------------------------------------------------
> diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
> index adddd8c45d0c..aa597cda0d88 100644
> --- a/drivers/firewire/core-device.c
> +++ b/drivers/firewire/core-device.c
> @@ -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));
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index b4edf10e8fd0..fb16e33e52c6 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -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);
> diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
> index e92d3e9a52bd..05f8ab762e34 100644
> --- a/drivers/i3c/device.c
> +++ b/drivers/i3c/device.c
> @@ -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);
>  }
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 351c81a929a6..bf1a2b2f34c4 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -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;
>  
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 50597165dc54..a612afffa196 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -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,
> diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
> index 527d9324742b..6bdad6341844 100644
> --- a/drivers/media/rc/rc-main.c
> +++ b/drivers/media/rc/rc-main.c
> @@ -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;
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index c674a13c3055..dda51b7ce597 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -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;
>  
> diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c
> index de539938896e..407eb55050a6 100644
> --- a/drivers/platform/surface/aggregator/bus.c
> +++ b/drivers/platform/surface/aggregator/bus.c
> @@ -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,
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 04b3529f8929..26c9a0a85d49 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -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));
> diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
> index 60da5c23ccaf..2f4ef156b210 100644
> --- a/drivers/thunderbolt/switch.c
> +++ b/drivers/thunderbolt/switch.c
> @@ -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) {
> diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
> index f9786976f5ec..909da0a98134 100644
> --- a/drivers/thunderbolt/tb.h
> +++ b/drivers/thunderbolt/tb.h
> @@ -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);
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index f00b2f62d8e3..aeb40a384bea 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -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));
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..aa80de3a8194 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -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;
>  
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 4d59d927ae3e..c397574a6570 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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);
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 11b15d7b357a..8527c06b65e6 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -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);
>  
> diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
> index 1b24492bb4e5..4b468bde19cf 100644
> --- a/drivers/usb/phy/phy.c
> +++ b/drivers/usb/phy/phy.c
> @@ -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;
> diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
> index a3575a5a18ce..3708fb70b693 100644
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -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;
>  
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index bd5e5dd70431..8e2b2077f262 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -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;
>  
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..fc956c3f8324 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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;
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 84ae52de6746..46093bae6905 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -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);
> diff --git a/include/linux/firewire.h b/include/linux/firewire.h
> index 980019053e54..4c882d57df02 100644
> --- a/include/linux/firewire.h
> +++ b/include/linux/firewire.h
> @@ -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);
>  }
> diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h
> index 8242e13e7b0b..cda61c1d6d60 100644
> --- a/include/linux/i3c/device.h
> +++ b/include/linux/i3c/device.h
> @@ -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;
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index ab7d557d541d..f4b57614979d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -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;
> diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h
> index 52eb66cd11bc..d8c27f1e5559 100644
> --- a/include/linux/soundwire/sdw_type.h
> +++ b/include/linux/soundwire/sdw_type.h
> @@ -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
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 46c45d1b6368..a5dff729edb7 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -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);
>  }

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
  2022-11-25 11:55     ` Mauro Carvalho Chehab
  (?)
@ 2022-11-25 12:40       ` Sumit Semwal
  -1 siblings, 0 replies; 103+ messages in thread
From: Sumit Semwal @ 2022-11-25 12:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Greg Kroah-Hartman, linux-kernel, Fenghua Yu, Reinette Chatre,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, FUJITA Tomonori, Jens Axboe, Justin Sanders,
	Arnd Bergmann, Benjamin Gaignard, Liam Mark, Laura Abbott,
	Brian Starkey, John Stultz, Christian König,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Jason Gunthorpe, Leon Romanovsky,
	Dennis Dalessandro, Dmitry Torokhov, Sean Young, Frank Haverkamp,
	Jiri Slaby, Michael S. Tsirkin, Jason Wang, Alex Williamson,
	Cornelia Huck, Kees Cook, Anton Vorontsov, Colin Cross,
	Tony Luck, Jaroslav Kysela, Takashi Iwai, Hans Verkuil,
	Christophe JAILLET, Xie Yongji, Gautam Dawar, Dan Carpenter,
	Eli Cohen, Parav Pandit, Maxime Coquelin, alsa-devel, dri-devel,
	kvm, linaro-mm-sig, linux-block, linux-input, linux-media,
	linux-rdma, linux-scsi, linux-usb, virtualization

Hello Greg,

On Fri, 25 Nov 2022 at 17:25, Mauro Carvalho Chehab <mchehab@kernel.org> wrote:
>
> Em Wed, 23 Nov 2022 13:25:20 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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 <mchehab@kernel.org>
> >
Please feel free to add my
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
for the dma-buf portion.

Best,
Sumit.
> > 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
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-25 12:40       ` Sumit Semwal
  0 siblings, 0 replies; 103+ messages in thread
From: Sumit Semwal @ 2022-11-25 12:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Jason Wang, Dave Hansen, dri-devel,
	Jaroslav Kysela, John Stultz, H. Peter Anvin, Eli Cohen,
	Gautam Dawar, Kees Cook, Parav Pandit, Benjamin Gaignard, kvm,
	Leon Romanovsky, Dennis Dalessandro, linux-rdma, Jiri Slaby, x86,
	Frank Haverkamp, Dan Carpenter, Jason Gunthorpe, Ingo Molnar,
	linux-input, Laura Abbott, virtualization, linux-media,
	Fenghua Yu, Arnd Bergmann, Colin Cross, linaro-mm-sig,
	Alex Williamson, Borislav Petkov, Takashi Iwai, Thomas Gleixner,
	Reinette Chatre, Jens Axboe, linux-block, Tony Luck, linux-scsi,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Liam Mark,
	FUJITA Tomonori, Xie Yongji, Maxime Coquelin, linux-usb,
	Thomas Zimmermann, Cornelia Huck, Hans Verkuil,
	Christophe JAILLET, Christian König

Hello Greg,

On Fri, 25 Nov 2022 at 17:25, Mauro Carvalho Chehab <mchehab@kernel.org> wrote:
>
> Em Wed, 23 Nov 2022 13:25:20 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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 <mchehab@kernel.org>
> >
Please feel free to add my
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
for the dma-buf portion.

Best,
Sumit.
> > 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
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 2/5] driver core: make struct class.devnode() take a const *
@ 2022-11-25 12:40       ` Sumit Semwal
  0 siblings, 0 replies; 103+ messages in thread
From: Sumit Semwal @ 2022-11-25 12:40 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: alsa-devel, Justin Sanders, Anton Vorontsov, Sean Young,
	Michael S. Tsirkin, Jason Wang, Dave Hansen, dri-devel,
	John Stultz, H. Peter Anvin, Eli Cohen, David Airlie,
	Gautam Dawar, Kees Cook, Parav Pandit, Benjamin Gaignard, kvm,
	Leon Romanovsky, Dennis Dalessandro, linux-rdma, Jiri Slaby, x86,
	Frank Haverkamp, Dan Carpenter, Jason Gunthorpe, Ingo Molnar,
	linux-input, Laura Abbott, virtualization, linux-media,
	Fenghua Yu, Daniel Vetter, Arnd Bergmann, Colin Cross,
	Maarten Lankhorst, Maxime Ripard, linaro-mm-sig, Alex Williamson,
	Borislav Petkov, Takashi Iwai, Thomas Gleixner, Reinette Chatre,
	Jens Axboe, linux-block, Tony Luck, linux-scsi,
	Greg Kroah-Hartman, Dmitry Torokhov, linux-kernel, Liam Mark,
	Brian Starkey, FUJITA Tomonori, Xie Yongji, Maxime Coquelin,
	linux-usb, Thomas Zimmermann, Cornelia Huck, Hans Verkuil,
	Christophe JAILLET, Christian König

Hello Greg,

On Fri, 25 Nov 2022 at 17:25, Mauro Carvalho Chehab <mchehab@kernel.org> wrote:
>
> Em Wed, 23 Nov 2022 13:25:20 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> 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 <mchehab@kernel.org>
> >
Please feel free to add my
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
for the dma-buf portion.

Best,
Sumit.
> > 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
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2022-11-25 11:54 ` Mauro Carvalho Chehab
@ 2022-11-25 23:51 ` Bart Van Assche
  2022-11-27 13:45   ` Greg Kroah-Hartman
  7 siblings, 1 reply; 103+ messages in thread
From: Bart Van Assche @ 2022-11-25 23:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Jens Axboe, Luis Chamberlain, Russ Weight, Rafael J. Wysocki,
	Jean Delvare, Johan Hovold, Jason Gunthorpe, Leon Romanovsky,
	Karsten Keil, Mauro Carvalho Chehab, Keith Busch,
	Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	Sebastian Reichel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Johannes Berg, Wolfram Sang, Raed Salem,
	Chen Zhongjin, Tetsuo Handa, Avihai Horon,
	Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

On 11/23/22 04:25, Greg Kroah-Hartman wrote:
> diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
> index 7dd1f01ec4f9..7aab4a769736 100644
> --- a/include/linux/mISDNif.h
> +++ b/include/linux/mISDNif.h
> @@ -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.


^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-25 23:51 ` Bart Van Assche
@ 2022-11-27 13:45   ` Greg Kroah-Hartman
  2022-11-28  2:38     ` Bart Van Assche
  0 siblings, 1 reply; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-27 13:45 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-kernel, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Mauro Carvalho Chehab,
	Keith Busch, Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	Sebastian Reichel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Johannes Berg, Wolfram Sang, Raed Salem,
	Chen Zhongjin, Tetsuo Handa, Avihai Horon,
	Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

On Fri, Nov 25, 2022 at 03:51:11PM -0800, Bart Van Assche wrote:
> On 11/23/22 04:25, Greg Kroah-Hartman wrote:
> > diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
> > index 7dd1f01ec4f9..7aab4a769736 100644
> > --- a/include/linux/mISDNif.h
> > +++ b/include/linux/mISDNif.h
> > @@ -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/Y34+V2bCDdqujBDk@kroah.com

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-27 13:45   ` Greg Kroah-Hartman
@ 2022-11-28  2:38     ` Bart Van Assche
  2022-11-28 17:25       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 103+ messages in thread
From: Bart Van Assche @ 2022-11-28  2:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Mauro Carvalho Chehab,
	Keith Busch, Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	Sebastian Reichel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Johannes Berg, Wolfram Sang, Raed Salem,
	Chen Zhongjin, Tetsuo Handa, Avihai Horon,
	Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

On 11/27/22 05:45, Greg Kroah-Hartman wrote:
> On Fri, Nov 25, 2022 at 03:51:11PM -0800, Bart Van Assche wrote:
>> On 11/23/22 04:25, Greg Kroah-Hartman wrote:
>>> diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
>>> index 7dd1f01ec4f9..7aab4a769736 100644
>>> --- a/include/linux/mISDNif.h
>>> +++ b/include/linux/mISDNif.h
>>> @@ -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/Y34+V2bCDdqujBDk@kroah.com
> 
> 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.

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const *
  2022-11-28  2:38     ` Bart Van Assche
@ 2022-11-28 17:25       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-11-28 17:25 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: linux-kernel, Jens Axboe, Luis Chamberlain, Russ Weight,
	Rafael J. Wysocki, Jean Delvare, Johan Hovold, Jason Gunthorpe,
	Leon Romanovsky, Karsten Keil, Mauro Carvalho Chehab,
	Keith Busch, Christoph Hellwig, Sagi Grimberg, Dominik Brodowski,
	Sebastian Reichel, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Johannes Berg, Wolfram Sang, Raed Salem,
	Chen Zhongjin, Tetsuo Handa, Avihai Horon,
	Matthew Wilcox (Oracle),
	Alan Stern, Colin Ian King, Geert Uytterhoeven, Jakob Koschel,
	Antoine Tenart, Frederic Weisbecker, Wang Yufen, linux-block,
	linux-media, linux-nvme, linux-pm, linux-rdma, linux-usb,
	linux-wireless, netdev

On Sun, Nov 27, 2022 at 06:38:39PM -0800, Bart Van Assche wrote:
> On 11/27/22 05:45, Greg Kroah-Hartman wrote:
> > On Fri, Nov 25, 2022 at 03:51:11PM -0800, Bart Van Assche wrote:
> > > On 11/23/22 04:25, Greg Kroah-Hartman wrote:
> > > > diff --git a/include/linux/mISDNif.h b/include/linux/mISDNif.h
> > > > index 7dd1f01ec4f9..7aab4a769736 100644
> > > > --- a/include/linux/mISDNif.h
> > > > +++ b/include/linux/mISDNif.h
> > > > @@ -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/Y34+V2bCDdqujBDk@kroah.com
> > 
> > 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?

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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 18:00                         ` Matthew Wilcox
  (?)
@ 2022-12-01 18:43                           ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-12-01 18:43 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Jason Gunthorpe, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 06:00:23PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #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 ;-)
> > 
> > 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-12-01 18:43                           ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-12-01 18:43 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Frank Rowand,
	Dan Williams, Andy Shevchenko, linux-acpi, Bard Liao,
	Pierre-Louis Bossart, Jason Gunthorpe, Alan Stern, linux-serial,
	linux-input, Won Chung, Len Brown, devicetree,
	Chaitanya Kulkarni, Ira Weiny, Michael Jamet, Ming Lei,
	Mark Gross, Hans de Goede, Rob Herring, Jiri Slaby,
	Thomas Gleixner, Mauro Carvalho Chehab, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 06:00:23PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #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 ;-)
> > 
> > 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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2022-12-01 18:43                           ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2022-12-01 18:43 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Jason Gunthorpe, Maximilian Luz, Andy Shevchenko, linux-kernel,
	Jens Axboe, Rafael J. Wysocki, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Hans de Goede,
	Mark Gross, Vinod Koul, Bard Liao, Pierre-Louis Bossart,
	Sanyog Kale, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, Jilin Yuan, Alan Stern,
	Sakari Ailus, Thomas Gleixner, Ira Weiny, Dan Williams,
	Won Chung, alsa-devel, devicetree, linux-acpi, linux-block,
	linux-i2c, linux-i3c, linux-input, linux-media, linux-serial,
	linux-usb, linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 06:00:23PM +0000, Matthew Wilcox wrote:
> On Wed, Nov 23, 2022 at 01:55:42PM -0400, Jason Gunthorpe wrote:
> > On Wed, Nov 23, 2022 at 05:49:36PM +0000, Matthew Wilcox wrote:
> > > On Wed, Nov 23, 2022 at 01:29:56PM -0400, Jason Gunthorpe wrote:
> > > > #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 ;-)
> > 
> > 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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 4/5] driver core: make struct device_type.devnode() take a const *
  2022-11-23 19:23   ` Dan Williams
@ 2023-01-11  9:46     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:46 UTC (permalink / raw)
  To: Dan Williams
  Cc: linux-kernel, Jens Axboe, Alison Schofield, Vishal Verma,
	Ira Weiny, Ben Widawsky, Jeremy Kerr, Joel Stanley,
	Alistar Popple, Eddie James, Alexander Shishkin,
	Jonathan Cameron, Jilin Yuan, Heikki Krogerus, Alan Stern,
	Andy Shevchenko, Thomas Gleixner, Jason Gunthorpe,
	Rafael J. Wysocki, Won Chung, linux-block, linux-cxl, linux-fsi,
	linux-usb

On Wed, Nov 23, 2022 at 11:23:36AM -0800, Dan Williams wrote:
> Greg Kroah-Hartman wrote:
> > The 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.
> > 
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: Alison Schofield <alison.schofield@intel.com>
> > Cc: Vishal Verma <vishal.l.verma@intel.com>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Ben Widawsky <bwidawsk@kernel.org>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Jeremy Kerr <jk@ozlabs.org>
> > Cc: Joel Stanley <joel@jms.id.au>
> > Cc: Alistar Popple <alistair@popple.id.au>
> > Cc: Eddie James <eajames@linux.ibm.com>
> > Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> > Cc: Won Chung <wonchung@google.com>
> > Cc: linux-block@vger.kernel.org
> > Cc: linux-cxl@vger.kernel.org
> > Cc: linux-fsi@lists.ozlabs.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-usb@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> [..]
> > diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> > index 20ce488a7754..6ae8d0bdc61b 100644
> > --- a/drivers/cxl/core/memdev.c
> > +++ b/drivers/cxl/core/memdev.c
> > @@ -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:
> 
> Acked-by: Dan Williams <dan.j.williams@intel.com>

Thanks for the review!

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 5/5] driver core: device_get_devnode() should take a const *
  2022-11-23 13:36   ` Andy Shevchenko
@ 2023-01-11  9:47     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, Rafael J. Wysocki, Thomas Gleixner,
	Jason Gunthorpe, Ira Weiny, Dan Williams, Won Chung

On Wed, Nov 23, 2022 at 03:36:37PM +0200, Andy Shevchenko wrote:
> On Wed, Nov 23, 2022 at 01:25:23PM +0100, Greg Kroah-Hartman wrote:
> > 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 of device.h as it does not need to be exposed to
> > the whole kernel tree.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> (see one nit-pick below)
> 
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Won Chung <wonchung@google.com>
> > Cc: linux-kernel@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >  drivers/base/base.h    | 2 ++
> >  drivers/base/core.c    | 2 +-
> >  include/linux/device.h | 2 --
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/base/base.h b/drivers/base/base.h
> > index 7d4803c03d3e..a8a119c36bdc 100644
> > --- a/drivers/base/base.h
> > +++ b/drivers/base/base.h
> > @@ -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

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 12:38     ` Rafael J. Wysocki
  (?)
@ 2023-01-11  9:51       ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:51 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-kernel, Jens Axboe, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Maximilian Luz,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:38:05PM +0100, Rafael J. Wysocki wrote:
> On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> >
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> > Cc: Wolfram Sang <wsa@kernel.org>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Sean Young <sean@mess.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Maximilian Luz <luzmaximilian@gmail.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Mark Gross <markgross@kernel.org>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Cc: Michael Jamet <michael.jamet@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> > Cc: Jiri Slaby <jirislaby@kernel.org>
> > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> > Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> > Cc: Chaitanya Kulkarni <kch@nvidia.com>
> > Cc: Ming Lei <ming.lei@redhat.com>
> > Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Won Chung <wonchung@google.com>
> > Cc: alsa-devel@alsa-project.org
> > Cc: devicetree@vger.kernel.org
> > Cc: linux-acpi@vger.kernel.org
> > Cc: linux-block@vger.kernel.org
> > Cc: linux-i2c@vger.kernel.org
> > Cc: linux-i3c@lists.infradead.org
> > Cc: linux-input@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-media@vger.kernel.org
> > Cc: linux-serial@vger.kernel.org
> > Cc: linux-usb@vger.kernel.org
> > Cc: linux1394-devel@lists.sourceforge.net
> > Cc: platform-driver-x86@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> (which my ACPI maintainer hat on).

thanks for the review, I'll add it to the v2 patch.

greg k-h

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2023-01-11  9:51       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:51 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-kernel, Jens Axboe, Len Brown, Stefan Richter,
	Wolfram Sang, Alexandre Belloni, Dmitry Torokhov, Sean Young,
	Mauro Carvalho Chehab, Rob Herring, Frank Rowand, Maximilian Luz,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 01:38:05PM +0100, Rafael J. Wysocki wrote:
> On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> >
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> > Cc: Wolfram Sang <wsa@kernel.org>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Sean Young <sean@mess.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Maximilian Luz <luzmaximilian@gmail.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Mark Gross <markgross@kernel.org>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Cc: Michael Jamet <michael.jamet@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> > Cc: Jiri Slaby <jirislaby@kernel.org>
> > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> > Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> > Cc: Chaitanya Kulkarni <kch@nvidia.com>
> > Cc: Ming Lei <ming.lei@redhat.com>
> > Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Won Chung <wonchung@google.com>
> > Cc: alsa-devel@alsa-project.org
> > Cc: devicetree@vger.kernel.org
> > Cc: linux-acpi@vger.kernel.org
> > Cc: linux-block@vger.kernel.org
> > Cc: linux-i2c@vger.kernel.org
> > Cc: linux-i3c@lists.infradead.org
> > Cc: linux-input@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-media@vger.kernel.org
> > Cc: linux-serial@vger.kernel.org
> > Cc: linux-usb@vger.kernel.org
> > Cc: linux1394-devel@lists.sourceforge.net
> > Cc: platform-driver-x86@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> (which my ACPI maintainer hat on).

thanks for the review, I'll add it to the v2 patch.

greg k-h

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2023-01-11  9:51       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:51 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young, alsa-devel,
	platform-driver-x86, linux-i2c, Andreas Noever, linux-i3c,
	linux1394-devel, Bard Liao, Dan Williams, Andy Shevchenko,
	linux-acpi, Frank Rowand, Pierre-Louis Bossart,
	Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab,
	Mika Westerberg, Jens Axboe, linux-block, Jilin Yuan,
	Martin K. Petersen, Dmitry Torokhov, linux-kernel, Wolfram Sang,
	Vinod Koul, Stefan Richter, Sakari Ailus, Yehezkel Bernat,
	Sanyog Kale, linux-media, Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 01:38:05PM +0100, Rafael J. Wysocki wrote:
> On Wed, Nov 23, 2022 at 1:25 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> >
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> > Cc: Wolfram Sang <wsa@kernel.org>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Sean Young <sean@mess.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Maximilian Luz <luzmaximilian@gmail.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Mark Gross <markgross@kernel.org>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Cc: Michael Jamet <michael.jamet@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
> > Cc: Jiri Slaby <jirislaby@kernel.org>
> > Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> > Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> > Cc: Chaitanya Kulkarni <kch@nvidia.com>
> > Cc: Ming Lei <ming.lei@redhat.com>
> > Cc: Jilin Yuan <yuanjilin@cdjrlc.com>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Won Chung <wonchung@google.com>
> > Cc: alsa-devel@alsa-project.org
> > Cc: devicetree@vger.kernel.org
> > Cc: linux-acpi@vger.kernel.org
> > Cc: linux-block@vger.kernel.org
> > Cc: linux-i2c@vger.kernel.org
> > Cc: linux-i3c@lists.infradead.org
> > Cc: linux-input@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-media@vger.kernel.org
> > Cc: linux-serial@vger.kernel.org
> > Cc: linux-usb@vger.kernel.org
> > Cc: linux1394-devel@lists.sourceforge.net
> > Cc: platform-driver-x86@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> (which my ACPI maintainer hat on).

thanks for the review, I'll add it to the v2 patch.

greg k-h

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-25 11:56     ` Mauro Carvalho Chehab
  (?)
@ 2023-01-11  9:52       ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:52 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Rob Herring, Frank Rowand, Maximilian Luz,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Fri, Nov 25, 2022 at 11:56:18AM +0000, Mauro Carvalho Chehab wrote:
> Em Wed, 23 Nov 2022 13:25:21 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:
> 
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> 
> Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Thanks for the review.

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2023-01-11  9:52       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:52 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Rob Herring, Frank Rowand, Maximilian Luz,
	Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Mika Westerberg, Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Fri, Nov 25, 2022 at 11:56:18AM +0000, Mauro Carvalho Chehab wrote:
> Em Wed, 23 Nov 2022 13:25:21 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:
> 
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> 
> Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Thanks for the review.

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2023-01-11  9:52       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:52 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, linux-acpi, Frank Rowand, Pierre-Louis Bossart,
	Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Andy Shevchenko, Mika Westerberg,
	Jens Axboe, linux-block, Jilin Yuan, Martin K. Petersen,
	Dmitry Torokhov, linux-kernel, Wolfram Sang, Vinod Koul,
	Stefan Richter, Sakari Ailus, Yehezkel Bernat, Sanyog Kale,
	linux-media, Maximilian Luz, linux-usb

On Fri, Nov 25, 2022 at 11:56:18AM +0000, Mauro Carvalho Chehab wrote:
> Em Wed, 23 Nov 2022 13:25:21 +0100
> Greg Kroah-Hartman <gregkh@linuxfoundation.org> escreveu:
> 
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> 
> Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Thanks for the review.

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
  2022-11-23 13:56     ` Mika Westerberg
  (?)
@ 2023-01-11  9:52       ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:52 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 03:56:54PM +0200, Mika Westerberg wrote:
> On Wed, Nov 23, 2022 at 01:25:21PM +0100, Greg Kroah-Hartman wrote:
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> > 
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> > Cc: Wolfram Sang <wsa@kernel.org>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Sean Young <sean@mess.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Maximilian Luz <luzmaximilian@gmail.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Mark Gross <markgross@kernel.org>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Cc: Michael Jamet <michael.jamet@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt

Thanks for the review.

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2023-01-11  9:52       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:52 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: linux-kernel, Jens Axboe, Rafael J. Wysocki, Len Brown,
	Stefan Richter, Wolfram Sang, Alexandre Belloni, Dmitry Torokhov,
	Sean Young, Mauro Carvalho Chehab, Rob Herring, Frank Rowand,
	Maximilian Luz, Hans de Goede, Mark Gross, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, Sanyog Kale, Andreas Noever, Michael Jamet,
	Yehezkel Bernat, Jiri Slaby, Heikki Krogerus,
	Matthew Wilcox (Oracle),
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, Jilin Yuan,
	Alan Stern, Andy Shevchenko, Sakari Ailus, Jason Gunthorpe,
	Thomas Gleixner, Ira Weiny, Dan Williams, Won Chung, alsa-devel,
	devicetree, linux-acpi, linux-block, linux-i2c, linux-i3c,
	linux-input, linux-media, linux-serial, linux-usb,
	linux1394-devel, platform-driver-x86

On Wed, Nov 23, 2022 at 03:56:54PM +0200, Mika Westerberg wrote:
> On Wed, Nov 23, 2022 at 01:25:21PM +0100, Greg Kroah-Hartman wrote:
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> > 
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> > Cc: Wolfram Sang <wsa@kernel.org>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Sean Young <sean@mess.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Maximilian Luz <luzmaximilian@gmail.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Mark Gross <markgross@kernel.org>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Cc: Michael Jamet <michael.jamet@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt

Thanks for the review.

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 103+ messages in thread

* Re: [PATCH 3/5] driver core: make struct device_type.uevent() take a const *
@ 2023-01-11  9:52       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 103+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11  9:52 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Alexandre Belloni, Heikki Krogerus, Sean Young,
	Rafael J. Wysocki, alsa-devel, platform-driver-x86, linux-i2c,
	Andreas Noever, linux-i3c, linux1394-devel, Bard Liao,
	Dan Williams, Andy Shevchenko, linux-acpi, Frank Rowand,
	Pierre-Louis Bossart, Matthew Wilcox (Oracle),
	Jason Gunthorpe, Alan Stern, linux-serial, linux-input,
	Won Chung, Len Brown, devicetree, Chaitanya Kulkarni, Ira Weiny,
	Michael Jamet, Ming Lei, Mark Gross, Hans de Goede, Rob Herring,
	Jiri Slaby, Thomas Gleixner, Mauro Carvalho Chehab, Jens Axboe,
	linux-block, Jilin Yuan, Martin K. Petersen, Dmitry Torokhov,
	linux-kernel, Wolfram Sang, Vinod Koul, Stefan Richter,
	Sakari Ailus, Yehezkel Bernat, Sanyog Kale, linux-media,
	Maximilian Luz, linux-usb

On Wed, Nov 23, 2022 at 03:56:54PM +0200, Mika Westerberg wrote:
> On Wed, Nov 23, 2022 at 01:25:21PM +0100, Greg Kroah-Hartman wrote:
> > The uevent() callback in struct device_type should not be modifying the
> > device that is passed into it, so mark it as a const * and propagate the
> > function signature changes out into all relevant subsystems that use
> > this callback.
> > 
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
> > Cc: Wolfram Sang <wsa@kernel.org>
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: Sean Young <sean@mess.org>
> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: Maximilian Luz <luzmaximilian@gmail.com>
> > Cc: Hans de Goede <hdegoede@redhat.com>
> > Cc: Mark Gross <markgross@kernel.org>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> > Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> > Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Cc: Michael Jamet <michael.jamet@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> # for Thunderbolt

Thanks for the review.

^ permalink raw reply	[flat|nested] 103+ messages in thread

end of thread, other threads:[~2023-01-12 16:02 UTC | newest]

Thread overview: 103+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 12:25 [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Greg Kroah-Hartman
2022-11-23 12:25 ` [PATCH 2/5] driver core: make struct class.devnode() " Greg Kroah-Hartman
2022-11-23 12:25   ` Greg Kroah-Hartman
2022-11-23 12:25   ` Greg Kroah-Hartman
2022-11-23 12:25   ` Greg Kroah-Hartman
2022-11-25 11:55   ` Mauro Carvalho Chehab
2022-11-25 11:55     ` Mauro Carvalho Chehab
2022-11-25 11:55     ` Mauro Carvalho Chehab
2022-11-25 12:40     ` Sumit Semwal
2022-11-25 12:40       ` Sumit Semwal
2022-11-25 12:40       ` Sumit Semwal
2022-11-23 12:25 ` [PATCH 3/5] driver core: make struct device_type.uevent() " Greg Kroah-Hartman
2022-11-23 12:25   ` Greg Kroah-Hartman
2022-11-23 12:25   ` Greg Kroah-Hartman
2022-11-23 12:38   ` Rafael J. Wysocki
2022-11-23 12:38     ` Rafael J. Wysocki
2022-11-23 12:38     ` Rafael J. Wysocki
2023-01-11  9:51     ` Greg Kroah-Hartman
2023-01-11  9:51       ` Greg Kroah-Hartman
2023-01-11  9:51       ` Greg Kroah-Hartman
2022-11-23 13:14   ` Maximilian Luz
2022-11-23 13:14     ` Maximilian Luz
2022-11-23 13:14     ` Maximilian Luz
2022-11-23 13:34     ` Andy Shevchenko
2022-11-23 13:34       ` Andy Shevchenko
2022-11-23 13:34       ` Andy Shevchenko
2022-11-23 13:59       ` Maximilian Luz
2022-11-23 13:59         ` Maximilian Luz
2022-11-23 13:59         ` Maximilian Luz
2022-11-23 14:52         ` Matthew Wilcox
2022-11-23 14:52           ` Matthew Wilcox
2022-11-23 14:52           ` Matthew Wilcox
2022-11-23 15:14           ` Maximilian Luz
2022-11-23 15:14             ` Maximilian Luz
2022-11-23 15:14             ` Maximilian Luz
2022-11-23 15:37           ` Greg Kroah-Hartman
2022-11-23 15:37             ` Greg Kroah-Hartman
2022-11-23 15:37             ` Greg Kroah-Hartman
2022-11-23 15:48             ` Maximilian Luz
2022-11-23 15:48               ` Maximilian Luz
2022-11-23 15:48               ` Maximilian Luz
2022-11-23 15:52               ` Greg Kroah-Hartman
2022-11-23 15:52                 ` Greg Kroah-Hartman
2022-11-23 15:52                 ` Greg Kroah-Hartman
2022-11-23 16:25             ` Jason Gunthorpe
2022-11-23 16:25               ` Jason Gunthorpe
2022-11-23 16:25               ` Jason Gunthorpe
2022-11-23 17:01               ` Greg Kroah-Hartman
2022-11-23 17:01                 ` Greg Kroah-Hartman
2022-11-23 17:01                 ` Greg Kroah-Hartman
2022-11-23 17:29                 ` Jason Gunthorpe
2022-11-23 17:29                   ` Jason Gunthorpe
2022-11-23 17:29                   ` Jason Gunthorpe
2022-11-23 17:49                   ` Matthew Wilcox
2022-11-23 17:49                     ` Matthew Wilcox
2022-11-23 17:49                     ` Matthew Wilcox
2022-11-23 17:55                     ` Jason Gunthorpe
2022-11-23 17:55                       ` Jason Gunthorpe
2022-11-23 17:55                       ` Jason Gunthorpe
2022-11-23 18:00                       ` Matthew Wilcox
2022-11-23 18:00                         ` Matthew Wilcox
2022-11-23 18:00                         ` Matthew Wilcox
2022-12-01 18:43                         ` Greg Kroah-Hartman
2022-12-01 18:43                           ` Greg Kroah-Hartman
2022-12-01 18:43                           ` Greg Kroah-Hartman
2022-11-23 18:10                     ` Greg Kroah-Hartman
2022-11-23 18:10                       ` Greg Kroah-Hartman
2022-11-23 18:10                       ` Greg Kroah-Hartman
2022-11-23 18:25                       ` Jason Gunthorpe
2022-11-23 18:25                         ` Jason Gunthorpe
2022-11-23 18:25                         ` Jason Gunthorpe
2022-11-23 19:06                         ` Greg Kroah-Hartman
2022-11-23 19:06                           ` Greg Kroah-Hartman
2022-11-23 19:06                           ` Greg Kroah-Hartman
2022-11-23 23:24                           ` Barnabás Pőcze
2022-11-23 23:24                             ` Barnabás Pőcze
2022-11-23 23:24                             ` Barnabás Pőcze
2022-11-23 13:56   ` Mika Westerberg
2022-11-23 13:56     ` Mika Westerberg
2022-11-23 13:56     ` Mika Westerberg
2023-01-11  9:52     ` Greg Kroah-Hartman
2023-01-11  9:52       ` Greg Kroah-Hartman
2023-01-11  9:52       ` Greg Kroah-Hartman
2022-11-25 11:56   ` Mauro Carvalho Chehab
2022-11-25 11:56     ` Mauro Carvalho Chehab
2022-11-25 11:56     ` Mauro Carvalho Chehab
2023-01-11  9:52     ` Greg Kroah-Hartman
2023-01-11  9:52       ` Greg Kroah-Hartman
2023-01-11  9:52       ` Greg Kroah-Hartman
2022-11-23 12:25 ` [PATCH 4/5] driver core: make struct device_type.devnode() " Greg Kroah-Hartman
2022-11-23 19:23   ` Dan Williams
2023-01-11  9:46     ` Greg Kroah-Hartman
2022-11-23 12:25 ` [PATCH 5/5] driver core: device_get_devnode() should " Greg Kroah-Hartman
2022-11-23 12:39   ` Rafael J. Wysocki
2022-11-23 13:36   ` Andy Shevchenko
2023-01-11  9:47     ` Greg Kroah-Hartman
2022-11-23 12:38 ` [PATCH 1/5] driver core: make struct class.dev_uevent() " Rafael J. Wysocki
2022-11-24 15:03 ` Sebastian Reichel
2022-11-25 11:54 ` Mauro Carvalho Chehab
2022-11-25 23:51 ` Bart Van Assche
2022-11-27 13:45   ` Greg Kroah-Hartman
2022-11-28  2:38     ` Bart Van Assche
2022-11-28 17:25       ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.