Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: Borislav Petkov <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: James Morse <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Robert Richter <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/edac/edac_device_sysfs.c | 16 +++++++++-------
drivers/edac/edac_pci_sysfs.c | 14 +++++++++-----
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index ac678b4a21fc..010c26be5846 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -228,8 +228,9 @@ static struct kobj_type ktype_device_ctrl = {
*/
int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
{
+ struct device *dev_root;
struct bus_type *edac_subsys;
- int err;
+ int err = -ENODEV;
edac_dbg(1, "\n");
@@ -247,15 +248,16 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
*/
edac_dev->owner = THIS_MODULE;
- if (!try_module_get(edac_dev->owner)) {
- err = -ENODEV;
+ if (!try_module_get(edac_dev->owner))
goto err_out;
- }
/* register */
- err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
- &edac_subsys->dev_root->kobj,
- "%s", edac_dev->name);
+ dev_root = bus_get_dev_root(edac_subsys);
+ if (dev_root) {
+ err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
+ &dev_root->kobj, "%s", edac_dev->name);
+ put_device(dev_root);
+ }
if (err) {
edac_dbg(1, "Failed to register '.../edac/%s'\n",
edac_dev->name);
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 888d5728ecef..287cc51dbc86 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -337,8 +337,9 @@ static struct kobj_type ktype_edac_pci_main_kobj = {
*/
static int edac_pci_main_kobj_setup(void)
{
- int err;
+ int err = -ENODEV;
struct bus_type *edac_subsys;
+ struct device *dev_root;
edac_dbg(0, "\n");
@@ -357,7 +358,6 @@ static int edac_pci_main_kobj_setup(void)
*/
if (!try_module_get(THIS_MODULE)) {
edac_dbg(1, "try_module_get() failed\n");
- err = -ENODEV;
goto decrement_count_fail;
}
@@ -369,9 +369,13 @@ static int edac_pci_main_kobj_setup(void)
}
/* Instanstiate the pci object */
- err = kobject_init_and_add(edac_pci_top_main_kobj,
- &ktype_edac_pci_main_kobj,
- &edac_subsys->dev_root->kobj, "pci");
+ dev_root = bus_get_dev_root(edac_subsys);
+ if (dev_root) {
+ err = kobject_init_and_add(edac_pci_top_main_kobj,
+ &ktype_edac_pci_main_kobj,
+ &dev_root->kobj, "pci");
+ put_device(dev_root);
+ }
if (err) {
edac_dbg(1, "Failed to register '.../edac/pci'\n");
goto kobject_init_and_add_fail;
--
2.39.2
Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: Yoshinori Sato <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/sh/intc/userimask.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
index f9f043a3d90a..abe9091827cd 100644
--- a/drivers/sh/intc/userimask.c
+++ b/drivers/sh/intc/userimask.c
@@ -61,10 +61,18 @@ static DEVICE_ATTR(userimask, S_IRUSR | S_IWUSR,
static int __init userimask_sysdev_init(void)
{
+ struct device *dev_root;
+ int ret = 0;
+
if (unlikely(!uimask))
return -ENXIO;
- return device_create_file(intc_subsys.dev_root, &dev_attr_userimask);
+ dev_root = bus_get_dev_root(&intc_subsys);
+ if (dev_root) {
+ ret = device_create_file(dev_root, &dev_attr_userimask);
+ put_device(dev_root);
+ }
+ return ret;
}
late_initcall(userimask_sysdev_init);
--
2.39.2
Now that all users who accessed the bus_type structure in struct device
are properly using it as a const *, mark it as such so that no one can
modify it going forward anymore.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
include/linux/device.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 0f128520f6e5..9a8573409685 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -564,7 +564,7 @@ struct device {
const char *init_name; /* initial name of the device */
const struct device_type *type;
- struct bus_type *bus; /* type of bus device is on */
+ const struct bus_type *bus; /* type of bus device is on */
struct device_driver *driver; /* which driver has allocated this
device */
void *platform_data; /* Platform specific data, device
--
2.39.2
The struct bus_type pointers in the functions
intel_huc_register_gsc_notifier() and
intel_huc_unregister_gsc_notifier() should be a const pointer, as the
structure is not modified anywhere in the functions, and the pointer
they are passed will be a const * in the near future.
Cc: Jani Nikula <[email protected]>
Cc: Joonas Lahtinen <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Daniele Ceraolo Spurio <[email protected]>
Cc: Alan Previn <[email protected]>
Cc: John Harrison <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Tony Ye <[email protected]>
Cc: Vitaly Lubart <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/gpu/drm/i915/gt/uc/intel_huc.c | 4 ++--
drivers/gpu/drm/i915/gt/uc/intel_huc.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_huc.c b/drivers/gpu/drm/i915/gt/uc/intel_huc.c
index 410905da8e97..8b453bd7c953 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_huc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_huc.c
@@ -183,7 +183,7 @@ static int gsc_notifier(struct notifier_block *nb, unsigned long action, void *d
return 0;
}
-void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus)
+void intel_huc_register_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus)
{
int ret;
@@ -200,7 +200,7 @@ void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus
}
}
-void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *bus)
+void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus)
{
if (!huc->delayed_load.nb.notifier_call)
return;
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_huc.h b/drivers/gpu/drm/i915/gt/uc/intel_huc.h
index 52db03620c60..05d4832f8461 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_huc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_huc.h
@@ -51,8 +51,8 @@ int intel_huc_check_status(struct intel_huc *huc);
void intel_huc_update_auth_status(struct intel_huc *huc);
bool intel_huc_is_authenticated(struct intel_huc *huc);
-void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus);
-void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *bus);
+void intel_huc_register_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus);
+void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus);
static inline int intel_huc_sanitize(struct intel_huc *huc)
{
--
2.39.2
The bus_rescan_devices() function was missed in the previous change of
the bus_for_each* constant pointer changes, so fix it up now to take a
const * to struct bus_type.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/bus.c | 2 +-
include/linux/device/bus.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index f739a2a79e59..ced61fad390e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -769,7 +769,7 @@ static int __must_check bus_rescan_devices_helper(struct device *dev,
* attached and rescan it against existing drivers to see if it matches
* any by calling device_attach() for the unbound devices.
*/
-int bus_rescan_devices(struct bus_type *bus)
+int bus_rescan_devices(const struct bus_type *bus)
{
return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper);
}
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index c30c4748c170..b517b82d4723 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -114,7 +114,7 @@ extern int __must_check bus_register(const struct bus_type *bus);
extern void bus_unregister(const struct bus_type *bus);
-extern int __must_check bus_rescan_devices(struct bus_type *bus);
+extern int __must_check bus_rescan_devices(const struct bus_type *bus);
struct bus_attribute {
struct attribute attr;
--
2.39.2
The pointer to struct bus_type in struct device_driver should only be
pointing to something that can never change now that the driver core has
fixed up the previously writable fields. So mark it as a constant
pointer to enforce this and move forward with the goal of moving
bus_type into read-only memory.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
include/linux/device/driver.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index ceb0e477c2c8..0f22a6f46f8c 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -95,7 +95,7 @@ enum probe_type {
*/
struct device_driver {
const char *name;
- struct bus_type *bus;
+ const struct bus_type *bus;
struct module *owner;
const char *mod_name; /* used for built-in modules */
--
2.39.2
In the function, qm_get_qos_value(), a struct bus_type * is used, but it
really should be a const pointer as it is not modified anywhere in the
function, and the driver core function it is used in expects a constant
pointer.
Cc: Weili Qian <[email protected]>
Cc: Zhou Wang <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/crypto/hisilicon/qm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index e4c84433a88a..fd1a38ee55f8 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -3691,7 +3691,7 @@ static ssize_t qm_get_qos_value(struct hisi_qm *qm, const char *buf,
unsigned long *val,
unsigned int *fun_index)
{
- struct bus_type *bus_type = qm->pdev->dev.bus;
+ const struct bus_type *bus_type = qm->pdev->dev.bus;
char tbuf_bdf[QM_DBG_READ_LEN] = {0};
char val_buf[QM_DBG_READ_LEN] = {0};
struct pci_dev *pdev;
--
2.39.2
Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Viresh Kumar <[email protected]>
Cc: Srinivas Pandruvada <[email protected]>
Cc: Len Brown <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/cpufreq/cpufreq.c | 7 ++++++-
drivers/cpufreq/intel_pstate.c | 7 +++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6d8fd3b8dcb5..6ad3119b8e15 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2932,11 +2932,16 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);
static int __init cpufreq_core_init(void)
{
struct cpufreq_governor *gov = cpufreq_default_governor();
+ struct device *dev_root;
if (cpufreq_disabled())
return -ENODEV;
- cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj);
+ dev_root = bus_get_dev_root(&cpu_subsys);
+ if (dev_root) {
+ cpufreq_global_kobject = kobject_create_and_add("cpufreq", &dev_root->kobj);
+ put_device(dev_root);
+ }
BUG_ON(!cpufreq_global_kobject);
if (!strlen(default_governor))
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 48a4613cef1e..102cf7f0ac63 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1473,10 +1473,13 @@ static struct kobject *intel_pstate_kobject;
static void __init intel_pstate_sysfs_expose_params(void)
{
+ struct device *dev_root = bus_get_dev_root(&cpu_subsys);
int rc;
- intel_pstate_kobject = kobject_create_and_add("intel_pstate",
- &cpu_subsys.dev_root->kobj);
+ if (dev_root) {
+ intel_pstate_kobject = kobject_create_and_add("intel_pstate", &dev_root->kobj);
+ put_device(dev_root);
+ }
if (WARN_ON(!intel_pstate_kobject))
return;
--
2.39.2
Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: Tejun Heo <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
kernel/workqueue.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index b8b541caed48..209917792fa4 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5826,13 +5826,19 @@ static struct device_attribute wq_sysfs_cpumask_attr =
static int __init wq_sysfs_init(void)
{
+ struct device *dev_root;
int err;
err = subsys_virtual_register(&wq_subsys, NULL);
if (err)
return err;
- return device_create_file(wq_subsys.dev_root, &wq_sysfs_cpumask_attr);
+ dev_root = bus_get_dev_root(&wq_subsys);
+ if (dev_root) {
+ err = device_create_file(dev_root, &wq_sysfs_cpumask_attr);
+ put_device(dev_root);
+ }
+ return err;
}
core_initcall(wq_sysfs_init);
--
2.39.2
struct bus_type should never be modified in a sysfs callback as there is
nothing in the structure to modify, and frankly, the structure is almost
never used in a sysfs callback, so mark it as constant to allow struct
bus_type to be moved to read-only memory.
Cc: "David S. Miller" <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Alex Shi <[email protected]>
Cc: Alexander Gordeev <[email protected]>
Cc: Alexandre Bounine <[email protected]>
Cc: Alison Schofield <[email protected]>
Cc: Ben Widawsky <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Dexuan Cui <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Cc: Harald Freudenberger <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Hu Haowen <[email protected]>
Cc: Ilya Dryomov <[email protected]>
Cc: Ira Weiny <[email protected]>
Cc: Iwona Winiarska <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Laurentiu Tudor <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Stuart Yoder <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Vishal Verma <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Yanteng Si <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
Documentation/driver-api/driver-model/bus.rst | 4 +-
Documentation/filesystems/sysfs.rst | 4 +-
.../translations/zh_CN/filesystems/sysfs.txt | 4 +-
.../translations/zh_TW/filesystems/sysfs.txt | 4 +-
arch/powerpc/platforms/pseries/ibmebus.c | 4 +-
arch/powerpc/platforms/pseries/vio.c | 8 ++--
drivers/ata/pata_parport/pata_parport.c | 6 +--
drivers/base/bus.c | 8 ++--
drivers/block/rbd.c | 34 +++++++--------
drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +--
drivers/cxl/core/port.c | 2 +-
drivers/hv/vmbus_drv.c | 2 +-
drivers/net/netdevsim/bus.c | 4 +-
drivers/pci/pci-sysfs.c | 2 +-
drivers/pci/pci.c | 4 +-
drivers/peci/sysfs.c | 2 +-
drivers/rapidio/rio-sysfs.c | 2 +-
drivers/s390/crypto/ap_bus.c | 42 +++++++++----------
drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++--
drivers/scsi/fcoe/fcoe_transport.c | 6 +--
include/linux/device/bus.h | 4 +-
include/scsi/libfcoe.h | 6 +--
22 files changed, 78 insertions(+), 88 deletions(-)
diff --git a/Documentation/driver-api/driver-model/bus.rst b/Documentation/driver-api/driver-model/bus.rst
index 016b15a6e8ea..9709ab62a468 100644
--- a/Documentation/driver-api/driver-model/bus.rst
+++ b/Documentation/driver-api/driver-model/bus.rst
@@ -125,8 +125,8 @@ Exporting Attributes
struct bus_attribute {
struct attribute attr;
- ssize_t (*show)(struct bus_type *, char * buf);
- ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
+ ssize_t (*show)(const struct bus_type *, char * buf);
+ ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
};
Bus drivers can export attributes using the BUS_ATTR_RW macro that works
diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystems/sysfs.rst
index f8187d466b97..c32993bc83c7 100644
--- a/Documentation/filesystems/sysfs.rst
+++ b/Documentation/filesystems/sysfs.rst
@@ -373,8 +373,8 @@ Structure::
struct bus_attribute {
struct attribute attr;
- ssize_t (*show)(struct bus_type *, char * buf);
- ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
+ ssize_t (*show)(const struct bus_type *, char * buf);
+ ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
};
Declaring::
diff --git a/Documentation/translations/zh_CN/filesystems/sysfs.txt b/Documentation/translations/zh_CN/filesystems/sysfs.txt
index 046cc1d52058..547062759e60 100644
--- a/Documentation/translations/zh_CN/filesystems/sysfs.txt
+++ b/Documentation/translations/zh_CN/filesystems/sysfs.txt
@@ -329,8 +329,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr
struct bus_attribute {
struct attribute attr;
- ssize_t (*show)(struct bus_type *, char * buf);
- ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
+ ssize_t (*show)(const struct bus_type *, char * buf);
+ ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
};
声明:
diff --git a/Documentation/translations/zh_TW/filesystems/sysfs.txt b/Documentation/translations/zh_TW/filesystems/sysfs.txt
index acd677f19d4f..280824cc7e5d 100644
--- a/Documentation/translations/zh_TW/filesystems/sysfs.txt
+++ b/Documentation/translations/zh_TW/filesystems/sysfs.txt
@@ -332,8 +332,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr
struct bus_attribute {
struct attribute attr;
- ssize_t (*show)(struct bus_type *, char * buf);
- ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
+ ssize_t (*show)(const struct bus_type *, char * buf);
+ ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
};
聲明:
diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
index bb9c18682783..44703f13985b 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -267,7 +267,7 @@ static char *ibmebus_chomp(const char *in, size_t count)
return out;
}
-static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t probe_store(const struct bus_type *bus, const char *buf, size_t count)
{
struct device_node *dn = NULL;
struct device *dev;
@@ -305,7 +305,7 @@ static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
}
static BUS_ATTR_WO(probe);
-static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
{
struct device *dev;
char *path;
diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
index 770df9351aaa..bf7aff6390be 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -1006,7 +1006,7 @@ ATTRIBUTE_GROUPS(vio_cmo_dev);
/* sysfs bus functions and data structures for CMO */
#define viobus_cmo_rd_attr(name) \
-static ssize_t cmo_bus_##name##_show(struct bus_type *bt, char *buf) \
+static ssize_t cmo_bus_##name##_show(const struct bus_type *bt, char *buf) \
{ \
return sprintf(buf, "%lu\n", vio_cmo.name); \
} \
@@ -1015,7 +1015,7 @@ static struct bus_attribute bus_attr_cmo_bus_##name = \
#define viobus_cmo_pool_rd_attr(name, var) \
static ssize_t \
-cmo_##name##_##var##_show(struct bus_type *bt, char *buf) \
+cmo_##name##_##var##_show(const struct bus_type *bt, char *buf) \
{ \
return sprintf(buf, "%lu\n", vio_cmo.name.var); \
} \
@@ -1030,12 +1030,12 @@ viobus_cmo_pool_rd_attr(reserve, size);
viobus_cmo_pool_rd_attr(excess, size);
viobus_cmo_pool_rd_attr(excess, free);
-static ssize_t cmo_high_show(struct bus_type *bt, char *buf)
+static ssize_t cmo_high_show(const struct bus_type *bt, char *buf)
{
return sprintf(buf, "%lu\n", vio_cmo.high);
}
-static ssize_t cmo_high_store(struct bus_type *bt, const char *buf,
+static ssize_t cmo_high_store(const struct bus_type *bt, const char *buf,
size_t count)
{
unsigned long flags;
diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
index 294a266a0dda..64d1bde26940 100644
--- a/drivers/ata/pata_parport/pata_parport.c
+++ b/drivers/ata/pata_parport/pata_parport.c
@@ -554,8 +554,7 @@ void pata_parport_unregister_driver(struct pi_protocol *pr)
}
EXPORT_SYMBOL_GPL(pata_parport_unregister_driver);
-static ssize_t new_device_store(struct bus_type *bus, const char *buf,
- size_t count)
+static ssize_t new_device_store(const struct bus_type *bus, const char *buf, size_t count)
{
char port[12] = "auto";
char protocol[8] = "auto";
@@ -630,8 +629,7 @@ static void pi_remove_one(struct device *dev)
/* pata_parport_dev_release will do kfree(pi) */
}
-static ssize_t delete_device_store(struct bus_type *bus, const char *buf,
- size_t count)
+static ssize_t delete_device_store(const struct bus_type *bus, const char *buf, size_t count)
{
struct device *dev;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 91a6b6b1fc49..819ab745fa9f 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -274,7 +274,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
}
static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
-static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
+static ssize_t drivers_autoprobe_show(const struct bus_type *bus, char *buf)
{
struct subsys_private *sp = bus_to_subsys(bus);
int ret;
@@ -287,7 +287,7 @@ static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
return ret;
}
-static ssize_t drivers_autoprobe_store(struct bus_type *bus,
+static ssize_t drivers_autoprobe_store(const struct bus_type *bus,
const char *buf, size_t count)
{
struct subsys_private *sp = bus_to_subsys(bus);
@@ -304,7 +304,7 @@ static ssize_t drivers_autoprobe_store(struct bus_type *bus,
return count;
}
-static ssize_t drivers_probe_store(struct bus_type *bus,
+static ssize_t drivers_probe_store(const struct bus_type *bus,
const char *buf, size_t count)
{
struct device *dev;
@@ -808,7 +808,7 @@ static void klist_devices_put(struct klist_node *n)
put_device(dev);
}
-static ssize_t bus_uevent_store(struct bus_type *bus,
+static ssize_t bus_uevent_store(const struct bus_type *bus,
const char *buf, size_t count)
{
struct subsys_private *sp = bus_to_subsys(bus);
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 5cb008b9700a..84ad3b17956f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -491,12 +491,12 @@ static bool single_major = true;
module_param(single_major, bool, 0444);
MODULE_PARM_DESC(single_major, "Use a single major number for all rbd devices (default: true)");
-static ssize_t add_store(struct bus_type *bus, const char *buf, size_t count);
-static ssize_t remove_store(struct bus_type *bus, const char *buf,
+static ssize_t add_store(const struct bus_type *bus, const char *buf, size_t count);
+static ssize_t remove_store(const struct bus_type *bus, const char *buf,
size_t count);
-static ssize_t add_single_major_store(struct bus_type *bus, const char *buf,
+static ssize_t add_single_major_store(const struct bus_type *bus, const char *buf,
size_t count);
-static ssize_t remove_single_major_store(struct bus_type *bus, const char *buf,
+static ssize_t remove_single_major_store(const struct bus_type *bus, const char *buf,
size_t count);
static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth);
@@ -538,7 +538,7 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev)
return is_lock_owner;
}
-static ssize_t supported_features_show(struct bus_type *bus, char *buf)
+static ssize_t supported_features_show(const struct bus_type *bus, char *buf)
{
return sprintf(buf, "0x%llx\n", RBD_FEATURES_SUPPORTED);
}
@@ -6967,9 +6967,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
return ret;
}
-static ssize_t do_rbd_add(struct bus_type *bus,
- const char *buf,
- size_t count)
+static ssize_t do_rbd_add(const char *buf, size_t count)
{
struct rbd_device *rbd_dev = NULL;
struct ceph_options *ceph_opts = NULL;
@@ -7081,18 +7079,18 @@ static ssize_t do_rbd_add(struct bus_type *bus,
goto out;
}
-static ssize_t add_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t add_store(const struct bus_type *bus, const char *buf, size_t count)
{
if (single_major)
return -EINVAL;
- return do_rbd_add(bus, buf, count);
+ return do_rbd_add(buf, count);
}
-static ssize_t add_single_major_store(struct bus_type *bus, const char *buf,
+static ssize_t add_single_major_store(const struct bus_type *bus, const char *buf,
size_t count)
{
- return do_rbd_add(bus, buf, count);
+ return do_rbd_add(buf, count);
}
static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
@@ -7122,9 +7120,7 @@ static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
}
}
-static ssize_t do_rbd_remove(struct bus_type *bus,
- const char *buf,
- size_t count)
+static ssize_t do_rbd_remove(const char *buf, size_t count)
{
struct rbd_device *rbd_dev = NULL;
struct list_head *tmp;
@@ -7196,18 +7192,18 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
return count;
}
-static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
{
if (single_major)
return -EINVAL;
- return do_rbd_remove(bus, buf, count);
+ return do_rbd_remove(buf, count);
}
-static ssize_t remove_single_major_store(struct bus_type *bus, const char *buf,
+static ssize_t remove_single_major_store(const struct bus_type *bus, const char *buf,
size_t count)
{
- return do_rbd_remove(bus, buf, count);
+ return do_rbd_remove(buf, count);
}
/*
diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 36cb091a33b4..653e2d4c116f 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -231,7 +231,7 @@ static int scan_fsl_mc_bus(struct device *dev, void *data)
return 0;
}
-static ssize_t rescan_store(struct bus_type *bus,
+static ssize_t rescan_store(const struct bus_type *bus,
const char *buf, size_t count)
{
unsigned long val;
@@ -284,7 +284,7 @@ static int fsl_mc_bus_get_autorescan(struct device *dev, void *data)
return 0;
}
-static ssize_t autorescan_store(struct bus_type *bus,
+static ssize_t autorescan_store(const struct bus_type *bus,
const char *buf, size_t count)
{
bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_set_autorescan);
@@ -292,7 +292,7 @@ static ssize_t autorescan_store(struct bus_type *bus,
return count;
}
-static ssize_t autorescan_show(struct bus_type *bus, char *buf)
+static ssize_t autorescan_show(const struct bus_type *bus, char *buf)
{
bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_get_autorescan);
return strlen(buf);
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 8ee6b6e2e2a4..66333cd6248e 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -1927,7 +1927,7 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd)
EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL);
/* for user tooling to ensure port disable work has completed */
-static ssize_t flush_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t flush_store(const struct bus_type *bus, const char *buf, size_t count)
{
if (sysfs_streq(buf, "1")) {
flush_workqueue(cxl_bus_wq);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index d24dd65b33d4..513adba09f56 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -684,7 +684,7 @@ static const struct attribute_group vmbus_dev_group = {
__ATTRIBUTE_GROUPS(vmbus_dev);
/* Set up the attribute for /sys/bus/vmbus/hibernation */
-static ssize_t hibernation_show(struct bus_type *bus, char *buf)
+static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
{
return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
}
diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
index 0052968e881e..0787ad252dd9 100644
--- a/drivers/net/netdevsim/bus.c
+++ b/drivers/net/netdevsim/bus.c
@@ -132,7 +132,7 @@ static struct nsim_bus_dev *
nsim_bus_dev_new(unsigned int id, unsigned int port_count, unsigned int num_queues);
static ssize_t
-new_device_store(struct bus_type *bus, const char *buf, size_t count)
+new_device_store(const struct bus_type *bus, const char *buf, size_t count)
{
unsigned int id, port_count, num_queues;
struct nsim_bus_dev *nsim_bus_dev;
@@ -186,7 +186,7 @@ static BUS_ATTR_WO(new_device);
static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev);
static ssize_t
-del_device_store(struct bus_type *bus, const char *buf, size_t count)
+del_device_store(const struct bus_type *bus, const char *buf, size_t count)
{
struct nsim_bus_dev *nsim_bus_dev, *tmp;
unsigned int id;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index dd0d9d9bc509..ab32a91f287b 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -428,7 +428,7 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RW(msi_bus);
-static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
{
unsigned long val;
struct pci_bus *b = NULL;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7a67611dc5f4..45c3bb039f21 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6679,7 +6679,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
}
}
-static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
+static ssize_t resource_alignment_show(const struct bus_type *bus, char *buf)
{
size_t count = 0;
@@ -6691,7 +6691,7 @@ static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
return count;
}
-static ssize_t resource_alignment_store(struct bus_type *bus,
+static ssize_t resource_alignment_store(const struct bus_type *bus,
const char *buf, size_t count)
{
char *param, *old, *end;
diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c
index db9ef05776e3..c04244075794 100644
--- a/drivers/peci/sysfs.c
+++ b/drivers/peci/sysfs.c
@@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void *data)
return peci_controller_scan_devices(to_peci_controller(dev));
}
-static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
{
bool res;
int ret;
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index f7679602498e..90d391210533 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -286,7 +286,7 @@ const struct attribute_group *rio_dev_groups[] = {
NULL,
};
-static ssize_t scan_store(struct bus_type *bus, const char *buf, size_t count)
+static ssize_t scan_store(const struct bus_type *bus, const char *buf, size_t count)
{
long val;
int rc;
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index f4cc1720156f..5a99e0b18289 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -1166,12 +1166,12 @@ EXPORT_SYMBOL(ap_parse_mask_str);
* AP bus attributes.
*/
-static ssize_t ap_domain_show(struct bus_type *bus, char *buf)
+static ssize_t ap_domain_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index);
}
-static ssize_t ap_domain_store(struct bus_type *bus,
+static ssize_t ap_domain_store(const struct bus_type *bus,
const char *buf, size_t count)
{
int domain;
@@ -1193,7 +1193,7 @@ static ssize_t ap_domain_store(struct bus_type *bus,
static BUS_ATTR_RW(ap_domain);
-static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
+static ssize_t ap_control_domain_mask_show(const struct bus_type *bus, char *buf)
{
if (!ap_qci_info) /* QCI not supported */
return scnprintf(buf, PAGE_SIZE, "not supported\n");
@@ -1208,7 +1208,7 @@ static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
static BUS_ATTR_RO(ap_control_domain_mask);
-static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
+static ssize_t ap_usage_domain_mask_show(const struct bus_type *bus, char *buf)
{
if (!ap_qci_info) /* QCI not supported */
return scnprintf(buf, PAGE_SIZE, "not supported\n");
@@ -1223,7 +1223,7 @@ static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
static BUS_ATTR_RO(ap_usage_domain_mask);
-static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
+static ssize_t ap_adapter_mask_show(const struct bus_type *bus, char *buf)
{
if (!ap_qci_info) /* QCI not supported */
return scnprintf(buf, PAGE_SIZE, "not supported\n");
@@ -1238,7 +1238,7 @@ static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
static BUS_ATTR_RO(ap_adapter_mask);
-static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
+static ssize_t ap_interrupts_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n",
ap_irq_flag ? 1 : 0);
@@ -1246,12 +1246,12 @@ static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
static BUS_ATTR_RO(ap_interrupts);
-static ssize_t config_time_show(struct bus_type *bus, char *buf)
+static ssize_t config_time_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", ap_config_time);
}
-static ssize_t config_time_store(struct bus_type *bus,
+static ssize_t config_time_store(const struct bus_type *bus,
const char *buf, size_t count)
{
int time;
@@ -1265,12 +1265,12 @@ static ssize_t config_time_store(struct bus_type *bus,
static BUS_ATTR_RW(config_time);
-static ssize_t poll_thread_show(struct bus_type *bus, char *buf)
+static ssize_t poll_thread_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", ap_poll_kthread ? 1 : 0);
}
-static ssize_t poll_thread_store(struct bus_type *bus,
+static ssize_t poll_thread_store(const struct bus_type *bus,
const char *buf, size_t count)
{
int flag, rc;
@@ -1289,12 +1289,12 @@ static ssize_t poll_thread_store(struct bus_type *bus,
static BUS_ATTR_RW(poll_thread);
-static ssize_t poll_timeout_show(struct bus_type *bus, char *buf)
+static ssize_t poll_timeout_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%llu\n", poll_timeout);
}
-static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
+static ssize_t poll_timeout_store(const struct bus_type *bus, const char *buf,
size_t count)
{
unsigned long long time;
@@ -1318,21 +1318,21 @@ static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
static BUS_ATTR_RW(poll_timeout);
-static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
+static ssize_t ap_max_domain_id_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_domain_id);
}
static BUS_ATTR_RO(ap_max_domain_id);
-static ssize_t ap_max_adapter_id_show(struct bus_type *bus, char *buf)
+static ssize_t ap_max_adapter_id_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_adapter_id);
}
static BUS_ATTR_RO(ap_max_adapter_id);
-static ssize_t apmask_show(struct bus_type *bus, char *buf)
+static ssize_t apmask_show(const struct bus_type *bus, char *buf)
{
int rc;
@@ -1393,7 +1393,7 @@ static int apmask_commit(unsigned long *newapm)
return 0;
}
-static ssize_t apmask_store(struct bus_type *bus, const char *buf,
+static ssize_t apmask_store(const struct bus_type *bus, const char *buf,
size_t count)
{
int rc, changes = 0;
@@ -1425,7 +1425,7 @@ static ssize_t apmask_store(struct bus_type *bus, const char *buf,
static BUS_ATTR_RW(apmask);
-static ssize_t aqmask_show(struct bus_type *bus, char *buf)
+static ssize_t aqmask_show(const struct bus_type *bus, char *buf)
{
int rc;
@@ -1486,7 +1486,7 @@ static int aqmask_commit(unsigned long *newaqm)
return 0;
}
-static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
+static ssize_t aqmask_store(const struct bus_type *bus, const char *buf,
size_t count)
{
int rc, changes = 0;
@@ -1518,13 +1518,13 @@ static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
static BUS_ATTR_RW(aqmask);
-static ssize_t scans_show(struct bus_type *bus, char *buf)
+static ssize_t scans_show(const struct bus_type *bus, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%llu\n",
atomic64_read(&ap_scan_bus_count));
}
-static ssize_t scans_store(struct bus_type *bus, const char *buf,
+static ssize_t scans_store(const struct bus_type *bus, const char *buf,
size_t count)
{
AP_DBF_INFO("%s force AP bus rescan\n", __func__);
@@ -1536,7 +1536,7 @@ static ssize_t scans_store(struct bus_type *bus, const char *buf,
static BUS_ATTR_RW(scans);
-static ssize_t bindings_show(struct bus_type *bus, char *buf)
+static ssize_t bindings_show(const struct bus_type *bus, char *buf)
{
int rc;
unsigned int apqns, n;
diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
index 6260aa5ea6af..e17957f8085c 100644
--- a/drivers/scsi/fcoe/fcoe_sysfs.c
+++ b/drivers/scsi/fcoe/fcoe_sysfs.c
@@ -659,17 +659,17 @@ static const struct device_type fcoe_fcf_device_type = {
.release = fcoe_fcf_device_release,
};
-static ssize_t ctlr_create_store(struct bus_type *bus, const char *buf,
+static ssize_t ctlr_create_store(const struct bus_type *bus, const char *buf,
size_t count)
{
- return fcoe_ctlr_create_store(bus, buf, count);
+ return fcoe_ctlr_create_store(buf, count);
}
static BUS_ATTR_WO(ctlr_create);
-static ssize_t ctlr_destroy_store(struct bus_type *bus, const char *buf,
+static ssize_t ctlr_destroy_store(const struct bus_type *bus, const char *buf,
size_t count)
{
- return fcoe_ctlr_destroy_store(bus, buf, count);
+ return fcoe_ctlr_destroy_store(buf, count);
}
static BUS_ATTR_WO(ctlr_destroy);
diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index 62341c6353a7..46b0bf237be1 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -745,8 +745,7 @@ static int libfcoe_device_notification(struct notifier_block *notifier,
return NOTIFY_OK;
}
-ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
- const char *buf, size_t count)
+ssize_t fcoe_ctlr_create_store(const char *buf, size_t count)
{
struct net_device *netdev = NULL;
struct fcoe_transport *ft = NULL;
@@ -808,8 +807,7 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
return count;
}
-ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
- const char *buf, size_t count)
+ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count)
{
int rc = -ENODEV;
struct net_device *netdev = NULL;
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index c258e8770285..78c875386c06 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -118,8 +118,8 @@ extern int __must_check bus_rescan_devices(struct bus_type *bus);
struct bus_attribute {
struct attribute attr;
- ssize_t (*show)(struct bus_type *bus, char *buf);
- ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
+ ssize_t (*show)(const struct bus_type *bus, char *buf);
+ ssize_t (*store)(const struct bus_type *bus, const char *buf, size_t count);
};
#define BUS_ATTR_RW(_name) \
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index 279782156373..8300ef1a982e 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -397,10 +397,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);
int fcoe_transport_detach(struct fcoe_transport *ft);
/* sysfs store handler for ctrl_control interface */
-ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
- const char *buf, size_t count);
-ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
- const char *buf, size_t count);
+ssize_t fcoe_ctlr_create_store(const char *buf, size_t count);
+ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count);
#endif /* _LIBFCOE_H */
--
2.39.2
Now that all accesses of dev_root is through the bus_get_dev_root()
call, move the pointer out of struct bus_type and into the private
dynamic structure, subsys_private.
With this change, there is no modifiable portions of struct bus_type so
it can be marked as a constant structure and moved to read-only memory.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/base.h | 2 ++
drivers/base/bus.c | 28 ++++++++++++++++++++++------
include/linux/device/bus.h | 2 --
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index b055eba1ec30..f1034e27e651 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -27,6 +27,7 @@
* on this bus.
* @bus - pointer back to the struct bus_type that this structure is associated
* with.
+ * @dev_root: Default device to use as the parent.
*
* @glue_dirs - "glue" directory to put in-between the parent device to
* avoid namespace conflicts
@@ -49,6 +50,7 @@ struct subsys_private {
struct blocking_notifier_head bus_notifier;
unsigned int drivers_autoprobe:1;
struct bus_type *bus;
+ struct device *dev_root;
struct kset glue_dirs;
struct class *class;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index dd4b82d7510f..91a6b6b1fc49 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -935,8 +935,8 @@ void bus_unregister(const struct bus_type *bus)
return;
pr_debug("bus: '%s': unregistering\n", bus->name);
- if (bus->dev_root)
- device_unregister(bus->dev_root);
+ if (sp->dev_root)
+ device_unregister(sp->dev_root);
bus_kobj = &sp->subsys.kobj;
sysfs_remove_groups(bus_kobj, bus->bus_groups);
@@ -1198,6 +1198,7 @@ static int subsys_register(struct bus_type *subsys,
const struct attribute_group **groups,
struct kobject *parent_of_root)
{
+ struct subsys_private *sp;
struct device *dev;
int err;
@@ -1205,6 +1206,12 @@ static int subsys_register(struct bus_type *subsys,
if (err < 0)
return err;
+ sp = bus_to_subsys(subsys);
+ if (!sp) {
+ err = -EINVAL;
+ goto err_sp;
+ }
+
dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (!dev) {
err = -ENOMEM;
@@ -1223,7 +1230,8 @@ static int subsys_register(struct bus_type *subsys,
if (err < 0)
goto err_dev_reg;
- subsys->dev_root = dev;
+ sp->dev_root = dev;
+ subsys_put(sp);
return 0;
err_dev_reg:
@@ -1232,6 +1240,8 @@ static int subsys_register(struct bus_type *subsys,
err_name:
kfree(dev);
err_dev:
+ subsys_put(sp);
+err_sp:
bus_unregister(subsys);
return err;
}
@@ -1349,9 +1359,15 @@ bool bus_is_registered(const struct bus_type *bus)
*/
struct device *bus_get_dev_root(const struct bus_type *bus)
{
- if (bus)
- return get_device(bus->dev_root);
- return NULL;
+ struct subsys_private *sp = bus_to_subsys(bus);
+ struct device *dev_root;
+
+ if (!sp)
+ return NULL;
+
+ dev_root = get_device(sp->dev_root);
+ subsys_put(sp);
+ return dev_root;
}
EXPORT_SYMBOL_GPL(bus_get_dev_root);
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 6ce32ef4b8fd..c258e8770285 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -26,7 +26,6 @@ struct fwnode_handle;
*
* @name: The name of the bus.
* @dev_name: Used for subsystems to enumerate devices like ("foo%u", dev->id).
- * @dev_root: Default device to use as the parent.
* @bus_groups: Default attributes of the bus.
* @dev_groups: Default attributes of the devices on the bus.
* @drv_groups: Default attributes of the device drivers on the bus.
@@ -82,7 +81,6 @@ struct fwnode_handle;
struct bus_type {
const char *name;
const char *dev_name;
- struct device *dev_root;
const struct attribute_group **bus_groups;
const struct attribute_group **dev_groups;
const struct attribute_group **drv_groups;
--
2.39.2
Direct access to the struct bus_type dev_root pointer is going away soon
so replace that with a call to bus_get_dev_root() instead, which is what
it is there for.
Cc: Borislav Petkov <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
arch/x86/kernel/cpu/microcode/core.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 7a329e561354..3afcf3de0dd4 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -632,6 +632,7 @@ static const struct attribute_group cpu_root_microcode_group = {
static int __init microcode_init(void)
{
+ struct device *dev_root;
struct cpuinfo_x86 *c = &boot_cpu_data;
int error;
@@ -652,10 +653,14 @@ static int __init microcode_init(void)
if (IS_ERR(microcode_pdev))
return PTR_ERR(microcode_pdev);
- error = sysfs_create_group(&cpu_subsys.dev_root->kobj, &cpu_root_microcode_group);
- if (error) {
- pr_err("Error creating microcode group!\n");
- goto out_pdev;
+ dev_root = bus_get_dev_root(&cpu_subsys);
+ if (dev_root) {
+ error = sysfs_create_group(&dev_root->kobj, &cpu_root_microcode_group);
+ put_device(dev_root);
+ if (error) {
+ pr_err("Error creating microcode group!\n");
+ goto out_pdev;
+ }
}
/* Do per-CPU setup */
--
2.39.2
Change the function arm_iommu_create_mapping() to take a pointer to a
const bus_type as the function does not modify the variable the pointer
points to at all, and the driver core bus functions it calls all expect
a const * type.
Cc: Russell King <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: "Russell King (Oracle)" <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Lukas Bulwahn <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
arch/arm/include/asm/dma-iommu.h | 2 +-
arch/arm/mm/dma-mapping.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
index fe9ef6f79e9c..82ec1ccf1fee 100644
--- a/arch/arm/include/asm/dma-iommu.h
+++ b/arch/arm/include/asm/dma-iommu.h
@@ -24,7 +24,7 @@ struct dma_iommu_mapping {
};
struct dma_iommu_mapping *
-arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size);
+arm_iommu_create_mapping(const struct bus_type *bus, dma_addr_t base, u64 size);
void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping);
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8bc01071474a..b4a33358d2e9 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1543,7 +1543,7 @@ static const struct dma_map_ops iommu_ops = {
* arm_iommu_attach_device function.
*/
struct dma_iommu_mapping *
-arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size)
+arm_iommu_create_mapping(const struct bus_type *bus, dma_addr_t base, u64 size)
{
unsigned int bits = size >> PAGE_SHIFT;
unsigned int bitmap_size = BITS_TO_LONGS(bits) * sizeof(long);
--
2.39.2
Now that the driver core can properly handle constant struct bus_type,
move all of the USB subsystem struct bus_type structures as const,
placing them into read-only memory which can not be modified at runtime.
Cc: Heikki Krogerus <[email protected]>
Cc: Johan Hovold <[email protected]>
Cc: Evan Green <[email protected]>
Cc: Alan Stern <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/usb/common/ulpi.c | 2 +-
drivers/usb/core/driver.c | 2 +-
drivers/usb/core/usb.h | 2 +-
drivers/usb/gadget/udc/core.c | 4 ++--
drivers/usb/serial/bus.c | 2 +-
drivers/usb/typec/bus.c | 2 +-
drivers/usb/typec/bus.h | 2 +-
include/linux/usb/serial.h | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index a98b2108376a..8305a5dfb910 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -90,7 +90,7 @@ static void ulpi_remove(struct device *dev)
drv->remove(to_ulpi_dev(dev));
}
-static struct bus_type ulpi_bus = {
+static const struct bus_type ulpi_bus = {
.name = "ulpi",
.match = ulpi_match,
.uevent = ulpi_uevent,
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index a0e076c6f3a4..f58a0299fb3b 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -2025,7 +2025,7 @@ int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
#endif /* CONFIG_PM */
-struct bus_type usb_bus_type = {
+const struct bus_type usb_bus_type = {
.name = "usb",
.match = usb_device_match,
.uevent = usb_uevent,
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 0eac7d4285d1..cd434af259c3 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -140,7 +140,7 @@ static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
#endif
-extern struct bus_type usb_bus_type;
+extern const struct bus_type usb_bus_type;
extern struct mutex usb_port_peer_mutex;
extern struct device_type usb_device_type;
extern struct device_type usb_if_device_type;
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 23b0629a8774..61a9c231deb9 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -26,7 +26,7 @@
static DEFINE_IDA(gadget_id_numbers);
-static struct bus_type gadget_bus_type;
+static const struct bus_type gadget_bus_type;
/**
* struct usb_udc - describes one usb device controller
@@ -1747,7 +1747,7 @@ static int usb_udc_uevent(const struct device *dev, struct kobj_uevent_env *env)
return 0;
}
-static struct bus_type gadget_bus_type = {
+static const struct bus_type gadget_bus_type = {
.name = "gadget",
.probe = gadget_bind_driver,
.remove = gadget_unbind_driver,
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 9e38142acd38..3eb8dc3a1a8f 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -144,7 +144,7 @@ static void free_dynids(struct usb_serial_driver *drv)
spin_unlock(&drv->dynids.lock);
}
-struct bus_type usb_serial_bus_type = {
+const struct bus_type usb_serial_bus_type = {
.name = "usb-serial",
.match = usb_serial_device_match,
.probe = usb_serial_device_probe,
diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
index 098f0efaa58d..fe5b9a2e61f5 100644
--- a/drivers/usb/typec/bus.c
+++ b/drivers/usb/typec/bus.c
@@ -431,7 +431,7 @@ static void typec_remove(struct device *dev)
adev->ops = NULL;
}
-struct bus_type typec_bus = {
+const struct bus_type typec_bus = {
.name = "typec",
.dev_groups = typec_groups,
.match = typec_match,
diff --git a/drivers/usb/typec/bus.h b/drivers/usb/typec/bus.h
index c89168857417..643b8c81786d 100644
--- a/drivers/usb/typec/bus.h
+++ b/drivers/usb/typec/bus.h
@@ -28,7 +28,7 @@ struct altmode {
#define to_altmode(d) container_of(d, struct altmode, adev)
-extern struct bus_type typec_bus;
+extern const struct bus_type typec_bus;
extern const struct device_type typec_altmode_dev_type;
#define is_typec_altmode(_dev_) (_dev_->type == &typec_altmode_dev_type)
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index f7bfedb740f5..7eeb5f9c4f0d 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -378,7 +378,7 @@ void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
int usb_serial_bus_register(struct usb_serial_driver *device);
void usb_serial_bus_deregister(struct usb_serial_driver *device);
-extern struct bus_type usb_serial_bus_type;
+extern const struct bus_type usb_serial_bus_type;
extern struct tty_driver *usb_serial_tty_driver;
static inline void usb_serial_debug_data(struct device *dev,
--
2.39.2
It's funny to think about getting a reference count of a constant
structure pointer, but this locks into place the private data
"underneath" the struct bus_type() which is important to not go away
while we are working with the bus structure for some callbacks.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/bus.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 8fea26c22521..84a21084d67d 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -84,7 +84,7 @@ static struct subsys_private *bus_to_subsys(const struct bus_type *bus)
return sp;
}
-static struct bus_type *bus_get(struct bus_type *bus)
+static const struct bus_type *bus_get(const struct bus_type *bus)
{
struct subsys_private *sp = bus_to_subsys(bus);
@@ -233,7 +233,7 @@ static const struct kset_uevent_ops bus_uevent_ops = {
static ssize_t unbind_store(struct device_driver *drv, const char *buf,
size_t count)
{
- struct bus_type *bus = bus_get(drv->bus);
+ const struct bus_type *bus = bus_get(drv->bus);
struct device *dev;
int err = -ENODEV;
@@ -256,7 +256,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
static ssize_t bind_store(struct device_driver *drv, const char *buf,
size_t count)
{
- struct bus_type *bus = bus_get(drv->bus);
+ const struct bus_type *bus = bus_get(drv->bus);
struct device *dev;
int err = -ENODEV;
--
2.39.2
The function, vhost_vdpa_alloc_domain(), has a pointer to a struct
bus_type, but it should be constant as the function it passes it to
expects it to be const, and the vhost code does not modify it in any
way.
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/vhost/vdpa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index dc12dbd5b43b..08c7cb3399fc 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1140,7 +1140,7 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
struct vdpa_device *vdpa = v->vdpa;
const struct vdpa_config_ops *ops = vdpa->config;
struct device *dma_dev = vdpa_get_dma_dev(vdpa);
- struct bus_type *bus;
+ const struct bus_type *bus;
int ret;
/* Device want to do DMA by itself */
--
2.39.2
The driver_find() function can now take a const * to bus_type, not just
a * so fix that up.
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/base/bus.c | 2 +-
include/linux/device/driver.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index ced61fad390e..8fea26c22521 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1307,7 +1307,7 @@ EXPORT_SYMBOL_GPL(subsys_virtual_register);
* from being unregistered or unloaded while the caller is using it.
* The caller is responsible for preventing this.
*/
-struct device_driver *driver_find(const char *name, struct bus_type *bus)
+struct device_driver *driver_find(const char *name, const struct bus_type *bus)
{
struct subsys_private *sp = bus_to_subsys(bus);
struct kobject *k;
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index 50d0a416a5e7..ceb0e477c2c8 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -126,7 +126,7 @@ extern int __must_check driver_register(struct device_driver *drv);
extern void driver_unregister(struct device_driver *drv);
extern struct device_driver *driver_find(const char *name,
- struct bus_type *bus);
+ const struct bus_type *bus);
extern int driver_probe_done(void);
extern void wait_for_device_probe(void);
void __init wait_for_init_devices_probe(void);
--
2.39.2
In the functions unbind_store() and bind_store(), a struct bus_type *
should be a const one, as the driver core bus functions used by this
variable are expecting the pointer to be constant, and these functions
do not modify the pointer at all.
Cc: Fenghua Yu <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
Note, this is a patch that is a prepatory cleanup as part of a larger
series of patches that is working on resolving some old driver core
design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
its own, but I'd prefer if I could take it through my driver-core tree
so that the driver core changes can be taken through there for 6.4-rc1.
drivers/dma/idxd/compat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
index 3df21615f888..5fd38d1b9d28 100644
--- a/drivers/dma/idxd/compat.c
+++ b/drivers/dma/idxd/compat.c
@@ -16,7 +16,7 @@ extern void device_driver_detach(struct device *dev);
static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
{
- struct bus_type *bus = drv->bus;
+ const struct bus_type *bus = drv->bus;
struct device *dev;
int rc = -ENODEV;
@@ -32,7 +32,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
{
- struct bus_type *bus = drv->bus;
+ const struct bus_type *bus = drv->bus;
struct device *dev;
struct device_driver *alt_drv = NULL;
int rc = -ENODEV;
--
2.39.2
On Mon, 2023-03-13 at 19:28 +0100, Greg Kroah-Hartman wrote:
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
>
> Cc: Yoshinori Sato <[email protected]>
> Cc: Rich Felker <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> drivers/sh/intc/userimask.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/sh/intc/userimask.c b/drivers/sh/intc/userimask.c
> index f9f043a3d90a..abe9091827cd 100644
> --- a/drivers/sh/intc/userimask.c
> +++ b/drivers/sh/intc/userimask.c
> @@ -61,10 +61,18 @@ static DEVICE_ATTR(userimask, S_IRUSR | S_IWUSR,
>
> static int __init userimask_sysdev_init(void)
> {
> + struct device *dev_root;
> + int ret = 0;
> +
> if (unlikely(!uimask))
> return -ENXIO;
>
> - return device_create_file(intc_subsys.dev_root, &dev_attr_userimask);
> + dev_root = bus_get_dev_root(&intc_subsys);
> + if (dev_root) {
> + ret = device_create_file(dev_root, &dev_attr_userimask);
> + put_device(dev_root);
> + }
> + return ret;
> }
> late_initcall(userimask_sysdev_init);
>
Acked-by: John Paul Adrian Glaubitz <[email protected]>
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
On Mon, Mar 13, 2023 at 7:29 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
>
> Cc: "Rafael J. Wysocki" <[email protected]>
> Cc: Viresh Kumar <[email protected]>
> Cc: Srinivas Pandruvada <[email protected]>
> Cc: Len Brown <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Rafael J. Wysocki <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> drivers/cpufreq/cpufreq.c | 7 ++++++-
> drivers/cpufreq/intel_pstate.c | 7 +++++--
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 6d8fd3b8dcb5..6ad3119b8e15 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2932,11 +2932,16 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);
> static int __init cpufreq_core_init(void)
> {
> struct cpufreq_governor *gov = cpufreq_default_governor();
> + struct device *dev_root;
>
> if (cpufreq_disabled())
> return -ENODEV;
>
> - cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj);
> + dev_root = bus_get_dev_root(&cpu_subsys);
> + if (dev_root) {
> + cpufreq_global_kobject = kobject_create_and_add("cpufreq", &dev_root->kobj);
> + put_device(dev_root);
> + }
> BUG_ON(!cpufreq_global_kobject);
>
> if (!strlen(default_governor))
> diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
> index 48a4613cef1e..102cf7f0ac63 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -1473,10 +1473,13 @@ static struct kobject *intel_pstate_kobject;
>
> static void __init intel_pstate_sysfs_expose_params(void)
> {
> + struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> int rc;
>
> - intel_pstate_kobject = kobject_create_and_add("intel_pstate",
> - &cpu_subsys.dev_root->kobj);
> + if (dev_root) {
> + intel_pstate_kobject = kobject_create_and_add("intel_pstate", &dev_root->kobj);
> + put_device(dev_root);
> + }
> if (WARN_ON(!intel_pstate_kobject))
> return;
>
> --
> 2.39.2
>
Hi, Greg,
On 3/13/23 11:29, Greg Kroah-Hartman wrote:
> In the functions unbind_store() and bind_store(), a struct bus_type *
> should be a const one, as the driver core bus functions used by this
> variable are expecting the pointer to be constant, and these functions
> do not modify the pointer at all.
>
> Cc: Fenghua Yu <[email protected]>
> Cc: Dave Jiang <[email protected]>
> Cc: Vinod Koul <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> drivers/dma/idxd/compat.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
> index 3df21615f888..5fd38d1b9d28 100644
> --- a/drivers/dma/idxd/compat.c
> +++ b/drivers/dma/idxd/compat.c
> @@ -16,7 +16,7 @@ extern void device_driver_detach(struct device *dev);
>
> static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
> {
> - struct bus_type *bus = drv->bus;
> + const struct bus_type *bus = drv->bus;
> struct device *dev;
> int rc = -ENODEV;
>
> @@ -32,7 +32,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
>
> static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
> {
> - struct bus_type *bus = drv->bus;
> + const struct bus_type *bus = drv->bus;
> struct device *dev;
> struct device_driver *alt_drv = NULL;
> int rc = -ENODEV;
After applying this patch, warning is reported:
drivers/dma/idxd/compat.c: In function ‘bind_store’:
drivers/dma/idxd/compat.c:47:47: warning: passing argument 2 of
‘driver_find’ discards ‘const’ qualifier from pointer target type
[-Wdiscarded-qualifiers]
47 | alt_drv = driver_find("idxd", bus);
| ^~~
In file included from ./include/linux/device.h:32,
from drivers/dma/idxd/compat.c:6:
./include/linux/device/driver.h:129:59: note: expected ‘struct bus_type
*’ but argument is of type ‘const struct bus_type *’
129 | struct bus_type *bus);
| ~~~~~~~~~~~~~~~~~^~~
Should the "bus" parameter in driver_find() definition be changed to
const as well to avoid the warning?
Thanks.
-Fenghua
On Mon, Mar 13, 2023 at 07:29:05PM +0100, Greg Kroah-Hartman wrote:
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
> Cc: "David S. Miller" <[email protected]>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: "Martin K. Petersen" <[email protected]>
> Cc: Alex Shi <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: Alexandre Bounine <[email protected]>
> Cc: Alison Schofield <[email protected]>
> Cc: Ben Widawsky <[email protected]>
> Cc: Bjorn Helgaas <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Hannes Reinecke <[email protected]>
> Cc: Harald Freudenberger <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Hu Haowen <[email protected]>
> Cc: Ilya Dryomov <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Cc: Iwona Winiarska <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Laurentiu Tudor <[email protected]>
> Cc: Matt Porter <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Stuart Yoder <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Yanteng Si <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Bjorn Helgaas <[email protected]> # pci
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index dd0d9d9bc509..ab32a91f287b 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -428,7 +428,7 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
> }
> static DEVICE_ATTR_RW(msi_bus);
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> unsigned long val;
> struct pci_bus *b = NULL;
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7a67611dc5f4..45c3bb039f21 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6679,7 +6679,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
> }
> }
>
> -static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
> +static ssize_t resource_alignment_show(const struct bus_type *bus, char *buf)
> {
> size_t count = 0;
>
> @@ -6691,7 +6691,7 @@ static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
> return count;
> }
>
> -static ssize_t resource_alignment_store(struct bus_type *bus,
> +static ssize_t resource_alignment_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> char *param, *old, *end;
On Mon, Mar 13, 2023 at 07:29:05PM +0100, Greg Kroah-Hartman wrote:
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
[...]
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index d24dd65b33d4..513adba09f56 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -684,7 +684,7 @@ static const struct attribute_group vmbus_dev_group = {
> __ATTRIBUTE_GROUPS(vmbus_dev);
>
> /* Set up the attribute for /sys/bus/vmbus/hibernation */
> -static ssize_t hibernation_show(struct bus_type *bus, char *buf)
> +static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
> {
> return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
> }
Acked-by: Wei Liu <[email protected]>
Greg Kroah-Hartman wrote:
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
> Cc: "David S. Miller" <[email protected]>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: "Martin K. Petersen" <[email protected]>
> Cc: Alex Shi <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: Alexandre Bounine <[email protected]>
> Cc: Alison Schofield <[email protected]>
> Cc: Ben Widawsky <[email protected]>
> Cc: Bjorn Helgaas <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Hannes Reinecke <[email protected]>
> Cc: Harald Freudenberger <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Hu Haowen <[email protected]>
> Cc: Ilya Dryomov <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Cc: Iwona Winiarska <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Laurentiu Tudor <[email protected]>
> Cc: Matt Porter <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Stuart Yoder <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Yanteng Si <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Ira Weiny <[email protected]> # cxl
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> Documentation/driver-api/driver-model/bus.rst | 4 +-
> Documentation/filesystems/sysfs.rst | 4 +-
> .../translations/zh_CN/filesystems/sysfs.txt | 4 +-
> .../translations/zh_TW/filesystems/sysfs.txt | 4 +-
> arch/powerpc/platforms/pseries/ibmebus.c | 4 +-
> arch/powerpc/platforms/pseries/vio.c | 8 ++--
> drivers/ata/pata_parport/pata_parport.c | 6 +--
> drivers/base/bus.c | 8 ++--
> drivers/block/rbd.c | 34 +++++++--------
> drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +--
> drivers/cxl/core/port.c | 2 +-
> drivers/hv/vmbus_drv.c | 2 +-
> drivers/net/netdevsim/bus.c | 4 +-
> drivers/pci/pci-sysfs.c | 2 +-
> drivers/pci/pci.c | 4 +-
> drivers/peci/sysfs.c | 2 +-
> drivers/rapidio/rio-sysfs.c | 2 +-
> drivers/s390/crypto/ap_bus.c | 42 +++++++++----------
> drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++--
> drivers/scsi/fcoe/fcoe_transport.c | 6 +--
> include/linux/device/bus.h | 4 +-
> include/scsi/libfcoe.h | 6 +--
> 22 files changed, 78 insertions(+), 88 deletions(-)
>
[...]
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 8ee6b6e2e2a4..66333cd6248e 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1927,7 +1927,7 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd)
> EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL);
>
> /* for user tooling to ensure port disable work has completed */
> -static ssize_t flush_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t flush_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (sysfs_streq(buf, "1")) {
> flush_workqueue(cxl_bus_wq);
On Mon, Mar 13, 2023 at 07:28:50PM +0100, Greg Kroah-Hartman wrote:
> Direct access to the struct bus_type dev_root pointer is going away soon
> so replace that with a call to bus_get_dev_root() instead, which is what
> it is there for.
>
> Cc: Tejun Heo <[email protected]>
> Cc: Lai Jiangshan <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Tejun Heo <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
Please feel free to route as you see fit.
Thanks.
--
tejun
On 2023-03-13 19:29, Greg Kroah-Hartman wrote:
> struct bus_type should never be modified in a sysfs callback as there
> is
> nothing in the structure to modify, and frankly, the structure is
> almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
> Cc: "David S. Miller" <[email protected]>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: "Martin K. Petersen" <[email protected]>
> Cc: Alex Shi <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: Alexandre Bounine <[email protected]>
> Cc: Alison Schofield <[email protected]>
> Cc: Ben Widawsky <[email protected]>
> Cc: Bjorn Helgaas <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Hannes Reinecke <[email protected]>
> Cc: Harald Freudenberger <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Hu Haowen <[email protected]>
> Cc: Ilya Dryomov <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Cc: Iwona Winiarska <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Laurentiu Tudor <[email protected]>
> Cc: Matt Porter <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Stuart Yoder <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Yanteng Si <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> Documentation/driver-api/driver-model/bus.rst | 4 +-
> Documentation/filesystems/sysfs.rst | 4 +-
> .../translations/zh_CN/filesystems/sysfs.txt | 4 +-
> .../translations/zh_TW/filesystems/sysfs.txt | 4 +-
> arch/powerpc/platforms/pseries/ibmebus.c | 4 +-
> arch/powerpc/platforms/pseries/vio.c | 8 ++--
> drivers/ata/pata_parport/pata_parport.c | 6 +--
> drivers/base/bus.c | 8 ++--
> drivers/block/rbd.c | 34 +++++++--------
> drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +--
> drivers/cxl/core/port.c | 2 +-
> drivers/hv/vmbus_drv.c | 2 +-
> drivers/net/netdevsim/bus.c | 4 +-
> drivers/pci/pci-sysfs.c | 2 +-
> drivers/pci/pci.c | 4 +-
> drivers/peci/sysfs.c | 2 +-
> drivers/rapidio/rio-sysfs.c | 2 +-
> drivers/s390/crypto/ap_bus.c | 42 +++++++++----------
> drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++--
> drivers/scsi/fcoe/fcoe_transport.c | 6 +--
> include/linux/device/bus.h | 4 +-
> include/scsi/libfcoe.h | 6 +--
> 22 files changed, 78 insertions(+), 88 deletions(-)
>
> diff --git a/Documentation/driver-api/driver-model/bus.rst
> b/Documentation/driver-api/driver-model/bus.rst
> index 016b15a6e8ea..9709ab62a468 100644
> --- a/Documentation/driver-api/driver-model/bus.rst
> +++ b/Documentation/driver-api/driver-model/bus.rst
> @@ -125,8 +125,8 @@ Exporting Attributes
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t
> count);
> };
>
> Bus drivers can export attributes using the BUS_ATTR_RW macro that
> works
> diff --git a/Documentation/filesystems/sysfs.rst
> b/Documentation/filesystems/sysfs.rst
> index f8187d466b97..c32993bc83c7 100644
> --- a/Documentation/filesystems/sysfs.rst
> +++ b/Documentation/filesystems/sysfs.rst
> @@ -373,8 +373,8 @@ Structure::
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t
> count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf,
> size_t count);
> };
>
> Declaring::
> diff --git a/Documentation/translations/zh_CN/filesystems/sysfs.txt
> b/Documentation/translations/zh_CN/filesystems/sysfs.txt
> index 046cc1d52058..547062759e60 100644
> --- a/Documentation/translations/zh_CN/filesystems/sysfs.txt
> +++ b/Documentation/translations/zh_CN/filesystems/sysfs.txt
> @@ -329,8 +329,8 @@ void device_remove_file(struct device *dev, const
> struct device_attribute * attr
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t
> count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf,
> size_t count);
> };
>
> 声明:
> diff --git a/Documentation/translations/zh_TW/filesystems/sysfs.txt
> b/Documentation/translations/zh_TW/filesystems/sysfs.txt
> index acd677f19d4f..280824cc7e5d 100644
> --- a/Documentation/translations/zh_TW/filesystems/sysfs.txt
> +++ b/Documentation/translations/zh_TW/filesystems/sysfs.txt
> @@ -332,8 +332,8 @@ void device_remove_file(struct device *dev, const
> struct device_attribute * attr
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t
> count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf,
> size_t count);
> };
>
> 聲明:
> diff --git a/arch/powerpc/platforms/pseries/ibmebus.c
> b/arch/powerpc/platforms/pseries/ibmebus.c
> index bb9c18682783..44703f13985b 100644
> --- a/arch/powerpc/platforms/pseries/ibmebus.c
> +++ b/arch/powerpc/platforms/pseries/ibmebus.c
> @@ -267,7 +267,7 @@ static char *ibmebus_chomp(const char *in, size_t
> count)
> return out;
> }
>
> -static ssize_t probe_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t probe_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> struct device_node *dn = NULL;
> struct device *dev;
> @@ -305,7 +305,7 @@ static ssize_t probe_store(struct bus_type *bus,
> const char *buf, size_t count)
> }
> static BUS_ATTR_WO(probe);
>
> -static ssize_t remove_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t remove_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> struct device *dev;
> char *path;
> diff --git a/arch/powerpc/platforms/pseries/vio.c
> b/arch/powerpc/platforms/pseries/vio.c
> index 770df9351aaa..bf7aff6390be 100644
> --- a/arch/powerpc/platforms/pseries/vio.c
> +++ b/arch/powerpc/platforms/pseries/vio.c
> @@ -1006,7 +1006,7 @@ ATTRIBUTE_GROUPS(vio_cmo_dev);
> /* sysfs bus functions and data structures for CMO */
>
> #define viobus_cmo_rd_attr(name)
> \
> -static ssize_t cmo_bus_##name##_show(struct bus_type *bt, char *buf)
> \
> +static ssize_t cmo_bus_##name##_show(const struct bus_type *bt, char
> *buf) \
> {
> \
> return sprintf(buf, "%lu\n", vio_cmo.name); \
> }
> \
> @@ -1015,7 +1015,7 @@ static struct bus_attribute
> bus_attr_cmo_bus_##name = \
>
> #define viobus_cmo_pool_rd_attr(name, var)
> \
> static ssize_t
> \
> -cmo_##name##_##var##_show(struct bus_type *bt, char *buf)
> \
> +cmo_##name##_##var##_show(const struct bus_type *bt, char *buf)
> \
> {
> \
> return sprintf(buf, "%lu\n", vio_cmo.name.var); \
> }
> \
> @@ -1030,12 +1030,12 @@ viobus_cmo_pool_rd_attr(reserve, size);
> viobus_cmo_pool_rd_attr(excess, size);
> viobus_cmo_pool_rd_attr(excess, free);
>
> -static ssize_t cmo_high_show(struct bus_type *bt, char *buf)
> +static ssize_t cmo_high_show(const struct bus_type *bt, char *buf)
> {
> return sprintf(buf, "%lu\n", vio_cmo.high);
> }
>
> -static ssize_t cmo_high_store(struct bus_type *bt, const char *buf,
> +static ssize_t cmo_high_store(const struct bus_type *bt, const char
> *buf,
> size_t count)
> {
> unsigned long flags;
> diff --git a/drivers/ata/pata_parport/pata_parport.c
> b/drivers/ata/pata_parport/pata_parport.c
> index 294a266a0dda..64d1bde26940 100644
> --- a/drivers/ata/pata_parport/pata_parport.c
> +++ b/drivers/ata/pata_parport/pata_parport.c
> @@ -554,8 +554,7 @@ void pata_parport_unregister_driver(struct
> pi_protocol *pr)
> }
> EXPORT_SYMBOL_GPL(pata_parport_unregister_driver);
>
> -static ssize_t new_device_store(struct bus_type *bus, const char *buf,
> - size_t count)
> +static ssize_t new_device_store(const struct bus_type *bus, const
> char *buf, size_t count)
> {
> char port[12] = "auto";
> char protocol[8] = "auto";
> @@ -630,8 +629,7 @@ static void pi_remove_one(struct device *dev)
> /* pata_parport_dev_release will do kfree(pi) */
> }
>
> -static ssize_t delete_device_store(struct bus_type *bus, const char
> *buf,
> - size_t count)
> +static ssize_t delete_device_store(const struct bus_type *bus, const
> char *buf, size_t count)
> {
> struct device *dev;
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 91a6b6b1fc49..819ab745fa9f 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -274,7 +274,7 @@ static ssize_t bind_store(struct device_driver
> *drv, const char *buf,
> }
> static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
>
> -static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
> +static ssize_t drivers_autoprobe_show(const struct bus_type *bus, char
> *buf)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> int ret;
> @@ -287,7 +287,7 @@ static ssize_t drivers_autoprobe_show(struct
> bus_type *bus, char *buf)
> return ret;
> }
>
> -static ssize_t drivers_autoprobe_store(struct bus_type *bus,
> +static ssize_t drivers_autoprobe_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> @@ -304,7 +304,7 @@ static ssize_t drivers_autoprobe_store(struct
> bus_type *bus,
> return count;
> }
>
> -static ssize_t drivers_probe_store(struct bus_type *bus,
> +static ssize_t drivers_probe_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct device *dev;
> @@ -808,7 +808,7 @@ static void klist_devices_put(struct klist_node *n)
> put_device(dev);
> }
>
> -static ssize_t bus_uevent_store(struct bus_type *bus,
> +static ssize_t bus_uevent_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 5cb008b9700a..84ad3b17956f 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -491,12 +491,12 @@ static bool single_major = true;
> module_param(single_major, bool, 0444);
> MODULE_PARM_DESC(single_major, "Use a single major number for all rbd
> devices (default: true)");
>
> -static ssize_t add_store(struct bus_type *bus, const char *buf, size_t
> count);
> -static ssize_t remove_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_store(const struct bus_type *bus, const char *buf,
> size_t count);
> +static ssize_t remove_store(const struct bus_type *bus, const char
> *buf,
> size_t count);
> -static ssize_t add_single_major_store(struct bus_type *bus, const char
> *buf,
> +static ssize_t add_single_major_store(const struct bus_type *bus,
> const char *buf,
> size_t count);
> -static ssize_t remove_single_major_store(struct bus_type *bus, const
> char *buf,
> +static ssize_t remove_single_major_store(const struct bus_type *bus,
> const char *buf,
> size_t count);
> static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth);
>
> @@ -538,7 +538,7 @@ static bool rbd_is_lock_owner(struct rbd_device
> *rbd_dev)
> return is_lock_owner;
> }
>
> -static ssize_t supported_features_show(struct bus_type *bus, char
> *buf)
> +static ssize_t supported_features_show(const struct bus_type *bus,
> char *buf)
> {
> return sprintf(buf, "0x%llx\n", RBD_FEATURES_SUPPORTED);
> }
> @@ -6967,9 +6967,7 @@ static int rbd_dev_image_probe(struct rbd_device
> *rbd_dev, int depth)
> return ret;
> }
>
> -static ssize_t do_rbd_add(struct bus_type *bus,
> - const char *buf,
> - size_t count)
> +static ssize_t do_rbd_add(const char *buf, size_t count)
> {
> struct rbd_device *rbd_dev = NULL;
> struct ceph_options *ceph_opts = NULL;
> @@ -7081,18 +7079,18 @@ static ssize_t do_rbd_add(struct bus_type *bus,
> goto out;
> }
>
> -static ssize_t add_store(struct bus_type *bus, const char *buf, size_t
> count)
> +static ssize_t add_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> if (single_major)
> return -EINVAL;
>
> - return do_rbd_add(bus, buf, count);
> + return do_rbd_add(buf, count);
> }
>
> -static ssize_t add_single_major_store(struct bus_type *bus, const char
> *buf,
> +static ssize_t add_single_major_store(const struct bus_type *bus,
> const char *buf,
> size_t count)
> {
> - return do_rbd_add(bus, buf, count);
> + return do_rbd_add(buf, count);
> }
>
> static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
> @@ -7122,9 +7120,7 @@ static void rbd_dev_remove_parent(struct
> rbd_device *rbd_dev)
> }
> }
>
> -static ssize_t do_rbd_remove(struct bus_type *bus,
> - const char *buf,
> - size_t count)
> +static ssize_t do_rbd_remove(const char *buf, size_t count)
> {
> struct rbd_device *rbd_dev = NULL;
> struct list_head *tmp;
> @@ -7196,18 +7192,18 @@ static ssize_t do_rbd_remove(struct bus_type
> *bus,
> return count;
> }
>
> -static ssize_t remove_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t remove_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> if (single_major)
> return -EINVAL;
>
> - return do_rbd_remove(bus, buf, count);
> + return do_rbd_remove(buf, count);
> }
>
> -static ssize_t remove_single_major_store(struct bus_type *bus, const
> char *buf,
> +static ssize_t remove_single_major_store(const struct bus_type *bus,
> const char *buf,
> size_t count)
> {
> - return do_rbd_remove(bus, buf, count);
> + return do_rbd_remove(buf, count);
> }
>
> /*
> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c
> b/drivers/bus/fsl-mc/fsl-mc-bus.c
> index 36cb091a33b4..653e2d4c116f 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
> @@ -231,7 +231,7 @@ static int scan_fsl_mc_bus(struct device *dev, void
> *data)
> return 0;
> }
>
> -static ssize_t rescan_store(struct bus_type *bus,
> +static ssize_t rescan_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> unsigned long val;
> @@ -284,7 +284,7 @@ static int fsl_mc_bus_get_autorescan(struct device
> *dev, void *data)
> return 0;
> }
>
> -static ssize_t autorescan_store(struct bus_type *bus,
> +static ssize_t autorescan_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_set_autorescan);
> @@ -292,7 +292,7 @@ static ssize_t autorescan_store(struct bus_type
> *bus,
> return count;
> }
>
> -static ssize_t autorescan_show(struct bus_type *bus, char *buf)
> +static ssize_t autorescan_show(const struct bus_type *bus, char *buf)
> {
> bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_get_autorescan);
> return strlen(buf);
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 8ee6b6e2e2a4..66333cd6248e 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1927,7 +1927,7 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev
> *cxlmd)
> EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL);
>
> /* for user tooling to ensure port disable work has completed */
> -static ssize_t flush_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t flush_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> if (sysfs_streq(buf, "1")) {
> flush_workqueue(cxl_bus_wq);
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index d24dd65b33d4..513adba09f56 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -684,7 +684,7 @@ static const struct attribute_group vmbus_dev_group
> = {
> __ATTRIBUTE_GROUPS(vmbus_dev);
>
> /* Set up the attribute for /sys/bus/vmbus/hibernation */
> -static ssize_t hibernation_show(struct bus_type *bus, char *buf)
> +static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
> {
> return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
> }
> diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
> index 0052968e881e..0787ad252dd9 100644
> --- a/drivers/net/netdevsim/bus.c
> +++ b/drivers/net/netdevsim/bus.c
> @@ -132,7 +132,7 @@ static struct nsim_bus_dev *
> nsim_bus_dev_new(unsigned int id, unsigned int port_count, unsigned
> int num_queues);
>
> static ssize_t
> -new_device_store(struct bus_type *bus, const char *buf, size_t count)
> +new_device_store(const struct bus_type *bus, const char *buf, size_t
> count)
> {
> unsigned int id, port_count, num_queues;
> struct nsim_bus_dev *nsim_bus_dev;
> @@ -186,7 +186,7 @@ static BUS_ATTR_WO(new_device);
> static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev);
>
> static ssize_t
> -del_device_store(struct bus_type *bus, const char *buf, size_t count)
> +del_device_store(const struct bus_type *bus, const char *buf, size_t
> count)
> {
> struct nsim_bus_dev *nsim_bus_dev, *tmp;
> unsigned int id;
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index dd0d9d9bc509..ab32a91f287b 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -428,7 +428,7 @@ static ssize_t msi_bus_store(struct device *dev,
> struct device_attribute *attr,
> }
> static DEVICE_ATTR_RW(msi_bus);
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> unsigned long val;
> struct pci_bus *b = NULL;
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7a67611dc5f4..45c3bb039f21 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6679,7 +6679,7 @@ void pci_reassigndev_resource_alignment(struct
> pci_dev *dev)
> }
> }
>
> -static ssize_t resource_alignment_show(struct bus_type *bus, char
> *buf)
> +static ssize_t resource_alignment_show(const struct bus_type *bus,
> char *buf)
> {
> size_t count = 0;
>
> @@ -6691,7 +6691,7 @@ static ssize_t resource_alignment_show(struct
> bus_type *bus, char *buf)
> return count;
> }
>
> -static ssize_t resource_alignment_store(struct bus_type *bus,
> +static ssize_t resource_alignment_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> char *param, *old, *end;
> diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c
> index db9ef05776e3..c04244075794 100644
> --- a/drivers/peci/sysfs.c
> +++ b/drivers/peci/sysfs.c
> @@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void
> *data)
> return peci_controller_scan_devices(to_peci_controller(dev));
> }
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> bool res;
> int ret;
> diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
> index f7679602498e..90d391210533 100644
> --- a/drivers/rapidio/rio-sysfs.c
> +++ b/drivers/rapidio/rio-sysfs.c
> @@ -286,7 +286,7 @@ const struct attribute_group *rio_dev_groups[] = {
> NULL,
> };
>
> -static ssize_t scan_store(struct bus_type *bus, const char *buf,
> size_t count)
> +static ssize_t scan_store(const struct bus_type *bus, const char
> *buf, size_t count)
> {
> long val;
> int rc;
> diff --git a/drivers/s390/crypto/ap_bus.c
> b/drivers/s390/crypto/ap_bus.c
> index f4cc1720156f..5a99e0b18289 100644
> --- a/drivers/s390/crypto/ap_bus.c
> +++ b/drivers/s390/crypto/ap_bus.c
> @@ -1166,12 +1166,12 @@ EXPORT_SYMBOL(ap_parse_mask_str);
> * AP bus attributes.
> */
>
> -static ssize_t ap_domain_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_domain_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index);
> }
>
> -static ssize_t ap_domain_store(struct bus_type *bus,
> +static ssize_t ap_domain_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int domain;
> @@ -1193,7 +1193,7 @@ static ssize_t ap_domain_store(struct bus_type
> *bus,
>
> static BUS_ATTR_RW(ap_domain);
>
> -static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char
> *buf)
> +static ssize_t ap_control_domain_mask_show(const struct bus_type
> *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1208,7 +1208,7 @@ static ssize_t
> ap_control_domain_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_control_domain_mask);
>
> -static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char
> *buf)
> +static ssize_t ap_usage_domain_mask_show(const struct bus_type *bus,
> char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1223,7 +1223,7 @@ static ssize_t ap_usage_domain_mask_show(struct
> bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_usage_domain_mask);
>
> -static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_adapter_mask_show(const struct bus_type *bus, char
> *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1238,7 +1238,7 @@ static ssize_t ap_adapter_mask_show(struct
> bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_adapter_mask);
>
> -static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_interrupts_show(const struct bus_type *bus, char
> *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n",
> ap_irq_flag ? 1 : 0);
> @@ -1246,12 +1246,12 @@ static ssize_t ap_interrupts_show(struct
> bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_interrupts);
>
> -static ssize_t config_time_show(struct bus_type *bus, char *buf)
> +static ssize_t config_time_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_config_time);
> }
>
> -static ssize_t config_time_store(struct bus_type *bus,
> +static ssize_t config_time_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int time;
> @@ -1265,12 +1265,12 @@ static ssize_t config_time_store(struct
> bus_type *bus,
>
> static BUS_ATTR_RW(config_time);
>
> -static ssize_t poll_thread_show(struct bus_type *bus, char *buf)
> +static ssize_t poll_thread_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_poll_kthread ? 1 : 0);
> }
>
> -static ssize_t poll_thread_store(struct bus_type *bus,
> +static ssize_t poll_thread_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int flag, rc;
> @@ -1289,12 +1289,12 @@ static ssize_t poll_thread_store(struct
> bus_type *bus,
>
> static BUS_ATTR_RW(poll_thread);
>
> -static ssize_t poll_timeout_show(struct bus_type *bus, char *buf)
> +static ssize_t poll_timeout_show(const struct bus_type *bus, char
> *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%llu\n", poll_timeout);
> }
>
> -static ssize_t poll_timeout_store(struct bus_type *bus, const char
> *buf,
> +static ssize_t poll_timeout_store(const struct bus_type *bus, const
> char *buf,
> size_t count)
> {
> unsigned long long time;
> @@ -1318,21 +1318,21 @@ static ssize_t poll_timeout_store(struct
> bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(poll_timeout);
>
> -static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_max_domain_id_show(const struct bus_type *bus, char
> *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_domain_id);
> }
>
> static BUS_ATTR_RO(ap_max_domain_id);
>
> -static ssize_t ap_max_adapter_id_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_max_adapter_id_show(const struct bus_type *bus, char
> *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_adapter_id);
> }
>
> static BUS_ATTR_RO(ap_max_adapter_id);
>
> -static ssize_t apmask_show(struct bus_type *bus, char *buf)
> +static ssize_t apmask_show(const struct bus_type *bus, char *buf)
> {
> int rc;
>
> @@ -1393,7 +1393,7 @@ static int apmask_commit(unsigned long *newapm)
> return 0;
> }
>
> -static ssize_t apmask_store(struct bus_type *bus, const char *buf,
> +static ssize_t apmask_store(const struct bus_type *bus, const char
> *buf,
> size_t count)
> {
> int rc, changes = 0;
> @@ -1425,7 +1425,7 @@ static ssize_t apmask_store(struct bus_type
> *bus, const char *buf,
>
> static BUS_ATTR_RW(apmask);
>
> -static ssize_t aqmask_show(struct bus_type *bus, char *buf)
> +static ssize_t aqmask_show(const struct bus_type *bus, char *buf)
> {
> int rc;
>
> @@ -1486,7 +1486,7 @@ static int aqmask_commit(unsigned long *newaqm)
> return 0;
> }
>
> -static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
> +static ssize_t aqmask_store(const struct bus_type *bus, const char
> *buf,
> size_t count)
> {
> int rc, changes = 0;
> @@ -1518,13 +1518,13 @@ static ssize_t aqmask_store(struct bus_type
> *bus, const char *buf,
>
> static BUS_ATTR_RW(aqmask);
>
> -static ssize_t scans_show(struct bus_type *bus, char *buf)
> +static ssize_t scans_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%llu\n",
> atomic64_read(&ap_scan_bus_count));
> }
>
> -static ssize_t scans_store(struct bus_type *bus, const char *buf,
> +static ssize_t scans_store(const struct bus_type *bus, const char
> *buf,
> size_t count)
> {
> AP_DBF_INFO("%s force AP bus rescan\n", __func__);
> @@ -1536,7 +1536,7 @@ static ssize_t scans_store(struct bus_type *bus,
> const char *buf,
>
> static BUS_ATTR_RW(scans);
>
> -static ssize_t bindings_show(struct bus_type *bus, char *buf)
> +static ssize_t bindings_show(const struct bus_type *bus, char *buf)
> {
> int rc;
> unsigned int apqns, n;
> diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c
> b/drivers/scsi/fcoe/fcoe_sysfs.c
> index 6260aa5ea6af..e17957f8085c 100644
> --- a/drivers/scsi/fcoe/fcoe_sysfs.c
> +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
> @@ -659,17 +659,17 @@ static const struct device_type
> fcoe_fcf_device_type = {
> .release = fcoe_fcf_device_release,
> };
>
> -static ssize_t ctlr_create_store(struct bus_type *bus, const char
> *buf,
> +static ssize_t ctlr_create_store(const struct bus_type *bus, const
> char *buf,
> size_t count)
> {
> - return fcoe_ctlr_create_store(bus, buf, count);
> + return fcoe_ctlr_create_store(buf, count);
> }
> static BUS_ATTR_WO(ctlr_create);
>
> -static ssize_t ctlr_destroy_store(struct bus_type *bus, const char
> *buf,
> +static ssize_t ctlr_destroy_store(const struct bus_type *bus, const
> char *buf,
> size_t count)
> {
> - return fcoe_ctlr_destroy_store(bus, buf, count);
> + return fcoe_ctlr_destroy_store(buf, count);
> }
> static BUS_ATTR_WO(ctlr_destroy);
>
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c
> b/drivers/scsi/fcoe/fcoe_transport.c
> index 62341c6353a7..46b0bf237be1 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -745,8 +745,7 @@ static int libfcoe_device_notification(struct
> notifier_block *notifier,
> return NOTIFY_OK;
> }
>
> -ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> - const char *buf, size_t count)
> +ssize_t fcoe_ctlr_create_store(const char *buf, size_t count)
> {
> struct net_device *netdev = NULL;
> struct fcoe_transport *ft = NULL;
> @@ -808,8 +807,7 @@ ssize_t fcoe_ctlr_create_store(struct bus_type
> *bus,
> return count;
> }
>
> -ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
> - const char *buf, size_t count)
> +ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count)
> {
> int rc = -ENODEV;
> struct net_device *netdev = NULL;
> diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
> index c258e8770285..78c875386c06 100644
> --- a/include/linux/device/bus.h
> +++ b/include/linux/device/bus.h
> @@ -118,8 +118,8 @@ extern int __must_check bus_rescan_devices(struct
> bus_type *bus);
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *bus, char *buf);
> - ssize_t (*store)(struct bus_type *bus, const char *buf, size_t
> count);
> + ssize_t (*show)(const struct bus_type *bus, char *buf);
> + ssize_t (*store)(const struct bus_type *bus, const char *buf, size_t
> count);
> };
>
> #define BUS_ATTR_RW(_name) \
> diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
> index 279782156373..8300ef1a982e 100644
> --- a/include/scsi/libfcoe.h
> +++ b/include/scsi/libfcoe.h
> @@ -397,10 +397,8 @@ int fcoe_transport_attach(struct fcoe_transport
> *ft);
> int fcoe_transport_detach(struct fcoe_transport *ft);
>
> /* sysfs store handler for ctrl_control interface */
> -ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> - const char *buf, size_t count);
> -ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
> - const char *buf, size_t count);
> +ssize_t fcoe_ctlr_create_store(const char *buf, size_t count);
> +ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count);
>
> #endif /* _LIBFCOE_H */
For the ap_bus.c part: Reviewed-by: Harald Freudenberger
<[email protected]>
On Mon, Mar 13, 2023 at 07:29:11PM +0100, Greg Kroah-Hartman wrote:
> In the function, qm_get_qos_value(), a struct bus_type * is used, but it
> really should be a const pointer as it is not modified anywhere in the
> function, and the driver core function it is used in expects a constant
> pointer.
>
> Cc: Weili Qian <[email protected]>
> Cc: Zhou Wang <[email protected]>
> Cc: Herbert Xu <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> drivers/crypto/hisilicon/qm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Herbert Xu <[email protected]>
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
On Mon, Mar 13, 2023 at 07:29:18PM +0100, Greg Kroah-Hartman wrote:
> Now that the driver core can properly handle constant struct bus_type,
> move all of the USB subsystem struct bus_type structures as const,
> placing them into read-only memory which can not be modified at runtime.
>
> Cc: Heikki Krogerus <[email protected]>
> Cc: Johan Hovold <[email protected]>
> Cc: Evan Green <[email protected]>
> Cc: Alan Stern <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Heikki Krogerus <[email protected]>
> ---
> drivers/usb/common/ulpi.c | 2 +-
> drivers/usb/core/driver.c | 2 +-
> drivers/usb/core/usb.h | 2 +-
> drivers/usb/gadget/udc/core.c | 4 ++--
> drivers/usb/serial/bus.c | 2 +-
> drivers/usb/typec/bus.c | 2 +-
> drivers/usb/typec/bus.h | 2 +-
> include/linux/usb/serial.h | 2 +-
> 8 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
> index a98b2108376a..8305a5dfb910 100644
> --- a/drivers/usb/common/ulpi.c
> +++ b/drivers/usb/common/ulpi.c
> @@ -90,7 +90,7 @@ static void ulpi_remove(struct device *dev)
> drv->remove(to_ulpi_dev(dev));
> }
>
> -static struct bus_type ulpi_bus = {
> +static const struct bus_type ulpi_bus = {
> .name = "ulpi",
> .match = ulpi_match,
> .uevent = ulpi_uevent,
> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
> index a0e076c6f3a4..f58a0299fb3b 100644
> --- a/drivers/usb/core/driver.c
> +++ b/drivers/usb/core/driver.c
> @@ -2025,7 +2025,7 @@ int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
>
> #endif /* CONFIG_PM */
>
> -struct bus_type usb_bus_type = {
> +const struct bus_type usb_bus_type = {
> .name = "usb",
> .match = usb_device_match,
> .uevent = usb_uevent,
> diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
> index 0eac7d4285d1..cd434af259c3 100644
> --- a/drivers/usb/core/usb.h
> +++ b/drivers/usb/core/usb.h
> @@ -140,7 +140,7 @@ static inline int usb_disable_usb2_hardware_lpm(struct usb_device *udev)
>
> #endif
>
> -extern struct bus_type usb_bus_type;
> +extern const struct bus_type usb_bus_type;
> extern struct mutex usb_port_peer_mutex;
> extern struct device_type usb_device_type;
> extern struct device_type usb_if_device_type;
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index 23b0629a8774..61a9c231deb9 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -26,7 +26,7 @@
>
> static DEFINE_IDA(gadget_id_numbers);
>
> -static struct bus_type gadget_bus_type;
> +static const struct bus_type gadget_bus_type;
>
> /**
> * struct usb_udc - describes one usb device controller
> @@ -1747,7 +1747,7 @@ static int usb_udc_uevent(const struct device *dev, struct kobj_uevent_env *env)
> return 0;
> }
>
> -static struct bus_type gadget_bus_type = {
> +static const struct bus_type gadget_bus_type = {
> .name = "gadget",
> .probe = gadget_bind_driver,
> .remove = gadget_unbind_driver,
> diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
> index 9e38142acd38..3eb8dc3a1a8f 100644
> --- a/drivers/usb/serial/bus.c
> +++ b/drivers/usb/serial/bus.c
> @@ -144,7 +144,7 @@ static void free_dynids(struct usb_serial_driver *drv)
> spin_unlock(&drv->dynids.lock);
> }
>
> -struct bus_type usb_serial_bus_type = {
> +const struct bus_type usb_serial_bus_type = {
> .name = "usb-serial",
> .match = usb_serial_device_match,
> .probe = usb_serial_device_probe,
> diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
> index 098f0efaa58d..fe5b9a2e61f5 100644
> --- a/drivers/usb/typec/bus.c
> +++ b/drivers/usb/typec/bus.c
> @@ -431,7 +431,7 @@ static void typec_remove(struct device *dev)
> adev->ops = NULL;
> }
>
> -struct bus_type typec_bus = {
> +const struct bus_type typec_bus = {
> .name = "typec",
> .dev_groups = typec_groups,
> .match = typec_match,
> diff --git a/drivers/usb/typec/bus.h b/drivers/usb/typec/bus.h
> index c89168857417..643b8c81786d 100644
> --- a/drivers/usb/typec/bus.h
> +++ b/drivers/usb/typec/bus.h
> @@ -28,7 +28,7 @@ struct altmode {
>
> #define to_altmode(d) container_of(d, struct altmode, adev)
>
> -extern struct bus_type typec_bus;
> +extern const struct bus_type typec_bus;
> extern const struct device_type typec_altmode_dev_type;
>
> #define is_typec_altmode(_dev_) (_dev_->type == &typec_altmode_dev_type)
> diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
> index f7bfedb740f5..7eeb5f9c4f0d 100644
> --- a/include/linux/usb/serial.h
> +++ b/include/linux/usb/serial.h
> @@ -378,7 +378,7 @@ void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
> int usb_serial_bus_register(struct usb_serial_driver *device);
> void usb_serial_bus_deregister(struct usb_serial_driver *device);
>
> -extern struct bus_type usb_serial_bus_type;
> +extern const struct bus_type usb_serial_bus_type;
> extern struct tty_driver *usb_serial_tty_driver;
>
> static inline void usb_serial_debug_data(struct device *dev,
> --
> 2.39.2
--
heikki
Greg Kroah-Hartman wrote:
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
[..]
> Cc: Dan Williams <[email protected]>
[..]
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 8ee6b6e2e2a4..66333cd6248e 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1927,7 +1927,7 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd)
> EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL);
>
> /* for user tooling to ensure port disable work has completed */
> -static ssize_t flush_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t flush_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (sysfs_streq(buf, "1")) {
> flush_workqueue(cxl_bus_wq);
For CXL:
Acked-by: Dan Williams <[email protected]>
Greg,
> struct bus_type should never be modified in a sysfs callback as there
> is nothing in the structure to modify, and frankly, the structure is
> almost never used in a sysfs callback, so mark it as constant to allow
> struct bus_type to be moved to read-only memory.
Acked-by: Martin K. Petersen <[email protected]> # scsi
--
Martin K. Petersen Oracle Linux Engineering
On 13/03/2023 18:29, Greg Kroah-Hartman wrote:
> The struct bus_type pointers in the functions
> intel_huc_register_gsc_notifier() and
> intel_huc_unregister_gsc_notifier() should be a const pointer, as the
> structure is not modified anywhere in the functions, and the pointer
> they are passed will be a const * in the near future.
>
> Cc: Jani Nikula <[email protected]>
> Cc: Joonas Lahtinen <[email protected]>
> Cc: Rodrigo Vivi <[email protected]>
> Cc: Tvrtko Ursulin <[email protected]>
> Cc: David Airlie <[email protected]>
> Cc: Daniel Vetter <[email protected]>
> Cc: Daniele Ceraolo Spurio <[email protected]>
> Cc: Alan Previn <[email protected]>
> Cc: John Harrison <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Tony Ye <[email protected]>
> Cc: Vitaly Lubart <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
Sounds fine to me.
Acked-by: Tvrtko Ursulin <[email protected]>
Regards,
Tvrtko
>
> drivers/gpu/drm/i915/gt/uc/intel_huc.c | 4 ++--
> drivers/gpu/drm/i915/gt/uc/intel_huc.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_huc.c b/drivers/gpu/drm/i915/gt/uc/intel_huc.c
> index 410905da8e97..8b453bd7c953 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_huc.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_huc.c
> @@ -183,7 +183,7 @@ static int gsc_notifier(struct notifier_block *nb, unsigned long action, void *d
> return 0;
> }
>
> -void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus)
> +void intel_huc_register_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus)
> {
> int ret;
>
> @@ -200,7 +200,7 @@ void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus
> }
> }
>
> -void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *bus)
> +void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus)
> {
> if (!huc->delayed_load.nb.notifier_call)
> return;
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_huc.h b/drivers/gpu/drm/i915/gt/uc/intel_huc.h
> index 52db03620c60..05d4832f8461 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_huc.h
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_huc.h
> @@ -51,8 +51,8 @@ int intel_huc_check_status(struct intel_huc *huc);
> void intel_huc_update_auth_status(struct intel_huc *huc);
> bool intel_huc_is_authenticated(struct intel_huc *huc);
>
> -void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus);
> -void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *bus);
> +void intel_huc_register_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus);
> +void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, const struct bus_type *bus);
>
> static inline int intel_huc_sanitize(struct intel_huc *huc)
> {
On Mon, Mar 13, 2023 at 7:30 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
> Cc: "David S. Miller" <[email protected]>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: "Martin K. Petersen" <[email protected]>
> Cc: Alex Shi <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: Alexandre Bounine <[email protected]>
> Cc: Alison Schofield <[email protected]>
> Cc: Ben Widawsky <[email protected]>
> Cc: Bjorn Helgaas <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Hannes Reinecke <[email protected]>
> Cc: Harald Freudenberger <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Hu Haowen <[email protected]>
> Cc: Ilya Dryomov <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Cc: Iwona Winiarska <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Laurentiu Tudor <[email protected]>
> Cc: Matt Porter <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Stuart Yoder <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Yanteng Si <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> Documentation/driver-api/driver-model/bus.rst | 4 +-
> Documentation/filesystems/sysfs.rst | 4 +-
> .../translations/zh_CN/filesystems/sysfs.txt | 4 +-
> .../translations/zh_TW/filesystems/sysfs.txt | 4 +-
> arch/powerpc/platforms/pseries/ibmebus.c | 4 +-
> arch/powerpc/platforms/pseries/vio.c | 8 ++--
> drivers/ata/pata_parport/pata_parport.c | 6 +--
> drivers/base/bus.c | 8 ++--
> drivers/block/rbd.c | 34 +++++++--------
> drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +--
> drivers/cxl/core/port.c | 2 +-
> drivers/hv/vmbus_drv.c | 2 +-
> drivers/net/netdevsim/bus.c | 4 +-
> drivers/pci/pci-sysfs.c | 2 +-
> drivers/pci/pci.c | 4 +-
> drivers/peci/sysfs.c | 2 +-
> drivers/rapidio/rio-sysfs.c | 2 +-
> drivers/s390/crypto/ap_bus.c | 42 +++++++++----------
> drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++--
> drivers/scsi/fcoe/fcoe_transport.c | 6 +--
> include/linux/device/bus.h | 4 +-
> include/scsi/libfcoe.h | 6 +--
> 22 files changed, 78 insertions(+), 88 deletions(-)
>
> diff --git a/Documentation/driver-api/driver-model/bus.rst b/Documentation/driver-api/driver-model/bus.rst
> index 016b15a6e8ea..9709ab62a468 100644
> --- a/Documentation/driver-api/driver-model/bus.rst
> +++ b/Documentation/driver-api/driver-model/bus.rst
> @@ -125,8 +125,8 @@ Exporting Attributes
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> Bus drivers can export attributes using the BUS_ATTR_RW macro that works
> diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystems/sysfs.rst
> index f8187d466b97..c32993bc83c7 100644
> --- a/Documentation/filesystems/sysfs.rst
> +++ b/Documentation/filesystems/sysfs.rst
> @@ -373,8 +373,8 @@ Structure::
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> Declaring::
> diff --git a/Documentation/translations/zh_CN/filesystems/sysfs.txt b/Documentation/translations/zh_CN/filesystems/sysfs.txt
> index 046cc1d52058..547062759e60 100644
> --- a/Documentation/translations/zh_CN/filesystems/sysfs.txt
> +++ b/Documentation/translations/zh_CN/filesystems/sysfs.txt
> @@ -329,8 +329,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> 声明:
> diff --git a/Documentation/translations/zh_TW/filesystems/sysfs.txt b/Documentation/translations/zh_TW/filesystems/sysfs.txt
> index acd677f19d4f..280824cc7e5d 100644
> --- a/Documentation/translations/zh_TW/filesystems/sysfs.txt
> +++ b/Documentation/translations/zh_TW/filesystems/sysfs.txt
> @@ -332,8 +332,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> 聲明:
> diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
> index bb9c18682783..44703f13985b 100644
> --- a/arch/powerpc/platforms/pseries/ibmebus.c
> +++ b/arch/powerpc/platforms/pseries/ibmebus.c
> @@ -267,7 +267,7 @@ static char *ibmebus_chomp(const char *in, size_t count)
> return out;
> }
>
> -static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t probe_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct device_node *dn = NULL;
> struct device *dev;
> @@ -305,7 +305,7 @@ static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
> }
> static BUS_ATTR_WO(probe);
>
> -static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct device *dev;
> char *path;
> diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
> index 770df9351aaa..bf7aff6390be 100644
> --- a/arch/powerpc/platforms/pseries/vio.c
> +++ b/arch/powerpc/platforms/pseries/vio.c
> @@ -1006,7 +1006,7 @@ ATTRIBUTE_GROUPS(vio_cmo_dev);
> /* sysfs bus functions and data structures for CMO */
>
> #define viobus_cmo_rd_attr(name) \
> -static ssize_t cmo_bus_##name##_show(struct bus_type *bt, char *buf) \
> +static ssize_t cmo_bus_##name##_show(const struct bus_type *bt, char *buf) \
> { \
> return sprintf(buf, "%lu\n", vio_cmo.name); \
> } \
> @@ -1015,7 +1015,7 @@ static struct bus_attribute bus_attr_cmo_bus_##name = \
>
> #define viobus_cmo_pool_rd_attr(name, var) \
> static ssize_t \
> -cmo_##name##_##var##_show(struct bus_type *bt, char *buf) \
> +cmo_##name##_##var##_show(const struct bus_type *bt, char *buf) \
> { \
> return sprintf(buf, "%lu\n", vio_cmo.name.var); \
> } \
> @@ -1030,12 +1030,12 @@ viobus_cmo_pool_rd_attr(reserve, size);
> viobus_cmo_pool_rd_attr(excess, size);
> viobus_cmo_pool_rd_attr(excess, free);
>
> -static ssize_t cmo_high_show(struct bus_type *bt, char *buf)
> +static ssize_t cmo_high_show(const struct bus_type *bt, char *buf)
> {
> return sprintf(buf, "%lu\n", vio_cmo.high);
> }
>
> -static ssize_t cmo_high_store(struct bus_type *bt, const char *buf,
> +static ssize_t cmo_high_store(const struct bus_type *bt, const char *buf,
> size_t count)
> {
> unsigned long flags;
> diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
> index 294a266a0dda..64d1bde26940 100644
> --- a/drivers/ata/pata_parport/pata_parport.c
> +++ b/drivers/ata/pata_parport/pata_parport.c
> @@ -554,8 +554,7 @@ void pata_parport_unregister_driver(struct pi_protocol *pr)
> }
> EXPORT_SYMBOL_GPL(pata_parport_unregister_driver);
>
> -static ssize_t new_device_store(struct bus_type *bus, const char *buf,
> - size_t count)
> +static ssize_t new_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> char port[12] = "auto";
> char protocol[8] = "auto";
> @@ -630,8 +629,7 @@ static void pi_remove_one(struct device *dev)
> /* pata_parport_dev_release will do kfree(pi) */
> }
>
> -static ssize_t delete_device_store(struct bus_type *bus, const char *buf,
> - size_t count)
> +static ssize_t delete_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct device *dev;
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 91a6b6b1fc49..819ab745fa9f 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -274,7 +274,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
> }
> static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
>
> -static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
> +static ssize_t drivers_autoprobe_show(const struct bus_type *bus, char *buf)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> int ret;
> @@ -287,7 +287,7 @@ static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
> return ret;
> }
>
> -static ssize_t drivers_autoprobe_store(struct bus_type *bus,
> +static ssize_t drivers_autoprobe_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> @@ -304,7 +304,7 @@ static ssize_t drivers_autoprobe_store(struct bus_type *bus,
> return count;
> }
>
> -static ssize_t drivers_probe_store(struct bus_type *bus,
> +static ssize_t drivers_probe_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct device *dev;
> @@ -808,7 +808,7 @@ static void klist_devices_put(struct klist_node *n)
> put_device(dev);
> }
>
> -static ssize_t bus_uevent_store(struct bus_type *bus,
> +static ssize_t bus_uevent_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 5cb008b9700a..84ad3b17956f 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -491,12 +491,12 @@ static bool single_major = true;
> module_param(single_major, bool, 0444);
> MODULE_PARM_DESC(single_major, "Use a single major number for all rbd devices (default: true)");
>
> -static ssize_t add_store(struct bus_type *bus, const char *buf, size_t count);
> -static ssize_t remove_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_store(const struct bus_type *bus, const char *buf, size_t count);
> +static ssize_t remove_store(const struct bus_type *bus, const char *buf,
> size_t count);
> -static ssize_t add_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count);
> -static ssize_t remove_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t remove_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count);
> static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth);
>
> @@ -538,7 +538,7 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev)
> return is_lock_owner;
> }
>
> -static ssize_t supported_features_show(struct bus_type *bus, char *buf)
> +static ssize_t supported_features_show(const struct bus_type *bus, char *buf)
> {
> return sprintf(buf, "0x%llx\n", RBD_FEATURES_SUPPORTED);
> }
> @@ -6967,9 +6967,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
> return ret;
> }
>
> -static ssize_t do_rbd_add(struct bus_type *bus,
> - const char *buf,
> - size_t count)
> +static ssize_t do_rbd_add(const char *buf, size_t count)
> {
> struct rbd_device *rbd_dev = NULL;
> struct ceph_options *ceph_opts = NULL;
> @@ -7081,18 +7079,18 @@ static ssize_t do_rbd_add(struct bus_type *bus,
> goto out;
> }
>
> -static ssize_t add_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t add_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (single_major)
> return -EINVAL;
>
> - return do_rbd_add(bus, buf, count);
> + return do_rbd_add(buf, count);
> }
>
> -static ssize_t add_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return do_rbd_add(bus, buf, count);
> + return do_rbd_add(buf, count);
> }
>
> static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
> @@ -7122,9 +7120,7 @@ static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
> }
> }
>
> -static ssize_t do_rbd_remove(struct bus_type *bus,
> - const char *buf,
> - size_t count)
> +static ssize_t do_rbd_remove(const char *buf, size_t count)
> {
> struct rbd_device *rbd_dev = NULL;
> struct list_head *tmp;
> @@ -7196,18 +7192,18 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
> return count;
> }
>
> -static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (single_major)
> return -EINVAL;
>
> - return do_rbd_remove(bus, buf, count);
> + return do_rbd_remove(buf, count);
> }
>
> -static ssize_t remove_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t remove_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return do_rbd_remove(bus, buf, count);
> + return do_rbd_remove(buf, count);
> }
>
> /*
> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
> index 36cb091a33b4..653e2d4c116f 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
> @@ -231,7 +231,7 @@ static int scan_fsl_mc_bus(struct device *dev, void *data)
> return 0;
> }
>
> -static ssize_t rescan_store(struct bus_type *bus,
> +static ssize_t rescan_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> unsigned long val;
> @@ -284,7 +284,7 @@ static int fsl_mc_bus_get_autorescan(struct device *dev, void *data)
> return 0;
> }
>
> -static ssize_t autorescan_store(struct bus_type *bus,
> +static ssize_t autorescan_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_set_autorescan);
> @@ -292,7 +292,7 @@ static ssize_t autorescan_store(struct bus_type *bus,
> return count;
> }
>
> -static ssize_t autorescan_show(struct bus_type *bus, char *buf)
> +static ssize_t autorescan_show(const struct bus_type *bus, char *buf)
> {
> bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_get_autorescan);
> return strlen(buf);
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 8ee6b6e2e2a4..66333cd6248e 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1927,7 +1927,7 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd)
> EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL);
>
> /* for user tooling to ensure port disable work has completed */
> -static ssize_t flush_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t flush_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (sysfs_streq(buf, "1")) {
> flush_workqueue(cxl_bus_wq);
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index d24dd65b33d4..513adba09f56 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -684,7 +684,7 @@ static const struct attribute_group vmbus_dev_group = {
> __ATTRIBUTE_GROUPS(vmbus_dev);
>
> /* Set up the attribute for /sys/bus/vmbus/hibernation */
> -static ssize_t hibernation_show(struct bus_type *bus, char *buf)
> +static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
> {
> return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
> }
> diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
> index 0052968e881e..0787ad252dd9 100644
> --- a/drivers/net/netdevsim/bus.c
> +++ b/drivers/net/netdevsim/bus.c
> @@ -132,7 +132,7 @@ static struct nsim_bus_dev *
> nsim_bus_dev_new(unsigned int id, unsigned int port_count, unsigned int num_queues);
>
> static ssize_t
> -new_device_store(struct bus_type *bus, const char *buf, size_t count)
> +new_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> unsigned int id, port_count, num_queues;
> struct nsim_bus_dev *nsim_bus_dev;
> @@ -186,7 +186,7 @@ static BUS_ATTR_WO(new_device);
> static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev);
>
> static ssize_t
> -del_device_store(struct bus_type *bus, const char *buf, size_t count)
> +del_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct nsim_bus_dev *nsim_bus_dev, *tmp;
> unsigned int id;
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index dd0d9d9bc509..ab32a91f287b 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -428,7 +428,7 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
> }
> static DEVICE_ATTR_RW(msi_bus);
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> unsigned long val;
> struct pci_bus *b = NULL;
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7a67611dc5f4..45c3bb039f21 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6679,7 +6679,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
> }
> }
>
> -static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
> +static ssize_t resource_alignment_show(const struct bus_type *bus, char *buf)
> {
> size_t count = 0;
>
> @@ -6691,7 +6691,7 @@ static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
> return count;
> }
>
> -static ssize_t resource_alignment_store(struct bus_type *bus,
> +static ssize_t resource_alignment_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> char *param, *old, *end;
> diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c
> index db9ef05776e3..c04244075794 100644
> --- a/drivers/peci/sysfs.c
> +++ b/drivers/peci/sysfs.c
> @@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void *data)
> return peci_controller_scan_devices(to_peci_controller(dev));
> }
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> bool res;
> int ret;
> diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
> index f7679602498e..90d391210533 100644
> --- a/drivers/rapidio/rio-sysfs.c
> +++ b/drivers/rapidio/rio-sysfs.c
> @@ -286,7 +286,7 @@ const struct attribute_group *rio_dev_groups[] = {
> NULL,
> };
>
> -static ssize_t scan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t scan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> long val;
> int rc;
> diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
> index f4cc1720156f..5a99e0b18289 100644
> --- a/drivers/s390/crypto/ap_bus.c
> +++ b/drivers/s390/crypto/ap_bus.c
> @@ -1166,12 +1166,12 @@ EXPORT_SYMBOL(ap_parse_mask_str);
> * AP bus attributes.
> */
>
> -static ssize_t ap_domain_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_domain_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index);
> }
>
> -static ssize_t ap_domain_store(struct bus_type *bus,
> +static ssize_t ap_domain_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int domain;
> @@ -1193,7 +1193,7 @@ static ssize_t ap_domain_store(struct bus_type *bus,
>
> static BUS_ATTR_RW(ap_domain);
>
> -static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_control_domain_mask_show(const struct bus_type *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1208,7 +1208,7 @@ static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_control_domain_mask);
>
> -static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_usage_domain_mask_show(const struct bus_type *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1223,7 +1223,7 @@ static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_usage_domain_mask);
>
> -static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_adapter_mask_show(const struct bus_type *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1238,7 +1238,7 @@ static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_adapter_mask);
>
> -static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_interrupts_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n",
> ap_irq_flag ? 1 : 0);
> @@ -1246,12 +1246,12 @@ static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_interrupts);
>
> -static ssize_t config_time_show(struct bus_type *bus, char *buf)
> +static ssize_t config_time_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_config_time);
> }
>
> -static ssize_t config_time_store(struct bus_type *bus,
> +static ssize_t config_time_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int time;
> @@ -1265,12 +1265,12 @@ static ssize_t config_time_store(struct bus_type *bus,
>
> static BUS_ATTR_RW(config_time);
>
> -static ssize_t poll_thread_show(struct bus_type *bus, char *buf)
> +static ssize_t poll_thread_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_poll_kthread ? 1 : 0);
> }
>
> -static ssize_t poll_thread_store(struct bus_type *bus,
> +static ssize_t poll_thread_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int flag, rc;
> @@ -1289,12 +1289,12 @@ static ssize_t poll_thread_store(struct bus_type *bus,
>
> static BUS_ATTR_RW(poll_thread);
>
> -static ssize_t poll_timeout_show(struct bus_type *bus, char *buf)
> +static ssize_t poll_timeout_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%llu\n", poll_timeout);
> }
>
> -static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
> +static ssize_t poll_timeout_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> unsigned long long time;
> @@ -1318,21 +1318,21 @@ static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(poll_timeout);
>
> -static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_max_domain_id_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_domain_id);
> }
>
> static BUS_ATTR_RO(ap_max_domain_id);
>
> -static ssize_t ap_max_adapter_id_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_max_adapter_id_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_adapter_id);
> }
>
> static BUS_ATTR_RO(ap_max_adapter_id);
>
> -static ssize_t apmask_show(struct bus_type *bus, char *buf)
> +static ssize_t apmask_show(const struct bus_type *bus, char *buf)
> {
> int rc;
>
> @@ -1393,7 +1393,7 @@ static int apmask_commit(unsigned long *newapm)
> return 0;
> }
>
> -static ssize_t apmask_store(struct bus_type *bus, const char *buf,
> +static ssize_t apmask_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> int rc, changes = 0;
> @@ -1425,7 +1425,7 @@ static ssize_t apmask_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(apmask);
>
> -static ssize_t aqmask_show(struct bus_type *bus, char *buf)
> +static ssize_t aqmask_show(const struct bus_type *bus, char *buf)
> {
> int rc;
>
> @@ -1486,7 +1486,7 @@ static int aqmask_commit(unsigned long *newaqm)
> return 0;
> }
>
> -static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
> +static ssize_t aqmask_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> int rc, changes = 0;
> @@ -1518,13 +1518,13 @@ static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(aqmask);
>
> -static ssize_t scans_show(struct bus_type *bus, char *buf)
> +static ssize_t scans_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%llu\n",
> atomic64_read(&ap_scan_bus_count));
> }
>
> -static ssize_t scans_store(struct bus_type *bus, const char *buf,
> +static ssize_t scans_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> AP_DBF_INFO("%s force AP bus rescan\n", __func__);
> @@ -1536,7 +1536,7 @@ static ssize_t scans_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(scans);
>
> -static ssize_t bindings_show(struct bus_type *bus, char *buf)
> +static ssize_t bindings_show(const struct bus_type *bus, char *buf)
> {
> int rc;
> unsigned int apqns, n;
> diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
> index 6260aa5ea6af..e17957f8085c 100644
> --- a/drivers/scsi/fcoe/fcoe_sysfs.c
> +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
> @@ -659,17 +659,17 @@ static const struct device_type fcoe_fcf_device_type = {
> .release = fcoe_fcf_device_release,
> };
>
> -static ssize_t ctlr_create_store(struct bus_type *bus, const char *buf,
> +static ssize_t ctlr_create_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return fcoe_ctlr_create_store(bus, buf, count);
> + return fcoe_ctlr_create_store(buf, count);
> }
> static BUS_ATTR_WO(ctlr_create);
>
> -static ssize_t ctlr_destroy_store(struct bus_type *bus, const char *buf,
> +static ssize_t ctlr_destroy_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return fcoe_ctlr_destroy_store(bus, buf, count);
> + return fcoe_ctlr_destroy_store(buf, count);
> }
> static BUS_ATTR_WO(ctlr_destroy);
>
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
> index 62341c6353a7..46b0bf237be1 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -745,8 +745,7 @@ static int libfcoe_device_notification(struct notifier_block *notifier,
> return NOTIFY_OK;
> }
>
> -ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> - const char *buf, size_t count)
> +ssize_t fcoe_ctlr_create_store(const char *buf, size_t count)
> {
> struct net_device *netdev = NULL;
> struct fcoe_transport *ft = NULL;
> @@ -808,8 +807,7 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> return count;
> }
>
> -ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
> - const char *buf, size_t count)
> +ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count)
> {
> int rc = -ENODEV;
> struct net_device *netdev = NULL;
> diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
> index c258e8770285..78c875386c06 100644
> --- a/include/linux/device/bus.h
> +++ b/include/linux/device/bus.h
> @@ -118,8 +118,8 @@ extern int __must_check bus_rescan_devices(struct bus_type *bus);
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *bus, char *buf);
> - ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
> + ssize_t (*show)(const struct bus_type *bus, char *buf);
> + ssize_t (*store)(const struct bus_type *bus, const char *buf, size_t count);
> };
>
> #define BUS_ATTR_RW(_name) \
> diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
> index 279782156373..8300ef1a982e 100644
> --- a/include/scsi/libfcoe.h
> +++ b/include/scsi/libfcoe.h
> @@ -397,10 +397,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);
> int fcoe_transport_detach(struct fcoe_transport *ft);
>
> /* sysfs store handler for ctrl_control interface */
> -ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> - const char *buf, size_t count);
> -ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
> - const char *buf, size_t count);
> +ssize_t fcoe_ctlr_create_store(const char *buf, size_t count);
> +ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count);
>
> #endif /* _LIBFCOE_H */
>
> --
> 2.39.2
>
Acked-by: Ilya Dryomov <[email protected]> # rbd
Thanks,
Ilya
On Tue, Mar 14, 2023 at 2:30 AM Greg Kroah-Hartman
<[email protected]> wrote:
>
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
LGTM.
Reviewed-by: Alex Shi <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: "Martin K. Petersen" <[email protected]>
> Cc: Alex Shi <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: Alexandre Bounine <[email protected]>
> Cc: Alison Schofield <[email protected]>
> Cc: Ben Widawsky <[email protected]>
> Cc: Bjorn Helgaas <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Hannes Reinecke <[email protected]>
> Cc: Harald Freudenberger <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Hu Haowen <[email protected]>
> Cc: Ilya Dryomov <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Cc: Iwona Winiarska <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Laurentiu Tudor <[email protected]>
> Cc: Matt Porter <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Stuart Yoder <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Yanteng Si <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> Documentation/driver-api/driver-model/bus.rst | 4 +-
> Documentation/filesystems/sysfs.rst | 4 +-
> .../translations/zh_CN/filesystems/sysfs.txt | 4 +-
> .../translations/zh_TW/filesystems/sysfs.txt | 4 +-
> arch/powerpc/platforms/pseries/ibmebus.c | 4 +-
> arch/powerpc/platforms/pseries/vio.c | 8 ++--
> drivers/ata/pata_parport/pata_parport.c | 6 +--
> drivers/base/bus.c | 8 ++--
> drivers/block/rbd.c | 34 +++++++--------
> drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +--
> drivers/cxl/core/port.c | 2 +-
> drivers/hv/vmbus_drv.c | 2 +-
> drivers/net/netdevsim/bus.c | 4 +-
> drivers/pci/pci-sysfs.c | 2 +-
> drivers/pci/pci.c | 4 +-
> drivers/peci/sysfs.c | 2 +-
> drivers/rapidio/rio-sysfs.c | 2 +-
> drivers/s390/crypto/ap_bus.c | 42 +++++++++----------
> drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++--
> drivers/scsi/fcoe/fcoe_transport.c | 6 +--
> include/linux/device/bus.h | 4 +-
> include/scsi/libfcoe.h | 6 +--
> 22 files changed, 78 insertions(+), 88 deletions(-)
>
> diff --git a/Documentation/driver-api/driver-model/bus.rst b/Documentation/driver-api/driver-model/bus.rst
> index 016b15a6e8ea..9709ab62a468 100644
> --- a/Documentation/driver-api/driver-model/bus.rst
> +++ b/Documentation/driver-api/driver-model/bus.rst
> @@ -125,8 +125,8 @@ Exporting Attributes
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> Bus drivers can export attributes using the BUS_ATTR_RW macro that works
> diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystems/sysfs.rst
> index f8187d466b97..c32993bc83c7 100644
> --- a/Documentation/filesystems/sysfs.rst
> +++ b/Documentation/filesystems/sysfs.rst
> @@ -373,8 +373,8 @@ Structure::
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> Declaring::
> diff --git a/Documentation/translations/zh_CN/filesystems/sysfs.txt b/Documentation/translations/zh_CN/filesystems/sysfs.txt
> index 046cc1d52058..547062759e60 100644
> --- a/Documentation/translations/zh_CN/filesystems/sysfs.txt
> +++ b/Documentation/translations/zh_CN/filesystems/sysfs.txt
> @@ -329,8 +329,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> 声明:
> diff --git a/Documentation/translations/zh_TW/filesystems/sysfs.txt b/Documentation/translations/zh_TW/filesystems/sysfs.txt
> index acd677f19d4f..280824cc7e5d 100644
> --- a/Documentation/translations/zh_TW/filesystems/sysfs.txt
> +++ b/Documentation/translations/zh_TW/filesystems/sysfs.txt
> @@ -332,8 +332,8 @@ void device_remove_file(struct device *dev, const struct device_attribute * attr
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *, char * buf);
> - ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
> + ssize_t (*show)(const struct bus_type *, char * buf);
> + ssize_t (*store)(const struct bus_type *, const char * buf, size_t count);
> };
>
> 聲明:
> diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
> index bb9c18682783..44703f13985b 100644
> --- a/arch/powerpc/platforms/pseries/ibmebus.c
> +++ b/arch/powerpc/platforms/pseries/ibmebus.c
> @@ -267,7 +267,7 @@ static char *ibmebus_chomp(const char *in, size_t count)
> return out;
> }
>
> -static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t probe_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct device_node *dn = NULL;
> struct device *dev;
> @@ -305,7 +305,7 @@ static ssize_t probe_store(struct bus_type *bus, const char *buf, size_t count)
> }
> static BUS_ATTR_WO(probe);
>
> -static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct device *dev;
> char *path;
> diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
> index 770df9351aaa..bf7aff6390be 100644
> --- a/arch/powerpc/platforms/pseries/vio.c
> +++ b/arch/powerpc/platforms/pseries/vio.c
> @@ -1006,7 +1006,7 @@ ATTRIBUTE_GROUPS(vio_cmo_dev);
> /* sysfs bus functions and data structures for CMO */
>
> #define viobus_cmo_rd_attr(name) \
> -static ssize_t cmo_bus_##name##_show(struct bus_type *bt, char *buf) \
> +static ssize_t cmo_bus_##name##_show(const struct bus_type *bt, char *buf) \
> { \
> return sprintf(buf, "%lu\n", vio_cmo.name); \
> } \
> @@ -1015,7 +1015,7 @@ static struct bus_attribute bus_attr_cmo_bus_##name = \
>
> #define viobus_cmo_pool_rd_attr(name, var) \
> static ssize_t \
> -cmo_##name##_##var##_show(struct bus_type *bt, char *buf) \
> +cmo_##name##_##var##_show(const struct bus_type *bt, char *buf) \
> { \
> return sprintf(buf, "%lu\n", vio_cmo.name.var); \
> } \
> @@ -1030,12 +1030,12 @@ viobus_cmo_pool_rd_attr(reserve, size);
> viobus_cmo_pool_rd_attr(excess, size);
> viobus_cmo_pool_rd_attr(excess, free);
>
> -static ssize_t cmo_high_show(struct bus_type *bt, char *buf)
> +static ssize_t cmo_high_show(const struct bus_type *bt, char *buf)
> {
> return sprintf(buf, "%lu\n", vio_cmo.high);
> }
>
> -static ssize_t cmo_high_store(struct bus_type *bt, const char *buf,
> +static ssize_t cmo_high_store(const struct bus_type *bt, const char *buf,
> size_t count)
> {
> unsigned long flags;
> diff --git a/drivers/ata/pata_parport/pata_parport.c b/drivers/ata/pata_parport/pata_parport.c
> index 294a266a0dda..64d1bde26940 100644
> --- a/drivers/ata/pata_parport/pata_parport.c
> +++ b/drivers/ata/pata_parport/pata_parport.c
> @@ -554,8 +554,7 @@ void pata_parport_unregister_driver(struct pi_protocol *pr)
> }
> EXPORT_SYMBOL_GPL(pata_parport_unregister_driver);
>
> -static ssize_t new_device_store(struct bus_type *bus, const char *buf,
> - size_t count)
> +static ssize_t new_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> char port[12] = "auto";
> char protocol[8] = "auto";
> @@ -630,8 +629,7 @@ static void pi_remove_one(struct device *dev)
> /* pata_parport_dev_release will do kfree(pi) */
> }
>
> -static ssize_t delete_device_store(struct bus_type *bus, const char *buf,
> - size_t count)
> +static ssize_t delete_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct device *dev;
>
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 91a6b6b1fc49..819ab745fa9f 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -274,7 +274,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
> }
> static DRIVER_ATTR_IGNORE_LOCKDEP(bind, 0200, NULL, bind_store);
>
> -static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
> +static ssize_t drivers_autoprobe_show(const struct bus_type *bus, char *buf)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> int ret;
> @@ -287,7 +287,7 @@ static ssize_t drivers_autoprobe_show(struct bus_type *bus, char *buf)
> return ret;
> }
>
> -static ssize_t drivers_autoprobe_store(struct bus_type *bus,
> +static ssize_t drivers_autoprobe_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> @@ -304,7 +304,7 @@ static ssize_t drivers_autoprobe_store(struct bus_type *bus,
> return count;
> }
>
> -static ssize_t drivers_probe_store(struct bus_type *bus,
> +static ssize_t drivers_probe_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct device *dev;
> @@ -808,7 +808,7 @@ static void klist_devices_put(struct klist_node *n)
> put_device(dev);
> }
>
> -static ssize_t bus_uevent_store(struct bus_type *bus,
> +static ssize_t bus_uevent_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> struct subsys_private *sp = bus_to_subsys(bus);
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 5cb008b9700a..84ad3b17956f 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -491,12 +491,12 @@ static bool single_major = true;
> module_param(single_major, bool, 0444);
> MODULE_PARM_DESC(single_major, "Use a single major number for all rbd devices (default: true)");
>
> -static ssize_t add_store(struct bus_type *bus, const char *buf, size_t count);
> -static ssize_t remove_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_store(const struct bus_type *bus, const char *buf, size_t count);
> +static ssize_t remove_store(const struct bus_type *bus, const char *buf,
> size_t count);
> -static ssize_t add_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count);
> -static ssize_t remove_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t remove_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count);
> static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth);
>
> @@ -538,7 +538,7 @@ static bool rbd_is_lock_owner(struct rbd_device *rbd_dev)
> return is_lock_owner;
> }
>
> -static ssize_t supported_features_show(struct bus_type *bus, char *buf)
> +static ssize_t supported_features_show(const struct bus_type *bus, char *buf)
> {
> return sprintf(buf, "0x%llx\n", RBD_FEATURES_SUPPORTED);
> }
> @@ -6967,9 +6967,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
> return ret;
> }
>
> -static ssize_t do_rbd_add(struct bus_type *bus,
> - const char *buf,
> - size_t count)
> +static ssize_t do_rbd_add(const char *buf, size_t count)
> {
> struct rbd_device *rbd_dev = NULL;
> struct ceph_options *ceph_opts = NULL;
> @@ -7081,18 +7079,18 @@ static ssize_t do_rbd_add(struct bus_type *bus,
> goto out;
> }
>
> -static ssize_t add_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t add_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (single_major)
> return -EINVAL;
>
> - return do_rbd_add(bus, buf, count);
> + return do_rbd_add(buf, count);
> }
>
> -static ssize_t add_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t add_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return do_rbd_add(bus, buf, count);
> + return do_rbd_add(buf, count);
> }
>
> static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
> @@ -7122,9 +7120,7 @@ static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
> }
> }
>
> -static ssize_t do_rbd_remove(struct bus_type *bus,
> - const char *buf,
> - size_t count)
> +static ssize_t do_rbd_remove(const char *buf, size_t count)
> {
> struct rbd_device *rbd_dev = NULL;
> struct list_head *tmp;
> @@ -7196,18 +7192,18 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
> return count;
> }
>
> -static ssize_t remove_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t remove_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (single_major)
> return -EINVAL;
>
> - return do_rbd_remove(bus, buf, count);
> + return do_rbd_remove(buf, count);
> }
>
> -static ssize_t remove_single_major_store(struct bus_type *bus, const char *buf,
> +static ssize_t remove_single_major_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return do_rbd_remove(bus, buf, count);
> + return do_rbd_remove(buf, count);
> }
>
> /*
> diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
> index 36cb091a33b4..653e2d4c116f 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-bus.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
> @@ -231,7 +231,7 @@ static int scan_fsl_mc_bus(struct device *dev, void *data)
> return 0;
> }
>
> -static ssize_t rescan_store(struct bus_type *bus,
> +static ssize_t rescan_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> unsigned long val;
> @@ -284,7 +284,7 @@ static int fsl_mc_bus_get_autorescan(struct device *dev, void *data)
> return 0;
> }
>
> -static ssize_t autorescan_store(struct bus_type *bus,
> +static ssize_t autorescan_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_set_autorescan);
> @@ -292,7 +292,7 @@ static ssize_t autorescan_store(struct bus_type *bus,
> return count;
> }
>
> -static ssize_t autorescan_show(struct bus_type *bus, char *buf)
> +static ssize_t autorescan_show(const struct bus_type *bus, char *buf)
> {
> bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_get_autorescan);
> return strlen(buf);
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 8ee6b6e2e2a4..66333cd6248e 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1927,7 +1927,7 @@ bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd)
> EXPORT_SYMBOL_NS_GPL(schedule_cxl_memdev_detach, CXL);
>
> /* for user tooling to ensure port disable work has completed */
> -static ssize_t flush_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t flush_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> if (sysfs_streq(buf, "1")) {
> flush_workqueue(cxl_bus_wq);
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index d24dd65b33d4..513adba09f56 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -684,7 +684,7 @@ static const struct attribute_group vmbus_dev_group = {
> __ATTRIBUTE_GROUPS(vmbus_dev);
>
> /* Set up the attribute for /sys/bus/vmbus/hibernation */
> -static ssize_t hibernation_show(struct bus_type *bus, char *buf)
> +static ssize_t hibernation_show(const struct bus_type *bus, char *buf)
> {
> return sprintf(buf, "%d\n", !!hv_is_hibernation_supported());
> }
> diff --git a/drivers/net/netdevsim/bus.c b/drivers/net/netdevsim/bus.c
> index 0052968e881e..0787ad252dd9 100644
> --- a/drivers/net/netdevsim/bus.c
> +++ b/drivers/net/netdevsim/bus.c
> @@ -132,7 +132,7 @@ static struct nsim_bus_dev *
> nsim_bus_dev_new(unsigned int id, unsigned int port_count, unsigned int num_queues);
>
> static ssize_t
> -new_device_store(struct bus_type *bus, const char *buf, size_t count)
> +new_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> unsigned int id, port_count, num_queues;
> struct nsim_bus_dev *nsim_bus_dev;
> @@ -186,7 +186,7 @@ static BUS_ATTR_WO(new_device);
> static void nsim_bus_dev_del(struct nsim_bus_dev *nsim_bus_dev);
>
> static ssize_t
> -del_device_store(struct bus_type *bus, const char *buf, size_t count)
> +del_device_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> struct nsim_bus_dev *nsim_bus_dev, *tmp;
> unsigned int id;
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index dd0d9d9bc509..ab32a91f287b 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -428,7 +428,7 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
> }
> static DEVICE_ATTR_RW(msi_bus);
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> unsigned long val;
> struct pci_bus *b = NULL;
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7a67611dc5f4..45c3bb039f21 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6679,7 +6679,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
> }
> }
>
> -static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
> +static ssize_t resource_alignment_show(const struct bus_type *bus, char *buf)
> {
> size_t count = 0;
>
> @@ -6691,7 +6691,7 @@ static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
> return count;
> }
>
> -static ssize_t resource_alignment_store(struct bus_type *bus,
> +static ssize_t resource_alignment_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> char *param, *old, *end;
> diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c
> index db9ef05776e3..c04244075794 100644
> --- a/drivers/peci/sysfs.c
> +++ b/drivers/peci/sysfs.c
> @@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void *data)
> return peci_controller_scan_devices(to_peci_controller(dev));
> }
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> bool res;
> int ret;
> diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
> index f7679602498e..90d391210533 100644
> --- a/drivers/rapidio/rio-sysfs.c
> +++ b/drivers/rapidio/rio-sysfs.c
> @@ -286,7 +286,7 @@ const struct attribute_group *rio_dev_groups[] = {
> NULL,
> };
>
> -static ssize_t scan_store(struct bus_type *bus, const char *buf, size_t count)
> +static ssize_t scan_store(const struct bus_type *bus, const char *buf, size_t count)
> {
> long val;
> int rc;
> diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
> index f4cc1720156f..5a99e0b18289 100644
> --- a/drivers/s390/crypto/ap_bus.c
> +++ b/drivers/s390/crypto/ap_bus.c
> @@ -1166,12 +1166,12 @@ EXPORT_SYMBOL(ap_parse_mask_str);
> * AP bus attributes.
> */
>
> -static ssize_t ap_domain_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_domain_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index);
> }
>
> -static ssize_t ap_domain_store(struct bus_type *bus,
> +static ssize_t ap_domain_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int domain;
> @@ -1193,7 +1193,7 @@ static ssize_t ap_domain_store(struct bus_type *bus,
>
> static BUS_ATTR_RW(ap_domain);
>
> -static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_control_domain_mask_show(const struct bus_type *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1208,7 +1208,7 @@ static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_control_domain_mask);
>
> -static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_usage_domain_mask_show(const struct bus_type *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1223,7 +1223,7 @@ static ssize_t ap_usage_domain_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_usage_domain_mask);
>
> -static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_adapter_mask_show(const struct bus_type *bus, char *buf)
> {
> if (!ap_qci_info) /* QCI not supported */
> return scnprintf(buf, PAGE_SIZE, "not supported\n");
> @@ -1238,7 +1238,7 @@ static ssize_t ap_adapter_mask_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_adapter_mask);
>
> -static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_interrupts_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n",
> ap_irq_flag ? 1 : 0);
> @@ -1246,12 +1246,12 @@ static ssize_t ap_interrupts_show(struct bus_type *bus, char *buf)
>
> static BUS_ATTR_RO(ap_interrupts);
>
> -static ssize_t config_time_show(struct bus_type *bus, char *buf)
> +static ssize_t config_time_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_config_time);
> }
>
> -static ssize_t config_time_store(struct bus_type *bus,
> +static ssize_t config_time_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int time;
> @@ -1265,12 +1265,12 @@ static ssize_t config_time_store(struct bus_type *bus,
>
> static BUS_ATTR_RW(config_time);
>
> -static ssize_t poll_thread_show(struct bus_type *bus, char *buf)
> +static ssize_t poll_thread_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_poll_kthread ? 1 : 0);
> }
>
> -static ssize_t poll_thread_store(struct bus_type *bus,
> +static ssize_t poll_thread_store(const struct bus_type *bus,
> const char *buf, size_t count)
> {
> int flag, rc;
> @@ -1289,12 +1289,12 @@ static ssize_t poll_thread_store(struct bus_type *bus,
>
> static BUS_ATTR_RW(poll_thread);
>
> -static ssize_t poll_timeout_show(struct bus_type *bus, char *buf)
> +static ssize_t poll_timeout_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%llu\n", poll_timeout);
> }
>
> -static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
> +static ssize_t poll_timeout_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> unsigned long long time;
> @@ -1318,21 +1318,21 @@ static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(poll_timeout);
>
> -static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_max_domain_id_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_domain_id);
> }
>
> static BUS_ATTR_RO(ap_max_domain_id);
>
> -static ssize_t ap_max_adapter_id_show(struct bus_type *bus, char *buf)
> +static ssize_t ap_max_adapter_id_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%d\n", ap_max_adapter_id);
> }
>
> static BUS_ATTR_RO(ap_max_adapter_id);
>
> -static ssize_t apmask_show(struct bus_type *bus, char *buf)
> +static ssize_t apmask_show(const struct bus_type *bus, char *buf)
> {
> int rc;
>
> @@ -1393,7 +1393,7 @@ static int apmask_commit(unsigned long *newapm)
> return 0;
> }
>
> -static ssize_t apmask_store(struct bus_type *bus, const char *buf,
> +static ssize_t apmask_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> int rc, changes = 0;
> @@ -1425,7 +1425,7 @@ static ssize_t apmask_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(apmask);
>
> -static ssize_t aqmask_show(struct bus_type *bus, char *buf)
> +static ssize_t aqmask_show(const struct bus_type *bus, char *buf)
> {
> int rc;
>
> @@ -1486,7 +1486,7 @@ static int aqmask_commit(unsigned long *newaqm)
> return 0;
> }
>
> -static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
> +static ssize_t aqmask_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> int rc, changes = 0;
> @@ -1518,13 +1518,13 @@ static ssize_t aqmask_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(aqmask);
>
> -static ssize_t scans_show(struct bus_type *bus, char *buf)
> +static ssize_t scans_show(const struct bus_type *bus, char *buf)
> {
> return scnprintf(buf, PAGE_SIZE, "%llu\n",
> atomic64_read(&ap_scan_bus_count));
> }
>
> -static ssize_t scans_store(struct bus_type *bus, const char *buf,
> +static ssize_t scans_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> AP_DBF_INFO("%s force AP bus rescan\n", __func__);
> @@ -1536,7 +1536,7 @@ static ssize_t scans_store(struct bus_type *bus, const char *buf,
>
> static BUS_ATTR_RW(scans);
>
> -static ssize_t bindings_show(struct bus_type *bus, char *buf)
> +static ssize_t bindings_show(const struct bus_type *bus, char *buf)
> {
> int rc;
> unsigned int apqns, n;
> diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
> index 6260aa5ea6af..e17957f8085c 100644
> --- a/drivers/scsi/fcoe/fcoe_sysfs.c
> +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
> @@ -659,17 +659,17 @@ static const struct device_type fcoe_fcf_device_type = {
> .release = fcoe_fcf_device_release,
> };
>
> -static ssize_t ctlr_create_store(struct bus_type *bus, const char *buf,
> +static ssize_t ctlr_create_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return fcoe_ctlr_create_store(bus, buf, count);
> + return fcoe_ctlr_create_store(buf, count);
> }
> static BUS_ATTR_WO(ctlr_create);
>
> -static ssize_t ctlr_destroy_store(struct bus_type *bus, const char *buf,
> +static ssize_t ctlr_destroy_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> - return fcoe_ctlr_destroy_store(bus, buf, count);
> + return fcoe_ctlr_destroy_store(buf, count);
> }
> static BUS_ATTR_WO(ctlr_destroy);
>
> diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
> index 62341c6353a7..46b0bf237be1 100644
> --- a/drivers/scsi/fcoe/fcoe_transport.c
> +++ b/drivers/scsi/fcoe/fcoe_transport.c
> @@ -745,8 +745,7 @@ static int libfcoe_device_notification(struct notifier_block *notifier,
> return NOTIFY_OK;
> }
>
> -ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> - const char *buf, size_t count)
> +ssize_t fcoe_ctlr_create_store(const char *buf, size_t count)
> {
> struct net_device *netdev = NULL;
> struct fcoe_transport *ft = NULL;
> @@ -808,8 +807,7 @@ ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> return count;
> }
>
> -ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
> - const char *buf, size_t count)
> +ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count)
> {
> int rc = -ENODEV;
> struct net_device *netdev = NULL;
> diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
> index c258e8770285..78c875386c06 100644
> --- a/include/linux/device/bus.h
> +++ b/include/linux/device/bus.h
> @@ -118,8 +118,8 @@ extern int __must_check bus_rescan_devices(struct bus_type *bus);
>
> struct bus_attribute {
> struct attribute attr;
> - ssize_t (*show)(struct bus_type *bus, char *buf);
> - ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
> + ssize_t (*show)(const struct bus_type *bus, char *buf);
> + ssize_t (*store)(const struct bus_type *bus, const char *buf, size_t count);
> };
>
> #define BUS_ATTR_RW(_name) \
> diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
> index 279782156373..8300ef1a982e 100644
> --- a/include/scsi/libfcoe.h
> +++ b/include/scsi/libfcoe.h
> @@ -397,10 +397,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);
> int fcoe_transport_detach(struct fcoe_transport *ft);
>
> /* sysfs store handler for ctrl_control interface */
> -ssize_t fcoe_ctlr_create_store(struct bus_type *bus,
> - const char *buf, size_t count);
> -ssize_t fcoe_ctlr_destroy_store(struct bus_type *bus,
> - const char *buf, size_t count);
> +ssize_t fcoe_ctlr_create_store(const char *buf, size_t count);
> +ssize_t fcoe_ctlr_destroy_store(const char *buf, size_t count);
>
> #endif /* _LIBFCOE_H */
>
> --
> 2.39.2
>
On Mon, 2023-03-13 at 19:29 +0100, Greg Kroah-Hartman wrote:
> struct bus_type should never be modified in a sysfs callback as there is
> nothing in the structure to modify, and frankly, the structure is almost
> never used in a sysfs callback, so mark it as constant to allow struct
> bus_type to be moved to read-only memory.
>
> Cc: "David S. Miller" <[email protected]>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: "Martin K. Petersen" <[email protected]>
> Cc: Alex Shi <[email protected]>
> Cc: Alexander Gordeev <[email protected]>
> Cc: Alexandre Bounine <[email protected]>
> Cc: Alison Schofield <[email protected]>
> Cc: Ben Widawsky <[email protected]>
> Cc: Bjorn Helgaas <[email protected]>
> Cc: Dan Williams <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: Eric Dumazet <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Hannes Reinecke <[email protected]>
> Cc: Harald Freudenberger <[email protected]>
> Cc: Heiko Carstens <[email protected]>
> Cc: Hu Haowen <[email protected]>
> Cc: Ilya Dryomov <[email protected]>
> Cc: Ira Weiny <[email protected]>
> Cc: Iwona Winiarska <[email protected]>
> Cc: Jakub Kicinski <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Jonathan Corbet <[email protected]>
> Cc: Laurentiu Tudor <[email protected]>
> Cc: Matt Porter <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paolo Abeni <[email protected]>
> Cc: Stuart Yoder <[email protected]>
> Cc: Vasily Gorbik <[email protected]>
> Cc: Vishal Verma <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Yanteng Si <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> Documentation/driver-api/driver-model/bus.rst | 4 +-
> Documentation/filesystems/sysfs.rst | 4 +-
> .../translations/zh_CN/filesystems/sysfs.txt | 4 +-
> .../translations/zh_TW/filesystems/sysfs.txt | 4 +-
> arch/powerpc/platforms/pseries/ibmebus.c | 4 +-
> arch/powerpc/platforms/pseries/vio.c | 8 ++--
> drivers/ata/pata_parport/pata_parport.c | 6 +--
> drivers/base/bus.c | 8 ++--
> drivers/block/rbd.c | 34 +++++++--------
> drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +--
> drivers/cxl/core/port.c | 2 +-
> drivers/hv/vmbus_drv.c | 2 +-
> drivers/net/netdevsim/bus.c | 4 +-
> drivers/pci/pci-sysfs.c | 2 +-
> drivers/pci/pci.c | 4 +-
> drivers/peci/sysfs.c | 2 +-
> drivers/rapidio/rio-sysfs.c | 2 +-
> drivers/s390/crypto/ap_bus.c | 42 +++++++++----------
> drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++--
> drivers/scsi/fcoe/fcoe_transport.c | 6 +--
> include/linux/device/bus.h | 4 +-
> include/scsi/libfcoe.h | 6 +--
> 22 files changed, 78 insertions(+), 88 deletions(-)
>
[..]
> diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c
> index db9ef05776e3..c04244075794 100644
> --- a/drivers/peci/sysfs.c
> +++ b/drivers/peci/sysfs.c
> @@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void *data)
> return peci_controller_scan_devices(to_peci_controller(dev));
> }
>
> -static ssize_t rescan_store(struct bus_type *bus, const char *buf, size_t
> count)
> +static ssize_t rescan_store(const struct bus_type *bus, const char *buf,
> size_t count)
> {
> bool res;
> int ret;
Acked-by: Iwona Winiarska <[email protected]>
Thanks
-Iwona
On Mon, Mar 13, 2023 at 12:07:27PM -0700, Fenghua Yu wrote:
> Hi, Greg,
>
> On 3/13/23 11:29, Greg Kroah-Hartman wrote:
> > In the functions unbind_store() and bind_store(), a struct bus_type *
> > should be a const one, as the driver core bus functions used by this
> > variable are expecting the pointer to be constant, and these functions
> > do not modify the pointer at all.
> >
> > Cc: Fenghua Yu <[email protected]>
> > Cc: Dave Jiang <[email protected]>
> > Cc: Vinod Koul <[email protected]>
> > Cc: [email protected]
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > Note, this is a patch that is a prepatory cleanup as part of a larger
> > series of patches that is working on resolving some old driver core
> > design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> > its own, but I'd prefer if I could take it through my driver-core tree
> > so that the driver core changes can be taken through there for 6.4-rc1.
> >
> > drivers/dma/idxd/compat.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
> > index 3df21615f888..5fd38d1b9d28 100644
> > --- a/drivers/dma/idxd/compat.c
> > +++ b/drivers/dma/idxd/compat.c
> > @@ -16,7 +16,7 @@ extern void device_driver_detach(struct device *dev);
> > static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
> > {
> > - struct bus_type *bus = drv->bus;
> > + const struct bus_type *bus = drv->bus;
> > struct device *dev;
> > int rc = -ENODEV;
> > @@ -32,7 +32,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
> > static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
> > {
> > - struct bus_type *bus = drv->bus;
> > + const struct bus_type *bus = drv->bus;
> > struct device *dev;
> > struct device_driver *alt_drv = NULL;
> > int rc = -ENODEV;
>
> After applying this patch, warning is reported:
>
> drivers/dma/idxd/compat.c: In function ‘bind_store’:
> drivers/dma/idxd/compat.c:47:47: warning: passing argument 2 of
> ‘driver_find’ discards ‘const’ qualifier from pointer target type
> [-Wdiscarded-qualifiers]
> 47 | alt_drv = driver_find("idxd", bus);
> | ^~~
> In file included from ./include/linux/device.h:32,
> from drivers/dma/idxd/compat.c:6:
> ./include/linux/device/driver.h:129:59: note: expected ‘struct bus_type *’
> but argument is of type ‘const struct bus_type *’
> 129 | struct bus_type *bus);
> | ~~~~~~~~~~~~~~~~~^~~
>
> Should the "bus" parameter in driver_find() definition be changed to const
> as well to avoid the warning?
Oops, yes, it needs an earlier patch in this series, sorry, I didn't
call that out properly in the notes section of the patch.
So I can just take this through my tree if that's ok.
thanks,
greg k-h
Hi, Greg,
On 3/16/23 03:16, Greg Kroah-Hartman wrote:
> On Mon, Mar 13, 2023 at 12:07:27PM -0700, Fenghua Yu wrote:
>> Hi, Greg,
>>
>> On 3/13/23 11:29, Greg Kroah-Hartman wrote:
>>> In the functions unbind_store() and bind_store(), a struct bus_type *
>>> should be a const one, as the driver core bus functions used by this
>>> variable are expecting the pointer to be constant, and these functions
>>> do not modify the pointer at all.
>>>
>>> Cc: Fenghua Yu <[email protected]>
>>> Cc: Dave Jiang <[email protected]>
>>> Cc: Vinod Koul <[email protected]>
>>> Cc: [email protected]
>>> Signed-off-by: Greg Kroah-Hartman <[email protected]>
>>> ---
>>> Note, this is a patch that is a prepatory cleanup as part of a larger
>>> series of patches that is working on resolving some old driver core
>>> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
>>> its own, but I'd prefer if I could take it through my driver-core tree
>>> so that the driver core changes can be taken through there for 6.4-rc1.
>>>
>>> drivers/dma/idxd/compat.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
>>> index 3df21615f888..5fd38d1b9d28 100644
>>> --- a/drivers/dma/idxd/compat.c
>>> +++ b/drivers/dma/idxd/compat.c
>>> @@ -16,7 +16,7 @@ extern void device_driver_detach(struct device *dev);
>>> static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
>>> {
>>> - struct bus_type *bus = drv->bus;
>>> + const struct bus_type *bus = drv->bus;
>>> struct device *dev;
>>> int rc = -ENODEV;
>>> @@ -32,7 +32,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
>>> static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
>>> {
>>> - struct bus_type *bus = drv->bus;
>>> + const struct bus_type *bus = drv->bus;
>>> struct device *dev;
>>> struct device_driver *alt_drv = NULL;
>>> int rc = -ENODEV;
>>
>> After applying this patch, warning is reported:
>>
>> drivers/dma/idxd/compat.c: In function ‘bind_store’:
>> drivers/dma/idxd/compat.c:47:47: warning: passing argument 2 of
>> ‘driver_find’ discards ‘const’ qualifier from pointer target type
>> [-Wdiscarded-qualifiers]
>> 47 | alt_drv = driver_find("idxd", bus);
>> | ^~~
>> In file included from ./include/linux/device.h:32,
>> from drivers/dma/idxd/compat.c:6:
>> ./include/linux/device/driver.h:129:59: note: expected ‘struct bus_type *’
>> but argument is of type ‘const struct bus_type *’
>> 129 | struct bus_type *bus);
>> | ~~~~~~~~~~~~~~~~~^~~
>>
>> Should the "bus" parameter in driver_find() definition be changed to const
>> as well to avoid the warning?
>
> Oops, yes, it needs an earlier patch in this series, sorry, I didn't
> call that out properly in the notes section of the patch.
>
> So I can just take this through my tree if that's ok.
Sure.
Acked-by: Fenghua Yu <[email protected]>
Thanks.
-Fenghua
On 13-03-23, 19:29, Greg Kroah-Hartman wrote:
> In the functions unbind_store() and bind_store(), a struct bus_type *
> should be a const one, as the driver core bus functions used by this
> variable are expecting the pointer to be constant, and these functions
> do not modify the pointer at all.
Acked-by: Vinod Koul <[email protected]>
--
~Vinod
On 3/13/23 11:29 AM, Greg Kroah-Hartman wrote:
> In the functions unbind_store() and bind_store(), a struct bus_type *
> should be a const one, as the driver core bus functions used by this
> variable are expecting the pointer to be constant, and these functions
> do not modify the pointer at all.
>
> Cc: Fenghua Yu <[email protected]>
> Cc: Dave Jiang <[email protected]>
> Cc: Vinod Koul <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Dave Jiang <[email protected]>
> ---
> Note, this is a patch that is a prepatory cleanup as part of a larger
> series of patches that is working on resolving some old driver core
> design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> its own, but I'd prefer if I could take it through my driver-core tree
> so that the driver core changes can be taken through there for 6.4-rc1.
>
> drivers/dma/idxd/compat.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
> index 3df21615f888..5fd38d1b9d28 100644
> --- a/drivers/dma/idxd/compat.c
> +++ b/drivers/dma/idxd/compat.c
> @@ -16,7 +16,7 @@ extern void device_driver_detach(struct device *dev);
>
> static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
> {
> - struct bus_type *bus = drv->bus;
> + const struct bus_type *bus = drv->bus;
> struct device *dev;
> int rc = -ENODEV;
>
> @@ -32,7 +32,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
>
> static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
> {
> - struct bus_type *bus = drv->bus;
> + const struct bus_type *bus = drv->bus;
> struct device *dev;
> struct device_driver *alt_drv = NULL;
> int rc = -ENODEV;
On Thu, Mar 16, 2023 at 04:57:54PM -0700, Fenghua Yu wrote:
> Hi, Greg,
>
> On 3/16/23 03:16, Greg Kroah-Hartman wrote:
> > On Mon, Mar 13, 2023 at 12:07:27PM -0700, Fenghua Yu wrote:
> > > Hi, Greg,
> > >
> > > On 3/13/23 11:29, Greg Kroah-Hartman wrote:
> > > > In the functions unbind_store() and bind_store(), a struct bus_type *
> > > > should be a const one, as the driver core bus functions used by this
> > > > variable are expecting the pointer to be constant, and these functions
> > > > do not modify the pointer at all.
> > > >
> > > > Cc: Fenghua Yu <[email protected]>
> > > > Cc: Dave Jiang <[email protected]>
> > > > Cc: Vinod Koul <[email protected]>
> > > > Cc: [email protected]
> > > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > > ---
> > > > Note, this is a patch that is a prepatory cleanup as part of a larger
> > > > series of patches that is working on resolving some old driver core
> > > > design mistakes. It will build and apply cleanly on top of 6.3-rc2 on
> > > > its own, but I'd prefer if I could take it through my driver-core tree
> > > > so that the driver core changes can be taken through there for 6.4-rc1.
> > > >
> > > > drivers/dma/idxd/compat.c | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/dma/idxd/compat.c b/drivers/dma/idxd/compat.c
> > > > index 3df21615f888..5fd38d1b9d28 100644
> > > > --- a/drivers/dma/idxd/compat.c
> > > > +++ b/drivers/dma/idxd/compat.c
> > > > @@ -16,7 +16,7 @@ extern void device_driver_detach(struct device *dev);
> > > > static ssize_t unbind_store(struct device_driver *drv, const char *buf, size_t count)
> > > > {
> > > > - struct bus_type *bus = drv->bus;
> > > > + const struct bus_type *bus = drv->bus;
> > > > struct device *dev;
> > > > int rc = -ENODEV;
> > > > @@ -32,7 +32,7 @@ static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store);
> > > > static ssize_t bind_store(struct device_driver *drv, const char *buf, size_t count)
> > > > {
> > > > - struct bus_type *bus = drv->bus;
> > > > + const struct bus_type *bus = drv->bus;
> > > > struct device *dev;
> > > > struct device_driver *alt_drv = NULL;
> > > > int rc = -ENODEV;
> > >
> > > After applying this patch, warning is reported:
> > >
> > > drivers/dma/idxd/compat.c: In function ‘bind_store’:
> > > drivers/dma/idxd/compat.c:47:47: warning: passing argument 2 of
> > > ‘driver_find’ discards ‘const’ qualifier from pointer target type
> > > [-Wdiscarded-qualifiers]
> > > 47 | alt_drv = driver_find("idxd", bus);
> > > | ^~~
> > > In file included from ./include/linux/device.h:32,
> > > from drivers/dma/idxd/compat.c:6:
> > > ./include/linux/device/driver.h:129:59: note: expected ‘struct bus_type *’
> > > but argument is of type ‘const struct bus_type *’
> > > 129 | struct bus_type *bus);
> > > | ~~~~~~~~~~~~~~~~~^~~
> > >
> > > Should the "bus" parameter in driver_find() definition be changed to const
> > > as well to avoid the warning?
> >
> > Oops, yes, it needs an earlier patch in this series, sorry, I didn't
> > call that out properly in the notes section of the patch.
> >
> > So I can just take this through my tree if that's ok.
>
> Sure.
>
> Acked-by: Fenghua Yu <[email protected]>
Great, thanks for this, I've now queued up the series in my tree.
greg k-h