From patchwork Wed Nov 23 12:25:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 24937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2755229wrr; Wed, 23 Nov 2022 04:27:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf66orGK/0XTeS/b/FpRfhIXhzRYl8EB50JkuF09lpoHYHDp1oU2DmyIgLLqyibmy6QKVMae X-Received: by 2002:a62:8686:0:b0:56c:636a:ac94 with SMTP id x128-20020a628686000000b0056c636aac94mr8682210pfd.38.1669206429447; Wed, 23 Nov 2022 04:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206429; cv=none; d=google.com; s=arc-20160816; b=sBetq2Av3vA27iuJP0oWoiGWs+YzFwDckaHWGWsVZhluNUE9syGZZLYKgqMSw8g5a7 pBhnufBxyW38w8bkoxdHy3VVp6GsdQ05HTLu2b/vK8o4zWwp8JR23GsZT3/yBh9vdJze d3831nWxxYEfXTaWxGDbhKMvnFsdI9iA0Y1G6F5aRuPVMX5wJdANuFxDVvJatT/V9C1K gV5SIH5n/WMhT3LrZque57JEed2+Q5QKqdKIfbNIoxwREAVc0jeD2aU8dC8n8JB9HfFS O3nNMFyMwYh1BmRWy5OFgkgFk5m2OZcGTxi0eTTar1MfjiKFEBLdmWMUcONsuc5CcJ/m RXTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=M5qPqRwPX+gd7PnZvZoLgcS6C5XT57qs5mwO/EAnqD8=; b=VPY4OanHBUytvPSiJCBknf9uvJ62tWC/YhVA2tkKMzxrJ53WmrOmePsNfBcNpSVNVI IgCb8Mu9Z8EdXfdiCFCrI0t7orV0iFPqa76eaAW/g8nT1N0RY/qUsscBzED1M2wU5qy/ BO2PNA4tXzZivjqXXZMU7u+6odrkYqKvfDAANOJvwIKAbYWPVdUDgE86nijkHGvN3Fiz 07PWhk8CBmT1xIR7MAiMlKFlxXgQR599iW/pZUz9/1eHawPX7Z39NP6cczhHWpIHti00 qMeQE4j1pYWqZmunGM/kIXy6dJx5567dYjiRmYVth70tqzWlPpjUzks9uGs2+Z/0g6vU syAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x7TOTJ5P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b1-20020a170903228100b00186f22a06absi18579212plh.253.2022.11.23.04.26.55; Wed, 23 Nov 2022 04:27:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x7TOTJ5P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236606AbiKWMZi (ORCPT + 99 others); Wed, 23 Nov 2022 07:25:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235818AbiKWMZe (ORCPT ); Wed, 23 Nov 2022 07:25:34 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173075987B; Wed, 23 Nov 2022 04:25:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 46F96CE2153; Wed, 23 Nov 2022 12:25:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0317C433D6; Wed, 23 Nov 2022 12:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669206329; bh=oMrybol96lNN6ONdQCGNskyFYExTfwUf1tGQFBXfRLo=; h=From:To:Cc:Subject:Date:From; b=x7TOTJ5PerYPQGesUeoJhfhIEAuzxmqtN9mwzQqv3fZBdHbnKRo0qRJyJCWGLgjx4 FEIso4FX+8IV2ctJOn4z03uv+q6wKF86To9V4+9TxgEVLFO4hxyDjjyZUbs73F38Ii 6mhw4gc5yL3AtG6lH958dIHdcSB02KRhU9QRim3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org 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@vger.kernel.org, linux-media@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org, linux-rdma@vger.kernel.org, linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/5] driver core: make struct class.dev_uevent() take a const * Date: Wed, 23 Nov 2022 13:25:19 +0100 Message-Id: <20221123122523.1332370-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=14903; i=gregkh@linuxfoundation.org; h=from:subject; bh=oMrybol96lNN6ONdQCGNskyFYExTfwUf1tGQFBXfRLo=; b=owGbwMvMwCRo6H6F97bub03G02pJDMl1goY/NTYEfnWYbPhInnfq1/UHpzq27hUzDJJ/bjzphNYW n88uHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRhhqGBd0Mk92+PsrXrbBovbhgY/ fplUfF6hgWLJFRtPeceUwzz2DdeYeKu3tLDE/PAgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289800815131907?= X-GMAIL-MSGID: =?utf-8?q?1750289800815131907?= 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 Cc: Luis Chamberlain Cc: Russ Weight Cc: "Rafael J. Wysocki" Cc: Jean Delvare Cc: Johan Hovold Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: Karsten Keil Cc: Mauro Carvalho Chehab Cc: Keith Busch Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Dominik Brodowski Cc: Sebastian Reichel Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Johannes Berg Cc: Wolfram Sang Cc: Raed Salem Cc: Chen Zhongjin Cc: Tetsuo Handa Cc: Avihai Horon Cc: "Matthew Wilcox (Oracle)" Cc: Alan Stern Cc: Colin Ian King Cc: Geert Uytterhoeven Cc: Jakob Koschel Cc: Antoine Tenart Cc: Frederic Weisbecker Cc: Wang Yufen 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 Acked-by: Rafael J. Wysocki Acked-by: Sebastian Reichel Acked-by: Mauro Carvalho Chehab --- 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; From patchwork Wed Nov 23 12:25:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 24938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2755659wrr; Wed, 23 Nov 2022 04:28:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7mjKkbGpf2eYbKVRaowBLi1pzLG8qoexNfG5wBhMCHykl5fZAzisq0C43zplVz9L/co8D8 X-Received: by 2002:a17:902:e013:b0:189:40ce:3ecc with SMTP id o19-20020a170902e01300b0018940ce3eccmr2929792plo.63.1669206493921; Wed, 23 Nov 2022 04:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206493; cv=none; d=google.com; s=arc-20160816; b=GySaSGrbLCUajDgpjdUgzf/L2XQNOk+GTyW/Sm5XSW6tlaL0Ntf6qIaNAu2LeZcaS7 K7q/8F3olHahpsmNilkqQmYG9SjVWoYHWs29eTErJLxPFP1KnR+4wF+/xwH8YTMiItVH UP1EjAbYfQ70WiHCbxSi98y/6/9qFb5VEtSuGPCo27g2rCqXOYgpsr11AMaGQBNZjz3u a+YOBfxF1gH088RbbwmWbb2o9u96vQrpXTaPQXROS2u6RB9eEVNUzK1AMPyQpy6Q3qiR 1ewnTMco7GPCvumpz6IojL4DAaQ9nDjp3TkNzsNlAPgQ9e04szI2oMa/fee4ZI5i02Ti vvSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hwWaLD57t9VMQSshsoMpfHx59TWTla0oKzVp7MhJRC4=; b=I6rhzCJgE1r/+vhbUTEkutRCxWoBCARrlgrY1zRWxynXn5t16/T0bcYxWLGKjFw+5Q GVuqWzXF7BYLGItojBbzCa/oa6ARAh2H76h0lWWXLep+lj5ap5UZT/Lz3TMZ5kDxsR7w UQJhhxVUXgLidbyUr1Pr3MUgNgyMqpQ/Gg7GjbVXuHvlsIDqIS5nyW5nfsdLxYGovURP qFo0Ug+1gCvN/TpwTKWNdBrGeHY0W9nVbsX9qrSzErS7bL8EhKpDF6krrh2IO1dDt7o9 VTtL6OmqXkRLvuTuFl6eGad+f2vXazwJ0YWF5wQUqUmkhVNVtxeiPy70/OXcwZ4y59oA YBYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YzHwrAzp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a63ea47000000b0043adff6d43dsi17276439pgk.583.2022.11.23.04.28.01; Wed, 23 Nov 2022 04:28:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YzHwrAzp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236964AbiKWMZq (ORCPT + 99 others); Wed, 23 Nov 2022 07:25:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236890AbiKWMZl (ORCPT ); Wed, 23 Nov 2022 07:25:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32CEF5E3C0; Wed, 23 Nov 2022 04:25:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ABBF9B81F2B; Wed, 23 Nov 2022 12:25:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B355C433C1; Wed, 23 Nov 2022 12:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669206337; bh=vX90mk67saZPcle6Cg4swhPypgBu1ruT4d+AsZhYWVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YzHwrAzpi6Mlm7VSFwQeObtZ5GHNyY5UPoQ9uhqzgPlyuN3h9LzFIfshxqlrXtQkM U2DseqZzrspOwrhOpW4ehWC6KIYswzEnQzR5df/NzP+AbNLVIjVDqAg180cudrfkFx Z4QP2k96A5niygkQRC6hsDh5lOKrvGLenvl7FLDc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , FUJITA Tomonori , Jens Axboe , Justin Sanders , Arnd Bergmann , Sumit Semwal , Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , =?utf-8?q?Christian_K=C3=B6nig?= , 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@alsa-project.org, dri-devel@lists.freedesktop.org, kvm@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-block@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-rdma@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 2/5] driver core: make struct class.devnode() take a const * Date: Wed, 23 Nov 2022 13:25:20 +0100 Message-Id: <20221123122523.1332370-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123122523.1332370-1-gregkh@linuxfoundation.org> References: <20221123122523.1332370-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=16514; i=gregkh@linuxfoundation.org; h=from:subject; bh=vX90mk67saZPcle6Cg4swhPypgBu1ruT4d+AsZhYWVQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDMl1gsaX2G1fi0ze8WsKL89+jYOhm3aZpRevE/LnVXhnaz3T KDikI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZSb8cwV6CLr1I+lS+A/eitsHff+y dXttrNY5inpGNxYvN5CVYLXRdj5sZrzH0reX0A X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289868502883868?= X-GMAIL-MSGID: =?utf-8?q?1750289868502883868?= 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 Cc: Reinette Chatre Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Cc: "H. Peter Anvin" Cc: FUJITA Tomonori Cc: Jens Axboe Cc: Justin Sanders Cc: Arnd Bergmann Cc: Sumit Semwal Cc: Benjamin Gaignard Cc: Liam Mark Cc: Laura Abbott Cc: Brian Starkey Cc: John Stultz Cc: "Christian König" Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: Dennis Dalessandro Cc: Dmitry Torokhov Cc: Mauro Carvalho Chehab Cc: Sean Young Cc: Frank Haverkamp Cc: Jiri Slaby Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Alex Williamson Cc: Cornelia Huck Cc: Kees Cook Cc: Anton Vorontsov Cc: Colin Cross Cc: Tony Luck Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Hans Verkuil Cc: Christophe JAILLET Cc: Xie Yongji Cc: Gautam Dawar Cc: Dan Carpenter Cc: Eli Cohen Cc: Parav Pandit Cc: Maxime Coquelin 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 Acked-by: Mauro Carvalho Chehab Acked-by: Sumit Semwal --- 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; From patchwork Wed Nov 23 12:25:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 24942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2756363wrr; Wed, 23 Nov 2022 04:30:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7db4qdVR/bkhd6h2p15bB9ph0wJ0pUjImxahyJgKWjceeFskZRm3YPcTaTOjvR0nKcS6sF X-Received: by 2002:a17:90b:48c2:b0:212:d636:1543 with SMTP id li2-20020a17090b48c200b00212d6361543mr37072582pjb.33.1669206600751; Wed, 23 Nov 2022 04:30:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206600; cv=none; d=google.com; s=arc-20160816; b=bdlGIz4ZH9A+Yowhr/cQoKmHHYW5EPcTloylMI/6H7IZdcLjd7PY/cgfwNhlXPqUZ6 owasbyaJw8OvGyPSPCCUFQW6l5YrPMJVacv6T9gXCdCGBdjUKKbH9b1gClCF1BWRcS7V xU7yeXeTQGW2GJDFWauP3gaz27BslOVsQLBb7STJ0mPIvaTLaxpl+yST1+Am3djwCOqe VEmUA2/h2QJAj7pbCzqYYYmrod/ADWfO1/LqEf67GPRwEum1WjhHVznO16GnbFnITuw5 UYdJZjvAydEQ7M6rLIM5djmLf/A9RmMnBrdw4n242dHG5NS6Kpwu6YF+A7o/S742WA9j 6fIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ekgksc7v5Fpm0etE6odaqSohxWBKajouQWSOoIzTg+A=; b=KI5Cp6H2QH1ftLBGkqBeY/gGA4gTIv07CaM9Kiv5oZAMtVmv+FJIU2bMhJD5W6NBwR 8li9cFJjyQe01uZ0i6uZNzlOznw0yYvj6Sf7ADK5Uhy4azJ2vvsrMUq2XiNOEq9rW9uC Ll6WcFfa9cne9aBj5YaWugIbR+ldH543mzVw5VXGUGtVlPB7XPZ85OAKlcTc23w2/Joj Q4T8r/RzmZAYKTtr1IwtREuqyevlYbYbve4whejr3lIESRbSAr9jqu91KwNY7b/hTxFN Jv+1NWIizdEb93EFKHLLhdQFagwFxZHAAFZMllg3JPRVuo7mKN+CfwOubP+QZZbdfaP7 iiLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="otg/8uRC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a6541ca000000b004770fe95989si16588215pgq.496.2022.11.23.04.29.47; Wed, 23 Nov 2022 04:30:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="otg/8uRC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237054AbiKWM0Q (ORCPT + 99 others); Wed, 23 Nov 2022 07:26:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236890AbiKWM0J (ORCPT ); Wed, 23 Nov 2022 07:26:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B355C74F; Wed, 23 Nov 2022 04:25:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ADE5FB81F37; Wed, 23 Nov 2022 12:25:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAE77C433C1; Wed, 23 Nov 2022 12:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669206342; bh=q4OHVk4abXLrHsF5oKZoNEiCtkOFn0dYEyBly5E3DXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=otg/8uRC6BkGB68wHsg3V6TAiGOoy+YoHheVd5g0mY4HBGGw+MUBPHXqa1clNl1z5 Arb9Pa/NP6p4pkUg/SCEZ5hYwhJ3D+3qn+SfejmU1Zy55K1qTPK+0K3VAcErnY6laD F4JyD2J6mXYpSaF4KtPStmZNzMPGYboxGWMmaUQo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org 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@alsa-project.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-block@vger.kernel.org, linux-i2c@vger.kernel.org, linux-i3c@lists.infradead.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux1394-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 3/5] driver core: make struct device_type.uevent() take a const * Date: Wed, 23 Nov 2022 13:25:21 +0100 Message-Id: <20221123122523.1332370-3-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123122523.1332370-1-gregkh@linuxfoundation.org> References: <20221123122523.1332370-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=27380; i=gregkh@linuxfoundation.org; h=from:subject; bh=q4OHVk4abXLrHsF5oKZoNEiCtkOFn0dYEyBly5E3DXU=; b=owGbwMvMwCRo6H6F97bub03G02pJDMl1gsYfBeONmpan/DlybFGA4Ukt5jtL/DkU535czdDPVLPs V39+RywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAExEqplhftKnLx3npcKn7TGbw2y32y /F85DyPIb5Cds2uily6SzTnMzJnPMgnXP+ZM53AA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289980896507980?= X-GMAIL-MSGID: =?utf-8?q?1750289980896507980?= 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 Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Stefan Richter Cc: Wolfram Sang Cc: Alexandre Belloni Cc: Dmitry Torokhov Cc: Sean Young Cc: Mauro Carvalho Chehab Cc: Rob Herring Cc: Frank Rowand Cc: Maximilian Luz Cc: Hans de Goede Cc: Mark Gross Cc: Vinod Koul Cc: Bard Liao Cc: Pierre-Louis Bossart Cc: Sanyog Kale Cc: Andreas Noever Cc: Michael Jamet Cc: Mika Westerberg Cc: Yehezkel Bernat Cc: Jiri Slaby Cc: Heikki Krogerus Cc: "Matthew Wilcox (Oracle)" Cc: "Martin K. Petersen" Cc: Chaitanya Kulkarni Cc: Ming Lei Cc: Jilin Yuan Cc: Alan Stern Cc: Andy Shevchenko Cc: Sakari Ailus Cc: Jason Gunthorpe Cc: Thomas Gleixner Cc: Ira Weiny Cc: Dan Williams Cc: Won Chung 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 Acked-by: Rafael J. Wysocki Acked-by: Mika Westerberg # for Thunderbolt Acked-by: Mauro Carvalho Chehab --- 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); } From patchwork Wed Nov 23 12:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 24940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2756131wrr; Wed, 23 Nov 2022 04:29:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf48MXJPB6OhigG70K43mTMSUB0icaxZP7Mf3YLWwsh1xn/0wmK3IxUQYpMrEY7xd6Nw2zTZ X-Received: by 2002:a17:90a:b396:b0:218:8379:89a0 with SMTP id e22-20020a17090ab39600b00218837989a0mr26490712pjr.81.1669206562996; Wed, 23 Nov 2022 04:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206562; cv=none; d=google.com; s=arc-20160816; b=u1HL0I3fNBkKb9uyRNvwPf8/klH0YThWtmk7hTha5Qh2nOf9AS+l9mHwcPzz3pBwzo FCiVf5+TIExhV9MnXWd4CFLAA+fCtEWJfcVwct/yQ0rtoLh5iroFlf8u6FOoS7zKXTrk 2XOkrA5tIoYKOzACQa4dmvgOrs7DACF6tuIiPGt1ai0tUH29yedij4QmVADCKIulvZMZ cQBGccTCwkc+fJc1CR50j/hiow4KKVG55297Q9Z9/XpjNicUhukVLBQx1+G+rDyrN/7y CCbJPI0ULh+yo1fjk/HbPYtPSKqyFuzPAHOXRzb24SUk820hGI2fF1TaI0LAqbUIOM+4 zEvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Px2AbSs9dYm8vdk0RmthYANY8GbUbWkqJ+G3GKhwS4=; b=jLmirp3i1yPwMNZq2magvSdRZOYwVK9p2mwA6htaINxFd3RvaNGpN+ibRMafUCn3H8 cGzzqz5yNoARzkWLXj5+lfSmrszus2b5VuDje+OI6MlJ25ZGMCD1vu5IkP1DD4WUeyFw 5wgGVrvQ+fUxgG0Ww1A4GfoaogA3MXjmjFAx2pUSbQDv2VL/GuuGKyv4L/9R9C+H5F5+ WbY+KCAnwjTPTRkJgib/K0osTsK1C4U8XcTfqVcVNK4Ul3vRSPGGpjA+SZQKYDxTTbUP peERbWoV59dUCuihGlBbsn3sng22Yu6u9FKMRfJgydJG1F7LTg0iQIuo0TLvrOGU7opK KE3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nlbf/HJ5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u70-20020a638549000000b004777166873csi8910263pgd.548.2022.11.23.04.29.09; Wed, 23 Nov 2022 04:29:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nlbf/HJ5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237534AbiKWM0z (ORCPT + 99 others); Wed, 23 Nov 2022 07:26:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237261AbiKWM0N (ORCPT ); Wed, 23 Nov 2022 07:26:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A7060E80; Wed, 23 Nov 2022 04:25:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 70293B81ED5; Wed, 23 Nov 2022 12:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BC08C433C1; Wed, 23 Nov 2022 12:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669206346; bh=tHqhDUSHq3ffWG1I/YC/xRRgv1nq4BU3p+/TFfRUrdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlbf/HJ5AH2BWfISiYvG/00jphh/RUKSt5ONtb/pdzTFeGizpg2RTEily7My9H7ob WvrhsddCYIRwv9nfiqoowz5k7/8gXwGaoDaABvgezjRseQRCLwKynSHTeF55EPg+Qb 4H3+XeCM2vAoQegiYFEwPm1C6mUQIAUWxtDCHinw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org 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@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsi@lists.ozlabs.org, linux-usb@vger.kernel.org Subject: [PATCH 4/5] driver core: make struct device_type.devnode() take a const * Date: Wed, 23 Nov 2022 13:25:22 +0100 Message-Id: <20221123122523.1332370-4-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123122523.1332370-1-gregkh@linuxfoundation.org> References: <20221123122523.1332370-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6608; i=gregkh@linuxfoundation.org; h=from:subject; bh=tHqhDUSHq3ffWG1I/YC/xRRgv1nq4BU3p+/TFfRUrdI=; b=owGbwMvMwCRo6H6F97bub03G02pJDMl1gsbbT9YcnTg9RC9we/NPp6iHinx80a+SXgmYcCnGfJU4 ym3YEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABM5/YZhNusK8/WT3h1etavvyWsNsU 93zCxlHBgWTOjQ4RX9lzDlgfXOlxNa3d7KFGd0AAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289941039143469?= X-GMAIL-MSGID: =?utf-8?q?1750289941039143469?= 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 Cc: Alison Schofield Cc: Vishal Verma Cc: Ira Weiny Cc: Ben Widawsky Cc: Dan Williams Cc: Jeremy Kerr Cc: Joel Stanley Cc: Alistar Popple Cc: Eddie James Cc: Alexander Shishkin Cc: Jonathan Cameron Cc: Jilin Yuan Cc: Heikki Krogerus Cc: Alan Stern Cc: Andy Shevchenko Cc: Thomas Gleixner Cc: Jason Gunthorpe Cc: "Rafael J. Wysocki" Cc: Won Chung 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 Acked-by: Dan Williams --- 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); From patchwork Wed Nov 23 12:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 24941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2756259wrr; Wed, 23 Nov 2022 04:29:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BWZFSWscVf6DPqnQkor0/qdZvNBZkirgeqhrBLUnsvZN2Q2XR0vQB2LwVvmbk6pkd/G23 X-Received: by 2002:a05:6a02:30a:b0:434:ffe3:cc1b with SMTP id bn10-20020a056a02030a00b00434ffe3cc1bmr25858333pgb.41.1669206581153; Wed, 23 Nov 2022 04:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206581; cv=none; d=google.com; s=arc-20160816; b=eFvS5aTYQGUAxSfCI7NuTGDQFvmrcws3DM9Gw3Jf6mBg949Wiy2AGoVkPznpv0xeKk xjB8T0IUvp2DY63fs4xA24Aom9sUnCSw69OkER22rnmGhDR7S5hmK6yoVUoXFNDNprGK mBdlb0DxX8g86PiPg1ax5blwcAQgkG4J3/InBodbfRn34f7dUN0Bzrw5H8g5rayynIHk vkvl+9A+U/s3UEioPYK65cOQlPO6MYmpqGBSIVhVjDCQkWAeg5Fq9O2mWFYuhDoSbRKx cceW4/HuWHMtFgagPwrEOhPkkHQ1o3se9s+svJfWDxh16GvxGci3suwCR72mw6wheTwI raAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aA1RhJf11NM8el89VSD4qB0NX6JN13qWgpAtxRSsOmE=; b=mgjq7h38XQ5gUs4/F79Q709jstxuGLE77P15cnnnYU8jK+hy6yuH4phrwTk3nHQyoK bVEbpZyOJNAvLRQQe/iGPP9ZWmPxH6C9AGomSRRxpee600PYuahFDXfkyl215VjZndUb dX7LK+3U4leg7XZy3nyFMcv8E5G3DBP4GVthzz6zNyIHkF03UrHe7b9uTS1hejmDJrgZ rQxCJKMFSTA/cjX738X4XmtZ/9F9TgzNvE6+qe/A0RJ9DrA2XEgkpFAqlJmdVGXe7ZBu 4eHJQ2hhRfC7cLaFLdYqU/uK4XCovteouDskMqv39pGwtd8E8J+IoH9rU9y+gF+RdwfK eveQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ec5fMGJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020aa78b43000000b0056bb98c611csi15044245pfd.226.2022.11.23.04.29.28; Wed, 23 Nov 2022 04:29:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ec5fMGJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237085AbiKWM1u (ORCPT + 99 others); Wed, 23 Nov 2022 07:27:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237078AbiKWM0Z (ORCPT ); Wed, 23 Nov 2022 07:26:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE8A761BB9 for ; Wed, 23 Nov 2022 04:25:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 534D861C58 for ; Wed, 23 Nov 2022 12:25:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1A4AC433B5; Wed, 23 Nov 2022 12:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669206350; bh=Y2hWZN4MqMeO65hNd5mMhexY6L2mauv8s0WA0ygqM3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ec5fMGJF0n9mfQKxQA9IBJvHbtiYdYw7iRsF4kk3Yx4TOTYRPF4t07VEXg9qaWgC1 c47uvrcCh+MBmwFPEvjTli7S0tIntGp98Tz0NE5Nq1kL6EiCSU+xBhTQGiS0R9IISC jteSNotwaqOrhKlRiaPJublQUNk+Bq6j9ByNjc50= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Jason Gunthorpe , Ira Weiny , Dan Williams , Andy Shevchenko , Won Chung Subject: [PATCH 5/5] driver core: device_get_devnode() should take a const * Date: Wed, 23 Nov 2022 13:25:23 +0100 Message-Id: <20221123122523.1332370-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123122523.1332370-1-gregkh@linuxfoundation.org> References: <20221123122523.1332370-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2551; i=gregkh@linuxfoundation.org; h=from:subject; bh=Y2hWZN4MqMeO65hNd5mMhexY6L2mauv8s0WA0ygqM3U=; b=owGbwMvMwCRo6H6F97bub03G02pJDMl1gsZu8TcMrn187L97nUqJnMi7xV9f7cop+DqLneFHduJa r+bYjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIrcUM87QmN1pMZtOQmJPtWn3vSp hA1lHPhwzz7Jwu3L+re8Rv7TNnhTbhi67TvjU/AwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750289959721691084?= X-GMAIL-MSGID: =?utf-8?q?1750289959721691084?= 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" Cc: Thomas Gleixner Cc: Jason Gunthorpe Cc: Ira Weiny Cc: Dan Williams Cc: Andy Shevchenko Cc: Won Chung Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Acked-by: Rafael J. Wysocki Reviewed-by: Andy Shevchenko --- 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)