All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root()
@ 2023-03-13 18:28 Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: " Greg Kroah-Hartman
                   ` (34 more replies)
  0 siblings, 35 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Borislav Petkov, Tony Luck,
	James Morse, Mauro Carvalho Chehab, Robert Richter, linux-edac

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 <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Robert Richter <rric@kernel.org>
Cc: linux-edac@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:43   ` Rafael J. Wysocki
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                   ` (33 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Len Brown, linux-acpi

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" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/acpi/acpi_lpit.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
index 3843d2576d3f..73b5c4800150 100644
--- a/drivers/acpi/acpi_lpit.c
+++ b/drivers/acpi/acpi_lpit.c
@@ -98,6 +98,8 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
 static void lpit_update_residency(struct lpit_residency_info *info,
 				 struct acpi_lpit_native *lpit_native)
 {
+	struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
 	info->frequency = lpit_native->counter_frequency ?
 				lpit_native->counter_frequency : tsc_khz * 1000;
 	if (!info->frequency)
@@ -111,15 +113,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
 			return;
 
 		/* Silently fail, if cpuidle attribute group is not present */
-		sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
-					&dev_attr_low_power_idle_system_residency_us.attr,
-					"cpuidle");
+		if (dev_root)
+			sysfs_add_file_to_group(&dev_root->kobj,
+						&dev_attr_low_power_idle_system_residency_us.attr,
+						"cpuidle");
 	} else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
 		/* Silently fail, if cpuidle attribute group is not present */
-		sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
-					&dev_attr_low_power_idle_cpu_residency_us.attr,
-					"cpuidle");
+		if (dev_root)
+			sysfs_add_file_to_group(&dev_root->kobj,
+						&dev_attr_low_power_idle_cpu_residency_us.attr,
+						"cpuidle");
 	}
+	put_device(dev_root);
 }
 
 static void lpit_process(u64 begin, u64 end)
-- 
2.39.2


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

* [PATCH 03/36] cpufreq: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:45   ` Rafael J. Wysocki
  2023-03-13 18:28 ` [PATCH 04/36] platform/x86: ibm_rtl: " Greg Kroah-Hartman
                   ` (32 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Viresh Kumar, Srinivas Pandruvada,
	Len Brown, linux-pm

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" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 04/36] platform/x86: ibm_rtl: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: " Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-15 12:46   ` Hans de Goede
  2023-03-13 18:28 ` [PATCH 05/36] platform/x86: intel-uncore-freq: " Greg Kroah-Hartman
                   ` (31 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Hans de Goede, Mark Gross,
	platform-driver-x86

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: Hans de Goede <hdegoede@redhat.com>
Cc: Mark Gross <markgross@kernel.org>
Cc: platform-driver-x86@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/platform/x86/ibm_rtl.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
index 5fc665f7d9b3..2ab7d9ac542d 100644
--- a/drivers/platform/x86/ibm_rtl.c
+++ b/drivers/platform/x86/ibm_rtl.c
@@ -199,16 +199,26 @@ static int rtl_setup_sysfs(void) {
 
 	ret = subsys_system_register(&rtl_subsys, NULL);
 	if (!ret) {
-		for (i = 0; rtl_attributes[i]; i ++)
-			device_create_file(rtl_subsys.dev_root, rtl_attributes[i]);
+		struct device *dev_root = bus_get_dev_root(&rtl_subsys);
+
+		if (dev_root) {
+			for (i = 0; rtl_attributes[i]; i ++)
+				device_create_file(dev_root, rtl_attributes[i]);
+			put_device(dev_root);
+		}
 	}
 	return ret;
 }
 
 static void rtl_teardown_sysfs(void) {
+	struct device *dev_root = bus_get_dev_root(&rtl_subsys);
 	int i;
-	for (i = 0; rtl_attributes[i]; i ++)
-		device_remove_file(rtl_subsys.dev_root, rtl_attributes[i]);
+
+	if (dev_root) {
+		for (i = 0; rtl_attributes[i]; i ++)
+			device_remove_file(dev_root, rtl_attributes[i]);
+		put_device(dev_root);
+	}
 	bus_unregister(&rtl_subsys);
 }
 
-- 
2.39.2


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

* [PATCH 05/36] platform/x86: intel-uncore-freq: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 04/36] platform/x86: ibm_rtl: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 19:14   ` srinivas pandruvada
  2023-03-15 12:46   ` Hans de Goede
  2023-03-13 18:28 ` [PATCH 06/36] cpuidle: " Greg Kroah-Hartman
                   ` (30 subsequent siblings)
  34 siblings, 2 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Srinivas Pandruvada, Hans de Goede,
	Mark Gross, platform-driver-x86

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: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Mark Gross <markgross@kernel.org>
Cc: platform-driver-x86@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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.

 .../intel/uncore-frequency/uncore-frequency-common.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index cb24de9e97dc..1a300e14f350 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -224,9 +224,15 @@ int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, u
 	uncore_write = write_control_freq;
 	uncore_read_freq = read_freq;
 
-	if (!uncore_root_kobj)
-		uncore_root_kobj = kobject_create_and_add("intel_uncore_frequency",
-							    &cpu_subsys.dev_root->kobj);
+	if (!uncore_root_kobj) {
+		struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
+		if (dev_root) {
+			uncore_root_kobj = kobject_create_and_add("intel_uncore_frequency",
+								  &dev_root->kobj);
+			put_device(dev_root);
+		}
+	}
 	if (uncore_root_kobj)
 		++uncore_instance_count;
 	mutex_unlock(&uncore_lock);
-- 
2.39.2


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

* [PATCH 06/36] cpuidle: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 05/36] platform/x86: intel-uncore-freq: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:58   ` Rafael J. Wysocki
  2023-03-13 18:28 ` [PATCH 07/36] cpu/hotplug: " Greg Kroah-Hartman
                   ` (29 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Daniel Lezcano, linux-pm

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.

This allows us to clean up the cpuidle_add_interface() call a bit as it
was only called in one place, with the same argument so just put that
into the function itself.  Note that cpuidle_remove_interface() should
also probably be removed in the future as there are no callers of it for
some reason.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/cpuidle/cpuidle.c |  2 +-
 drivers/cpuidle/cpuidle.h |  2 +-
 drivers/cpuidle/sysfs.c   | 12 +++++++++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0b00f21cefe3..8e929f6602ce 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -808,7 +808,7 @@ static int __init cpuidle_init(void)
 	if (cpuidle_disabled())
 		return -ENODEV;
 
-	return cpuidle_add_interface(cpu_subsys.dev_root);
+	return cpuidle_add_interface();
 }
 
 module_param(off, int, 0444);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 9f336af17fa6..52701d9588f1 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -30,7 +30,7 @@ extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
 
 struct device;
 
-extern int cpuidle_add_interface(struct device *dev);
+extern int cpuidle_add_interface(void);
 extern void cpuidle_remove_interface(struct device *dev);
 extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
 extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 48948b171749..84e4946f1072 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -119,11 +119,17 @@ static struct attribute_group cpuidle_attr_group = {
 
 /**
  * cpuidle_add_interface - add CPU global sysfs attributes
- * @dev: the target device
  */
-int cpuidle_add_interface(struct device *dev)
+int cpuidle_add_interface(void)
 {
-	return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
+	struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+	int retval = -EINVAL;
+
+	if (dev_root) {
+		retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
+		put_device(dev_root);
+	}
+	return retval;
 }
 
 /**
-- 
2.39.2


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

* [PATCH 07/36] cpu/hotplug: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 06/36] cpuidle: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-20 13:59   ` Thomas Gleixner
  2023-03-13 18:28 ` [PATCH 08/36] workqueue: " Greg Kroah-Hartman
                   ` (28 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Thomas Gleixner, Valentin Schneider,
	Phil Auld, Steven Price, Juri Lelli, Vincent Donnefort,
	Kuppuswamy Sathyanarayanan, Jason A. Donenfeld

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: Thomas Gleixner <tglx@linutronix.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Phil Auld <pauld@redhat.com>
Cc: Steven Price <steven.price@arm.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Vincent Donnefort <vdonnefort@google.com>
Cc: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/cpu.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6c0a92ca6bb5..c59b73d13a3a 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2569,22 +2569,33 @@ static const struct attribute_group cpuhp_smt_attr_group = {
 
 static int __init cpu_smt_sysfs_init(void)
 {
-	return sysfs_create_group(&cpu_subsys.dev_root->kobj,
-				  &cpuhp_smt_attr_group);
+	struct device *dev_root;
+	int ret = -ENODEV;
+
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		ret = sysfs_create_group(&dev_root->kobj, &cpuhp_smt_attr_group);
+		put_device(dev_root);
+	}
+	return ret;
 }
 
 static int __init cpuhp_sysfs_init(void)
 {
+	struct device *dev_root;
 	int cpu, ret;
 
 	ret = cpu_smt_sysfs_init();
 	if (ret)
 		return ret;
 
-	ret = sysfs_create_group(&cpu_subsys.dev_root->kobj,
-				 &cpuhp_cpu_root_attr_group);
-	if (ret)
-		return ret;
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		ret = sysfs_create_group(&dev_root->kobj, &cpuhp_cpu_root_attr_group);
+		put_device(dev_root);
+		if (ret)
+			return ret;
+	}
 
 	for_each_possible_cpu(cpu) {
 		struct device *dev = get_cpu_device(cpu);
-- 
2.39.2


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

* [PATCH 08/36] workqueue: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 07/36] cpu/hotplug: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-14  3:31   ` Tejun Heo
  2023-03-13 18:28 ` [PATCH 09/36] x86/microcode: " Greg Kroah-Hartman
                   ` (27 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Tejun Heo, Lai Jiangshan

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 <tj@kernel.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 09/36] x86/microcode: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 08/36] workqueue: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 10/36] x86/umwait: " Greg Kroah-Hartman
                   ` (26 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Borislav Petkov, Thomas Gleixner,
	Ingo Molnar, Dave Hansen, x86, H. Peter Anvin

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 <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 10/36] x86/umwait: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 09/36] x86/microcode: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:28   ` Greg Kroah-Hartman
                   ` (25 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin

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: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/umwait.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/umwait.c b/arch/x86/kernel/cpu/umwait.c
index ec8064c0ae03..2293efd6ffa6 100644
--- a/arch/x86/kernel/cpu/umwait.c
+++ b/arch/x86/kernel/cpu/umwait.c
@@ -232,7 +232,11 @@ static int __init umwait_init(void)
 	 * Add umwait control interface. Ignore failure, so at least the
 	 * default values are set up in case the machine manages to boot.
 	 */
-	dev = cpu_subsys.dev_root;
-	return sysfs_create_group(&dev->kobj, &umwait_attr_group);
+	dev = bus_get_dev_root(&cpu_subsys);
+	if (dev) {
+		ret = sysfs_create_group(&dev->kobj, &umwait_attr_group);
+		put_device(dev);
+	}
+	return ret;
 }
 device_initcall(umwait_init);
-- 
2.39.2


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

* [PATCH 11/36] arm64: cpufeature: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Mark Brown, James Morse, Kristina Martsenko, Marc Zyngier,
	Ard Biesheuvel, Vladimir Murzin, Mark Rutland, linux-arm-kernel

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: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Kristina Martsenko <kristina.martsenko@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Vladimir Murzin <vladimir.murzin@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/arm64/kernel/cpufeature.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 2e3e55139777..f3bab4bd0917 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1490,10 +1490,18 @@ static const DEVICE_ATTR_RO(aarch32_el0);
 
 static int __init aarch32_el0_sysfs_init(void)
 {
+	struct device *dev_root;
+	int ret = 0;
+
 	if (!allow_mismatched_32bit_el0)
 		return 0;
 
-	return device_create_file(cpu_subsys.dev_root, &dev_attr_aarch32_el0);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &dev_attr_aarch32_el0);
+		put_device(dev_root);
+	}
+	return ret;
 }
 device_initcall(aarch32_el0_sysfs_init);
 
-- 
2.39.2


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

* [PATCH 11/36] arm64: cpufeature: move to use bus_get_dev_root()
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Catalin Marinas, Will Deacon,
	Mark Brown, James Morse, Kristina Martsenko, Marc Zyngier,
	Ard Biesheuvel, Vladimir Murzin, Mark Rutland, linux-arm-kernel

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: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Kristina Martsenko <kristina.martsenko@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Vladimir Murzin <vladimir.murzin@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/arm64/kernel/cpufeature.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 2e3e55139777..f3bab4bd0917 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1490,10 +1490,18 @@ static const DEVICE_ATTR_RO(aarch32_el0);
 
 static int __init aarch32_el0_sysfs_init(void)
 {
+	struct device *dev_root;
+	int ret = 0;
+
 	if (!allow_mismatched_32bit_el0)
 		return 0;
 
-	return device_create_file(cpu_subsys.dev_root, &dev_attr_aarch32_el0);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &dev_attr_aarch32_el0);
+		put_device(dev_root);
+	}
+	return ret;
 }
 device_initcall(aarch32_el0_sysfs_init);
 
-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 12/36] powerpc/sysfs: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, David Hildenbrand, Andrew Morton, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/powerpc/kernel/sysfs.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index ef9a61718940..0f39a6b84132 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -217,13 +217,18 @@ static DEVICE_ATTR(dscr_default, 0600,
 static void __init sysfs_create_dscr_default(void)
 {
 	if (cpu_has_feature(CPU_FTR_DSCR)) {
+		struct device *dev_root;
 		int cpu;
 
 		dscr_default = spr_default_dscr;
 		for_each_possible_cpu(cpu)
 			paca_ptrs[cpu]->dscr_default = dscr_default;
 
-		device_create_file(cpu_subsys.dev_root, &dev_attr_dscr_default);
+		dev_root = bus_get_dev_root(&cpu_subsys);
+		if (dev_root) {
+			device_create_file(dev_root, &dev_attr_dscr_default);
+			put_device(dev_root);
+		}
 	}
 }
 #endif /* CONFIG_PPC64 */
@@ -746,7 +751,12 @@ static DEVICE_ATTR(svm, 0444, show_svm, NULL);
 
 static void __init create_svm_file(void)
 {
-	device_create_file(cpu_subsys.dev_root, &dev_attr_svm);
+	struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
+	if (dev_root) {
+		device_create_file(dev_root, &dev_attr_svm);
+		put_device(dev_root);
+	}
 }
 #else
 static void __init create_svm_file(void)
-- 
2.39.2


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

* [PATCH 12/36] powerpc/sysfs: move to use bus_get_dev_root()
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Hildenbrand, Greg Kroah-Hartman, rafael, Nicholas Piggin,
	Andrew Morton, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/powerpc/kernel/sysfs.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index ef9a61718940..0f39a6b84132 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -217,13 +217,18 @@ static DEVICE_ATTR(dscr_default, 0600,
 static void __init sysfs_create_dscr_default(void)
 {
 	if (cpu_has_feature(CPU_FTR_DSCR)) {
+		struct device *dev_root;
 		int cpu;
 
 		dscr_default = spr_default_dscr;
 		for_each_possible_cpu(cpu)
 			paca_ptrs[cpu]->dscr_default = dscr_default;
 
-		device_create_file(cpu_subsys.dev_root, &dev_attr_dscr_default);
+		dev_root = bus_get_dev_root(&cpu_subsys);
+		if (dev_root) {
+			device_create_file(dev_root, &dev_attr_dscr_default);
+			put_device(dev_root);
+		}
 	}
 }
 #endif /* CONFIG_PPC64 */
@@ -746,7 +751,12 @@ static DEVICE_ATTR(svm, 0444, show_svm, NULL);
 
 static void __init create_svm_file(void)
 {
-	device_create_file(cpu_subsys.dev_root, &dev_attr_svm);
+	struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
+	if (dev_root) {
+		device_create_file(dev_root, &dev_attr_svm);
+		put_device(dev_root);
+	}
 }
 #else
 static void __init create_svm_file(void)
-- 
2.39.2


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

* [PATCH 13/36] powerpc/powernv: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Wolfram Sang, Joel Stanley, Liang He,
	Julia Lawall, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Liang He <windhl@126.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/powerpc/platforms/powernv/idle.c    |  9 +++++++--
 arch/powerpc/platforms/powernv/subcore.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 841cb7f31f4f..6dfe8d611164 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -1464,14 +1464,19 @@ static int __init pnv_init_idle_states(void)
 			power7_fastsleep_workaround_entry = false;
 			power7_fastsleep_workaround_exit = false;
 		} else {
+			struct device *dev_root;
 			/*
 			 * OPAL_PM_SLEEP_ENABLED_ER1 is set. It indicates that
 			 * workaround is needed to use fastsleep. Provide sysfs
 			 * control to choose how this workaround has to be
 			 * applied.
 			 */
-			device_create_file(cpu_subsys.dev_root,
-				&dev_attr_fastsleep_workaround_applyonce);
+			dev_root = bus_get_dev_root(&cpu_subsys);
+			if (dev_root) {
+				device_create_file(dev_root,
+						   &dev_attr_fastsleep_workaround_applyonce);
+				put_device(dev_root);
+			}
 		}
 
 		update_subcore_sibling_mask();
diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c
index 7e98b00ea2e8..428532a69762 100644
--- a/arch/powerpc/platforms/powernv/subcore.c
+++ b/arch/powerpc/platforms/powernv/subcore.c
@@ -415,7 +415,9 @@ static DEVICE_ATTR(subcores_per_core, 0644,
 
 static int subcore_init(void)
 {
+	struct device *dev_root;
 	unsigned pvr_ver;
+	int rc = 0;
 
 	pvr_ver = PVR_VER(mfspr(SPRN_PVR));
 
@@ -435,7 +437,11 @@ static int subcore_init(void)
 
 	set_subcores_per_core(1);
 
-	return device_create_file(cpu_subsys.dev_root,
-				  &dev_attr_subcores_per_core);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		rc = device_create_file(dev_root, &dev_attr_subcores_per_core);
+		put_device(dev_root);
+	}
+	return rc;
 }
 machine_device_initcall(powernv, subcore_init);
-- 
2.39.2


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

* [PATCH 13/36] powerpc/powernv: move to use bus_get_dev_root()
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, linuxppc-dev, Julia Lawall,
	Wolfram Sang, Nicholas Piggin, Liang He, Joel Stanley

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Liang He <windhl@126.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/powerpc/platforms/powernv/idle.c    |  9 +++++++--
 arch/powerpc/platforms/powernv/subcore.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 841cb7f31f4f..6dfe8d611164 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -1464,14 +1464,19 @@ static int __init pnv_init_idle_states(void)
 			power7_fastsleep_workaround_entry = false;
 			power7_fastsleep_workaround_exit = false;
 		} else {
+			struct device *dev_root;
 			/*
 			 * OPAL_PM_SLEEP_ENABLED_ER1 is set. It indicates that
 			 * workaround is needed to use fastsleep. Provide sysfs
 			 * control to choose how this workaround has to be
 			 * applied.
 			 */
-			device_create_file(cpu_subsys.dev_root,
-				&dev_attr_fastsleep_workaround_applyonce);
+			dev_root = bus_get_dev_root(&cpu_subsys);
+			if (dev_root) {
+				device_create_file(dev_root,
+						   &dev_attr_fastsleep_workaround_applyonce);
+				put_device(dev_root);
+			}
 		}
 
 		update_subcore_sibling_mask();
diff --git a/arch/powerpc/platforms/powernv/subcore.c b/arch/powerpc/platforms/powernv/subcore.c
index 7e98b00ea2e8..428532a69762 100644
--- a/arch/powerpc/platforms/powernv/subcore.c
+++ b/arch/powerpc/platforms/powernv/subcore.c
@@ -415,7 +415,9 @@ static DEVICE_ATTR(subcores_per_core, 0644,
 
 static int subcore_init(void)
 {
+	struct device *dev_root;
 	unsigned pvr_ver;
+	int rc = 0;
 
 	pvr_ver = PVR_VER(mfspr(SPRN_PVR));
 
@@ -435,7 +437,11 @@ static int subcore_init(void)
 
 	set_subcores_per_core(1);
 
-	return device_create_file(cpu_subsys.dev_root,
-				  &dev_attr_subcores_per_core);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		rc = device_create_file(dev_root, &dev_attr_subcores_per_core);
+		put_device(dev_root);
+	}
+	return rc;
 }
 machine_device_initcall(powernv, subcore_init);
-- 
2.39.2


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

* [PATCH 14/36] powerpc/pseries: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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.

 .../platforms/pseries/pseries_energy.c        | 28 +++++++++++--------
 arch/powerpc/platforms/pseries/suspend.c      | 10 +++++--
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
index 09e98d301db0..2c661b798235 100644
--- a/arch/powerpc/platforms/pseries/pseries_energy.c
+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
@@ -300,20 +300,22 @@ static struct device_attribute attr_percpu_deactivate_hint =
 static int __init pseries_energy_init(void)
 {
 	int cpu, err;
-	struct device *cpu_dev;
+	struct device *cpu_dev, *dev_root;
 
 	if (!firmware_has_feature(FW_FEATURE_BEST_ENERGY))
 		return 0; /* H_BEST_ENERGY hcall not supported */
 
 	/* Create the sysfs files */
-	err = device_create_file(cpu_subsys.dev_root,
-				&attr_cpu_activate_hint_list);
-	if (!err)
-		err = device_create_file(cpu_subsys.dev_root,
-				&attr_cpu_deactivate_hint_list);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		err = device_create_file(dev_root, &attr_cpu_activate_hint_list);
+		if (!err)
+			err = device_create_file(dev_root, &attr_cpu_deactivate_hint_list);
+		put_device(dev_root);
+		if (err)
+			return err;
+	}
 
-	if (err)
-		return err;
 	for_each_possible_cpu(cpu) {
 		cpu_dev = get_cpu_device(cpu);
 		err = device_create_file(cpu_dev,
@@ -337,14 +339,18 @@ static int __init pseries_energy_init(void)
 static void __exit pseries_energy_cleanup(void)
 {
 	int cpu;
-	struct device *cpu_dev;
+	struct device *cpu_dev, *dev_root;
 
 	if (!sysfs_entries)
 		return;
 
 	/* Remove the sysfs files */
-	device_remove_file(cpu_subsys.dev_root, &attr_cpu_activate_hint_list);
-	device_remove_file(cpu_subsys.dev_root, &attr_cpu_deactivate_hint_list);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		device_remove_file(dev_root, &attr_cpu_activate_hint_list);
+		device_remove_file(dev_root, &attr_cpu_deactivate_hint_list);
+		put_device(dev_root);
+	}
 
 	for_each_possible_cpu(cpu) {
 		cpu_dev = get_cpu_device(cpu);
diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
index 1b902cbf85c5..5c43435472cc 100644
--- a/arch/powerpc/platforms/pseries/suspend.c
+++ b/arch/powerpc/platforms/pseries/suspend.c
@@ -143,6 +143,7 @@ static const struct platform_suspend_ops pseries_suspend_ops = {
  **/
 static int pseries_suspend_sysfs_register(struct device *dev)
 {
+	struct device *dev_root;
 	int rc;
 
 	if ((rc = subsys_system_register(&suspend_subsys, NULL)))
@@ -151,8 +152,13 @@ static int pseries_suspend_sysfs_register(struct device *dev)
 	dev->id = 0;
 	dev->bus = &suspend_subsys;
 
-	if ((rc = device_create_file(suspend_subsys.dev_root, &dev_attr_hibernate)))
-		goto subsys_unregister;
+	dev_root = bus_get_dev_root(&suspend_subsys);
+	if (dev_root) {
+		rc = device_create_file(dev_root, &dev_attr_hibernate);
+		put_device(dev_root);
+		if (rc)
+			goto subsys_unregister;
+	}
 
 	return 0;
 
-- 
2.39.2


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

* [PATCH 14/36] powerpc/pseries: move to use bus_get_dev_root()
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Nicholas Piggin, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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.

 .../platforms/pseries/pseries_energy.c        | 28 +++++++++++--------
 arch/powerpc/platforms/pseries/suspend.c      | 10 +++++--
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
index 09e98d301db0..2c661b798235 100644
--- a/arch/powerpc/platforms/pseries/pseries_energy.c
+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
@@ -300,20 +300,22 @@ static struct device_attribute attr_percpu_deactivate_hint =
 static int __init pseries_energy_init(void)
 {
 	int cpu, err;
-	struct device *cpu_dev;
+	struct device *cpu_dev, *dev_root;
 
 	if (!firmware_has_feature(FW_FEATURE_BEST_ENERGY))
 		return 0; /* H_BEST_ENERGY hcall not supported */
 
 	/* Create the sysfs files */
-	err = device_create_file(cpu_subsys.dev_root,
-				&attr_cpu_activate_hint_list);
-	if (!err)
-		err = device_create_file(cpu_subsys.dev_root,
-				&attr_cpu_deactivate_hint_list);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		err = device_create_file(dev_root, &attr_cpu_activate_hint_list);
+		if (!err)
+			err = device_create_file(dev_root, &attr_cpu_deactivate_hint_list);
+		put_device(dev_root);
+		if (err)
+			return err;
+	}
 
-	if (err)
-		return err;
 	for_each_possible_cpu(cpu) {
 		cpu_dev = get_cpu_device(cpu);
 		err = device_create_file(cpu_dev,
@@ -337,14 +339,18 @@ static int __init pseries_energy_init(void)
 static void __exit pseries_energy_cleanup(void)
 {
 	int cpu;
-	struct device *cpu_dev;
+	struct device *cpu_dev, *dev_root;
 
 	if (!sysfs_entries)
 		return;
 
 	/* Remove the sysfs files */
-	device_remove_file(cpu_subsys.dev_root, &attr_cpu_activate_hint_list);
-	device_remove_file(cpu_subsys.dev_root, &attr_cpu_deactivate_hint_list);
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		device_remove_file(dev_root, &attr_cpu_activate_hint_list);
+		device_remove_file(dev_root, &attr_cpu_deactivate_hint_list);
+		put_device(dev_root);
+	}
 
 	for_each_possible_cpu(cpu) {
 		cpu_dev = get_cpu_device(cpu);
diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
index 1b902cbf85c5..5c43435472cc 100644
--- a/arch/powerpc/platforms/pseries/suspend.c
+++ b/arch/powerpc/platforms/pseries/suspend.c
@@ -143,6 +143,7 @@ static const struct platform_suspend_ops pseries_suspend_ops = {
  **/
 static int pseries_suspend_sysfs_register(struct device *dev)
 {
+	struct device *dev_root;
 	int rc;
 
 	if ((rc = subsys_system_register(&suspend_subsys, NULL)))
@@ -151,8 +152,13 @@ static int pseries_suspend_sysfs_register(struct device *dev)
 	dev->id = 0;
 	dev->bus = &suspend_subsys;
 
-	if ((rc = device_create_file(suspend_subsys.dev_root, &dev_attr_hibernate)))
-		goto subsys_unregister;
+	dev_root = bus_get_dev_root(&suspend_subsys);
+	if (dev_root) {
+		rc = device_create_file(dev_root, &dev_attr_hibernate);
+		put_device(dev_root);
+		if (rc)
+			goto subsys_unregister;
+	}
 
 	return 0;
 
-- 
2.39.2


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

* [PATCH 15/36] powerpc/fsl: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/powerpc/sysdev/fsl_mpic_timer_wakeup.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
index c2baa283e624..147b5d8bb904 100644
--- a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
+++ b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
@@ -116,6 +116,7 @@ static struct device_attribute mpic_attributes = __ATTR(timer_wakeup, 0644,
 
 static int __init fsl_wakeup_sys_init(void)
 {
+	struct device *dev_root;
 	int ret;
 
 	fsl_wakeup = kzalloc(sizeof(struct fsl_mpic_timer_wakeup), GFP_KERNEL);
@@ -124,16 +125,26 @@ static int __init fsl_wakeup_sys_init(void)
 
 	INIT_WORK(&fsl_wakeup->free_work, fsl_free_resource);
 
-	ret = device_create_file(mpic_subsys.dev_root, &mpic_attributes);
-	if (ret)
-		kfree(fsl_wakeup);
+	dev_root = bus_get_dev_root(&mpic_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &mpic_attributes);
+		put_device(dev_root);
+		if (ret)
+			kfree(fsl_wakeup);
+	}
 
 	return ret;
 }
 
 static void __exit fsl_wakeup_sys_exit(void)
 {
-	device_remove_file(mpic_subsys.dev_root, &mpic_attributes);
+	struct device *dev_root;
+
+	dev_root = bus_get_dev_root(&mpic_subsys);
+	if (dev_root) {
+		device_remove_file(dev_root, &mpic_attributes);
+		put_device(dev_root);
+	}
 
 	mutex_lock(&sysfs_lock);
 
-- 
2.39.2


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

* [PATCH 15/36] powerpc/fsl: move to use bus_get_dev_root()
@ 2023-03-13 18:28   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Nicholas Piggin, linuxppc-dev

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: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/powerpc/sysdev/fsl_mpic_timer_wakeup.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
index c2baa283e624..147b5d8bb904 100644
--- a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
+++ b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
@@ -116,6 +116,7 @@ static struct device_attribute mpic_attributes = __ATTR(timer_wakeup, 0644,
 
 static int __init fsl_wakeup_sys_init(void)
 {
+	struct device *dev_root;
 	int ret;
 
 	fsl_wakeup = kzalloc(sizeof(struct fsl_mpic_timer_wakeup), GFP_KERNEL);
@@ -124,16 +125,26 @@ static int __init fsl_wakeup_sys_init(void)
 
 	INIT_WORK(&fsl_wakeup->free_work, fsl_free_resource);
 
-	ret = device_create_file(mpic_subsys.dev_root, &mpic_attributes);
-	if (ret)
-		kfree(fsl_wakeup);
+	dev_root = bus_get_dev_root(&mpic_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &mpic_attributes);
+		put_device(dev_root);
+		if (ret)
+			kfree(fsl_wakeup);
+	}
 
 	return ret;
 }
 
 static void __exit fsl_wakeup_sys_exit(void)
 {
-	device_remove_file(mpic_subsys.dev_root, &mpic_attributes);
+	struct device *dev_root;
+
+	dev_root = bus_get_dev_root(&mpic_subsys);
+	if (dev_root) {
+		device_remove_file(dev_root, &mpic_attributes);
+		put_device(dev_root);
+	}
 
 	mutex_lock(&sysfs_lock);
 
-- 
2.39.2


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

* [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (13 preceding siblings ...)
  2023-03-13 18:28   ` Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:38   ` John Paul Adrian Glaubitz
  2023-03-13 18:48   ` John Paul Adrian Glaubitz
  2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
                   ` (19 subsequent siblings)
  34 siblings, 2 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Yoshinori Sato, Rich Felker, linux-sh

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 <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/sh/drivers/dma/dma-sysfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index 8ef318150f84..431bc18f0a41 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -45,13 +45,19 @@ static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
 
 static int __init dma_subsys_init(void)
 {
+	struct device *dev_root;
 	int ret;
 
 	ret = subsys_system_register(&dma_subsys, NULL);
 	if (unlikely(ret))
 		return ret;
 
-	return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
+	dev_root = bus_get_dev_root(&dma_subsys);
+	if (dev_root) {
+		ret = device_create_file(dev_root, &dev_attr_devices);
+		put_device(dev_root);
+	}
+	return ret;
 }
 postcore_initcall(dma_subsys_init);
 
-- 
2.39.2


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

* [PATCH 17/36] sh: intc: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (14 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: " Greg Kroah-Hartman
@ 2023-03-13 18:28 ` Greg Kroah-Hartman
  2023-03-13 18:39   ` John Paul Adrian Glaubitz
  2023-03-13 18:29 ` [PATCH 18/36] s390/topology: " Greg Kroah-Hartman
                   ` (18 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Yoshinori Sato, Rich Felker, linux-sh

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 <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 18/36] s390/topology: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (15 preceding siblings ...)
  2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-14 11:34   ` Heiko Carstens
  2023-03-13 18:29 ` [PATCH 19/36] s390/smp: " Greg Kroah-Hartman
                   ` (17 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	linux-s390

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: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/s390/kernel/topology.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index c6eecd4a5302..72af753d1bba 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -649,12 +649,21 @@ static struct ctl_table topology_dir_table[] = {
 
 static int __init topology_init(void)
 {
+	struct device *dev_root;
+	int rc = 0;
+
 	timer_setup(&topology_timer, topology_timer_fn, TIMER_DEFERRABLE);
 	if (MACHINE_HAS_TOPOLOGY)
 		set_topology_timer();
 	else
 		topology_update_polarization_simple();
 	register_sysctl_table(topology_dir_table);
-	return device_create_file(cpu_subsys.dev_root, &dev_attr_dispatching);
+
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		rc = device_create_file(dev_root, &dev_attr_dispatching);
+		put_device(dev_root);
+	}
+	return rc;
 }
 device_initcall(topology_init);
-- 
2.39.2


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

* [PATCH 19/36] s390/smp: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (16 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 18/36] s390/topology: " Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-14 11:35   ` Heiko Carstens
  2023-03-13 18:29 ` [PATCH 20/36] cpufreq: amd-pstate: " Greg Kroah-Hartman
                   ` (16 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Ilya Leoshkevich, linux-s390

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: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/s390/kernel/smp.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index d4888453bbf8..4df797ab8ca2 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1227,11 +1227,17 @@ static DEVICE_ATTR_WO(rescan);
 
 static int __init s390_smp_init(void)
 {
+	struct device *dev_root;
 	int cpu, rc = 0;
 
-	rc = device_create_file(cpu_subsys.dev_root, &dev_attr_rescan);
-	if (rc)
-		return rc;
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		rc = device_create_file(dev_root, &dev_attr_rescan);
+		put_device(dev_root);
+		if (rc)
+			return rc;
+	}
+
 	for_each_present_cpu(cpu) {
 		rc = smp_add_present_cpu(cpu);
 		if (rc)
-- 
2.39.2


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

* [PATCH 20/36] cpufreq: amd-pstate: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (17 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 19/36] s390/smp: " Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-14  6:04   ` Huang Rui
  2023-03-13 18:29 ` [PATCH 21/36] irqchip/mbigen: " Greg Kroah-Hartman
                   ` (15 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Huang Rui, Viresh Kumar, linux-pm

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.

In doing so, remove the unneded kobject structure that was only being
created to cause a subdirectory for the attributes.  The name of the
attribute group is the correct way to do this, saving code and
complexity as well as allowing the attributes to properly show up to
userspace tools (the raw kobject would not allow that.)

Cc: Huang Rui <ray.huang@amd.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/amd-pstate.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 73c7643b2697..b92454c50118 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -63,7 +63,6 @@ static struct cpufreq_driver *current_pstate_driver;
 static struct cpufreq_driver amd_pstate_driver;
 static struct cpufreq_driver amd_pstate_epp_driver;
 static int cppc_state = AMD_PSTATE_DISABLE;
-struct kobject *amd_pstate_kobj;
 
 /*
  * AMD Energy Preference Performance (EPP)
@@ -932,6 +931,7 @@ static struct attribute *pstate_global_attributes[] = {
 };
 
 static const struct attribute_group amd_pstate_global_attr_group = {
+	.name = "amd_pstate",
 	.attrs = pstate_global_attributes,
 };
 
@@ -1253,6 +1253,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
 
 static int __init amd_pstate_init(void)
 {
+	struct device *dev_root;
 	int ret;
 
 	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
@@ -1299,24 +1300,19 @@ static int __init amd_pstate_init(void)
 	if (ret)
 		pr_err("failed to register with return %d\n", ret);
 
-	amd_pstate_kobj = kobject_create_and_add("amd_pstate", &cpu_subsys.dev_root->kobj);
-	if (!amd_pstate_kobj) {
-		ret = -EINVAL;
-		pr_err("global sysfs registration failed.\n");
-		goto kobject_free;
-	}
-
-	ret = sysfs_create_group(amd_pstate_kobj, &amd_pstate_global_attr_group);
-	if (ret) {
-		pr_err("sysfs attribute export failed with error %d.\n", ret);
-		goto global_attr_free;
+	dev_root = bus_get_dev_root(&cpu_subsys);
+	if (dev_root) {
+		ret = sysfs_create_group(&dev_root->kobj, &amd_pstate_global_attr_group);
+		put_device(dev_root);
+		if (ret) {
+			pr_err("sysfs attribute export failed with error %d.\n", ret);
+			goto global_attr_free;
+		}
 	}
 
 	return ret;
 
 global_attr_free:
-	kobject_put(amd_pstate_kobj);
-kobject_free:
 	cpufreq_unregister_driver(current_pstate_driver);
 	return ret;
 }
-- 
2.39.2


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

* [PATCH 21/36] irqchip/mbigen: move to use bus_get_dev_root()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (18 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 20/36] cpufreq: amd-pstate: " Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 22/36] driver core: bus: move dev_root out of struct bus_type Greg Kroah-Hartman
                   ` (14 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman, Thomas Gleixner, Marc Zyngier

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: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/irqchip/irq-mbigen.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index f3faf5c99770..30ca1bf7fc8b 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -245,11 +245,14 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
 		if (!of_property_read_bool(np, "interrupt-controller"))
 			continue;
 
-		parent = platform_bus_type.dev_root;
-		child = of_platform_device_create(np, NULL, parent);
-		if (!child) {
-			of_node_put(np);
-			return -ENOMEM;
+		parent = bus_get_dev_root(&platform_bus_type);
+		if (parent) {
+			child = of_platform_device_create(np, NULL, parent);
+			put_device(parent);
+			if (!child) {
+				of_node_put(np);
+				return -ENOMEM;
+			}
 		}
 
 		if (of_property_read_u32(child->dev.of_node, "num-pins",
-- 
2.39.2


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

* [PATCH 22/36] driver core: bus: move dev_root out of struct bus_type
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (19 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 21/36] irqchip/mbigen: " Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

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


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

* [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (20 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 22/36] driver core: bus: move dev_root out of struct bus_type Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 19:14   ` Bjorn Helgaas
                     ` (8 more replies)
  2023-03-13 18:29 ` [PATCH 24/36] driver core: bus: constantify bus_register() Greg Kroah-Hartman
                   ` (12 subsequent siblings)
  34 siblings, 9 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, David S. Miller,
	James E.J. Bottomley, K. Y. Srinivasan, Martin K. Petersen,
	Alex Shi, Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si

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" <davem@davemloft.net>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Alex Shi <alexs@kernel.org>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Alison Schofield <alison.schofield@intel.com>
Cc: Ben Widawsky <bwidawsk@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Hu Haowen <src.res@email.cn>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Iwona Winiarska <iwona.winiarska@intel.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Stuart Yoder <stuyoder@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Yanteng Si <siyanteng@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 24/36] driver core: bus: constantify bus_register()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (21 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 25/36] driver core: bus: constify bus_rescan_devices() Greg Kroah-Hartman
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

bus_register() is now safe to take a constant * to bus_type, so make
that change and mark the subsys_private bus_type * constant as well.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/base.h        | 2 +-
 drivers/base/bus.c         | 2 +-
 include/linux/device/bus.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index f1034e27e651..09c6682d16b5 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -49,7 +49,7 @@ struct subsys_private {
 	struct klist klist_drivers;
 	struct blocking_notifier_head bus_notifier;
 	unsigned int drivers_autoprobe:1;
-	struct bus_type *bus;
+	const struct bus_type *bus;
 	struct device *dev_root;
 
 	struct kset glue_dirs;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 819ab745fa9f..f739a2a79e59 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -841,7 +841,7 @@ static struct bus_attribute bus_attr_uevent = __ATTR(uevent, 0200, NULL,
  * infrastructure, then register the children subsystems it has:
  * the devices and drivers that belong to the subsystem.
  */
-int bus_register(struct bus_type *bus)
+int bus_register(const struct bus_type *bus)
 {
 	int retval;
 	struct subsys_private *priv;
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 78c875386c06..c30c4748c170 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -110,7 +110,7 @@ struct bus_type {
 	bool need_parent_lock;
 };
 
-extern int __must_check bus_register(struct bus_type *bus);
+extern int __must_check bus_register(const struct bus_type *bus);
 
 extern void bus_unregister(const struct bus_type *bus);
 
-- 
2.39.2


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

* [PATCH 25/36] driver core: bus: constify bus_rescan_devices()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (22 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 24/36] driver core: bus: constantify bus_register() Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 26/36] driver core: bus: constify driver_find() Greg Kroah-Hartman
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

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


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

* [PATCH 26/36] driver core: bus: constify driver_find()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (23 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 25/36] driver core: bus: constify bus_rescan_devices() Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 27/36] driver core: bus: constify bus_get() Greg Kroah-Hartman
                   ` (9 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

The driver_find() function can now take a const * to bus_type, not just
a * so fix that up.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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


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

* [PATCH 27/36] driver core: bus: constify bus_get()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (24 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 26/36] driver core: bus: constify driver_find() Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 28/36] driver core: make the bus_type in struct device_driver constant Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

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


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

* [PATCH 28/36] driver core: make the bus_type in struct device_driver constant
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (25 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 27/36] driver core: bus: constify bus_get() Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 29/36] crypto: hisilicon/qm - make struct bus_type * const Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

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


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

* [PATCH 29/36] crypto: hisilicon/qm - make struct bus_type * const
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (26 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 28/36] driver core: make the bus_type in struct device_driver constant Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-14  8:22   ` Herbert Xu
  2023-03-13 18:29   ` [Intel-gfx] " Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Weili Qian, Zhou Wang, Herbert Xu,
	David S. Miller, linux-crypto

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 <qianweili@huawei.com>
Cc: Zhou Wang <wangzhou1@hisilicon.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: " Greg Kroah-Hartman
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 04/36] platform/x86: ibm_rtl: " Greg Kroah-Hartman
                     ` (32 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Tony Ye, Tvrtko Ursulin, Alan Previn, rafael, Greg Kroah-Hartman,
	intel-gfx, Daniele Ceraolo Spurio, dri-devel, Rodrigo Vivi,
	Vitaly Lubart, John Harrison

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 <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Ye <tony.ye@intel.com>
Cc: Vitaly Lubart <vitaly.lubart@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [Intel-gfx] [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alan Previn, rafael, Greg Kroah-Hartman, intel-gfx, dri-devel,
	Daniel Vetter, Rodrigo Vivi, David Airlie, Vitaly Lubart

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 <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Ye <tony.ye@intel.com>
Cc: Vitaly Lubart <vitaly.lubart@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Jani Nikula, Joonas Lahtinen,
	Rodrigo Vivi, Tvrtko Ursulin, David Airlie, Daniel Vetter,
	Daniele Ceraolo Spurio, Alan Previn, John Harrison, Tony Ye,
	Vitaly Lubart, intel-gfx, dri-devel

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 <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Tony Ye <tony.ye@intel.com>
Cc: Vitaly Lubart <vitaly.lubart@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 31/36] vhost-vdpa: vhost_vdpa_alloc_domain() should be using a const struct bus_type *
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: kvm, Michael S. Tsirkin, Greg Kroah-Hartman, rafael,
	virtualization, netdev

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" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: kvm@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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

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

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

* [PATCH 31/36] vhost-vdpa: vhost_vdpa_alloc_domain() should be using a const struct bus_type *
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Michael S. Tsirkin, Jason Wang, kvm,
	virtualization, netdev

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" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: kvm@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (29 preceding siblings ...)
  2023-03-13 18:29   ` Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 19:07   ` Fenghua Yu
                     ` (2 more replies)
  2023-03-13 18:29   ` Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  34 siblings, 3 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Fenghua Yu, Dave Jiang, Vinod Koul,
	dmaengine

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 <fenghua.yu@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 33/36] ARM/dma-mapping: const a pointer to bus_type in arm_iommu_create_mapping()
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
                     ` (33 subsequent siblings)
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Russell King, Russell King (Oracle),
	Arnd Bergmann, Robin Murphy, Kees Cook, Lukas Bulwahn, Ben Dooks,
	Linus Walleij, linux-arm-kernel

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 <linux@armlinux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 33/36] ARM/dma-mapping: const a pointer to bus_type in arm_iommu_create_mapping()
@ 2023-03-13 18:29   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Russell King, Russell King (Oracle),
	Arnd Bergmann, Robin Murphy, Kees Cook, Lukas Bulwahn, Ben Dooks,
	Linus Walleij, linux-arm-kernel

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 <linux@armlinux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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


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

* [PATCH 34/36] iommu: make the pointer to struct bus_type constant
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (31 preceding siblings ...)
  2023-03-13 18:29   ` Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-22 12:13   ` Joerg Roedel
  2023-03-13 18:29 ` [PATCH 35/36] driver core: device.h: make struct bus_type a const * Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 36/36] USB: mark all struct bus_type as const Greg Kroah-Hartman
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Joerg Roedel, Will Deacon,
	Robin Murphy, iommu

A number of iommu functions take a struct bus_type * and never modify
the data passed in, so make them all const * as that is what the driver
core is expecting to have passed into as well.

This is a step toward making all struct bus_type pointers constant in
the kernel.

Cc: Joerg Roedel <joro@8bytes.org>
Cc: Will Deacon <will@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: iommu@lists.linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
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/iommu/iommu.c | 14 +++++++-------
 include/linux/iommu.h | 10 +++++-----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 10db680acaed..0b5e181998c9 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -89,7 +89,7 @@ static int iommu_bus_notifier(struct notifier_block *nb,
 			      unsigned long action, void *data);
 static int iommu_alloc_default_domain(struct iommu_group *group,
 				      struct device *dev);
-static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
+static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
 						 unsigned type);
 static int __iommu_attach_device(struct iommu_domain *domain,
 				 struct device *dev);
@@ -1631,7 +1631,7 @@ static int iommu_get_def_domain_type(struct device *dev)
 	return 0;
 }
 
-static int iommu_group_alloc_default_domain(struct bus_type *bus,
+static int iommu_group_alloc_default_domain(const struct bus_type *bus,
 					    struct iommu_group *group,
 					    unsigned int type)
 {
@@ -1777,7 +1777,7 @@ static int probe_get_default_domain_type(struct device *dev, void *data)
 	return 0;
 }
 
-static void probe_alloc_default_domain(struct bus_type *bus,
+static void probe_alloc_default_domain(const struct bus_type *bus,
 				       struct iommu_group *group)
 {
 	struct __group_domain_type gtype;
@@ -1832,7 +1832,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group)
 					  iommu_do_create_direct_mappings);
 }
 
-int bus_iommu_probe(struct bus_type *bus)
+int bus_iommu_probe(const struct bus_type *bus)
 {
 	struct iommu_group *group, *next;
 	LIST_HEAD(group_list);
@@ -1876,7 +1876,7 @@ int bus_iommu_probe(struct bus_type *bus)
 	return ret;
 }
 
-bool iommu_present(struct bus_type *bus)
+bool iommu_present(const struct bus_type *bus)
 {
 	return bus->iommu_ops != NULL;
 }
@@ -1951,7 +1951,7 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
 }
 EXPORT_SYMBOL_GPL(iommu_set_fault_handler);
 
-static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
+static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
 						 unsigned type)
 {
 	struct iommu_domain *domain;
@@ -1976,7 +1976,7 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
 	return domain;
 }
 
-struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
+struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
 {
 	return __iommu_domain_alloc(bus, IOMMU_DOMAIN_UNMANAGED);
 }
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 6595454d4f48..0fd4e6734d5b 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -455,11 +455,11 @@ static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
 	return dev->iommu->iommu_dev->ops;
 }
 
-extern int bus_iommu_probe(struct bus_type *bus);
-extern bool iommu_present(struct bus_type *bus);
+extern int bus_iommu_probe(const struct bus_type *bus);
+extern bool iommu_present(const struct bus_type *bus);
 extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap);
 extern bool iommu_group_has_isolated_msi(struct iommu_group *group);
-extern struct iommu_domain *iommu_domain_alloc(struct bus_type *bus);
+extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus);
 extern struct iommu_group *iommu_group_get_by_id(int id);
 extern void iommu_domain_free(struct iommu_domain *domain);
 extern int iommu_attach_device(struct iommu_domain *domain,
@@ -732,7 +732,7 @@ struct iommu_device {};
 struct iommu_fault_param {};
 struct iommu_iotlb_gather {};
 
-static inline bool iommu_present(struct bus_type *bus)
+static inline bool iommu_present(const struct bus_type *bus)
 {
 	return false;
 }
@@ -742,7 +742,7 @@ static inline bool device_iommu_capable(struct device *dev, enum iommu_cap cap)
 	return false;
 }
 
-static inline struct iommu_domain *iommu_domain_alloc(struct bus_type *bus)
+static inline struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
 {
 	return NULL;
 }
-- 
2.39.2


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

* [PATCH 35/36] driver core: device.h: make struct bus_type a const *
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (32 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 34/36] iommu: make the pointer to struct bus_type constant Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-13 18:29 ` [PATCH 36/36] USB: mark all struct bus_type as const Greg Kroah-Hartman
  34 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: rafael, Greg Kroah-Hartman

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


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

* [PATCH 36/36] USB: mark all struct bus_type as const
  2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
                   ` (33 preceding siblings ...)
  2023-03-13 18:29 ` [PATCH 35/36] driver core: device.h: make struct bus_type a const * Greg Kroah-Hartman
@ 2023-03-13 18:29 ` Greg Kroah-Hartman
  2023-03-14  8:48   ` Heikki Krogerus
  34 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-13 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Heikki Krogerus, Johan Hovold,
	Evan Green, Alan Stern, linux-usb

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 <heikki.krogerus@linux.intel.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Evan Green <evgreen@chromium.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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


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

* Re: [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: " Greg Kroah-Hartman
@ 2023-03-13 18:38   ` John Paul Adrian Glaubitz
  2023-03-13 18:48   ` John Paul Adrian Glaubitz
  1 sibling, 0 replies; 89+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-03-13 18:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Yoshinori Sato, Rich Felker, linux-sh

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 <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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/sh/drivers/dma/dma-sysfs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
> index 8ef318150f84..431bc18f0a41 100644
> --- a/arch/sh/drivers/dma/dma-sysfs.c
> +++ b/arch/sh/drivers/dma/dma-sysfs.c
> @@ -45,13 +45,19 @@ static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
>  
>  static int __init dma_subsys_init(void)
>  {
> +	struct device *dev_root;
>  	int ret;
>  
>  	ret = subsys_system_register(&dma_subsys, NULL);
>  	if (unlikely(ret))
>  		return ret;
>  
> -	return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
> +	dev_root = bus_get_dev_root(&dma_subsys);
> +	if (dev_root) {
> +		ret = device_create_file(dev_root, &dev_attr_devices);
> +		put_device(dev_root);
> +	}
> +	return ret;
>  }
>  postcore_initcall(dma_subsys_init);
>  

Acked-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH 17/36] sh: intc: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
@ 2023-03-13 18:39   ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 89+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-03-13 18:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Yoshinori Sato, Rich Felker, linux-sh

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 <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <glaubitz@physik.fu-berlin.de>

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: " Greg Kroah-Hartman
@ 2023-03-13 18:43   ` Rafael J. Wysocki
  2023-03-17 14:50     ` Greg Kroah-Hartman
  2023-03-22  8:36     ` [PATCH v2 02/19] " Greg Kroah-Hartman
  0 siblings, 2 replies; 89+ messages in thread
From: Rafael J. Wysocki @ 2023-03-13 18:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, rafael, Len Brown, linux-acpi

On Mon, Mar 13, 2023 at 7:29 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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/acpi/acpi_lpit.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index 3843d2576d3f..73b5c4800150 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -98,6 +98,8 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
>  static void lpit_update_residency(struct lpit_residency_info *info,
>                                  struct acpi_lpit_native *lpit_native)
>  {
> +       struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +

This can return here right away if dev_root is NULL, because it will
not do anything useful in that case anyway.

>         info->frequency = lpit_native->counter_frequency ?
>                                 lpit_native->counter_frequency : tsc_khz * 1000;
>         if (!info->frequency)
> @@ -111,15 +113,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
>                         return;
>
>                 /* Silently fail, if cpuidle attribute group is not present */
> -               sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> -                                       &dev_attr_low_power_idle_system_residency_us.attr,
> -                                       "cpuidle");
> +               if (dev_root)
> +                       sysfs_add_file_to_group(&dev_root->kobj,
> +                                               &dev_attr_low_power_idle_system_residency_us.attr,
> +                                               "cpuidle");
>         } else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
>                 /* Silently fail, if cpuidle attribute group is not present */
> -               sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> -                                       &dev_attr_low_power_idle_cpu_residency_us.attr,
> -                                       "cpuidle");
> +               if (dev_root)
> +                       sysfs_add_file_to_group(&dev_root->kobj,
> +                                               &dev_attr_low_power_idle_cpu_residency_us.attr,
> +                                               "cpuidle");
>         }
> +       put_device(dev_root);
>  }
>
>  static void lpit_process(u64 begin, u64 end)
> --
> 2.39.2
>

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

* Re: [PATCH 03/36] cpufreq: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
@ 2023-03-13 18:45   ` Rafael J. Wysocki
  0 siblings, 0 replies; 89+ messages in thread
From: Rafael J. Wysocki @ 2023-03-13 18:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Viresh Kumar, Srinivas Pandruvada,
	Len Brown, linux-pm

On Mon, Mar 13, 2023 at 7:29 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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" <rafael@kernel.org>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

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

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

* Re: [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: " Greg Kroah-Hartman
  2023-03-13 18:38   ` John Paul Adrian Glaubitz
@ 2023-03-13 18:48   ` John Paul Adrian Glaubitz
  1 sibling, 0 replies; 89+ messages in thread
From: John Paul Adrian Glaubitz @ 2023-03-13 18:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Yoshinori Sato, Rich Felker, linux-sh

Hi Greg!

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 <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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/sh/drivers/dma/dma-sysfs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
> index 8ef318150f84..431bc18f0a41 100644
> --- a/arch/sh/drivers/dma/dma-sysfs.c
> +++ b/arch/sh/drivers/dma/dma-sysfs.c
> @@ -45,13 +45,19 @@ static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
>  
>  static int __init dma_subsys_init(void)
>  {
> +	struct device *dev_root;
>  	int ret;
>  
>  	ret = subsys_system_register(&dma_subsys, NULL);
>  	if (unlikely(ret))
>  		return ret;
>  
> -	return device_create_file(dma_subsys.dev_root, &dev_attr_devices);
> +	dev_root = bus_get_dev_root(&dma_subsys);
> +	if (dev_root) {
> +		ret = device_create_file(dev_root, &dev_attr_devices);
> +		put_device(dev_root);
> +	}
> +	return ret;
>  }
>  postcore_initcall(dma_subsys_init);
>  

After acking this, I noticed that if bus_get_dev_root() fails, "ret" remains
set to the value by subsys_system_register() which might confuse the caller
thinking that dma_subsys_init() succeeded unless I am missing something?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH 06/36] cpuidle: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 06/36] cpuidle: " Greg Kroah-Hartman
@ 2023-03-13 18:58   ` Rafael J. Wysocki
  2023-03-22  9:04     ` Greg Kroah-Hartman
  2023-03-22  9:05     ` [PATCH v2 03/19] " Greg Kroah-Hartman
  0 siblings, 2 replies; 89+ messages in thread
From: Rafael J. Wysocki @ 2023-03-13 18:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, rafael, Daniel Lezcano, linux-pm

On Mon, Mar 13, 2023 at 7:30 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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.
>
> This allows us to clean up the cpuidle_add_interface() call a bit as it
> was only called in one place, with the same argument so just put that
> into the function itself.  Note that cpuidle_remove_interface() should
> also probably be removed in the future as there are no callers of it for
> some reason.
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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/cpuidle/cpuidle.c |  2 +-
>  drivers/cpuidle/cpuidle.h |  2 +-
>  drivers/cpuidle/sysfs.c   | 12 +++++++++---
>  3 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 0b00f21cefe3..8e929f6602ce 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -808,7 +808,7 @@ static int __init cpuidle_init(void)
>         if (cpuidle_disabled())
>                 return -ENODEV;
>
> -       return cpuidle_add_interface(cpu_subsys.dev_root);
> +       return cpuidle_add_interface();
>  }
>
>  module_param(off, int, 0444);
> diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
> index 9f336af17fa6..52701d9588f1 100644
> --- a/drivers/cpuidle/cpuidle.h
> +++ b/drivers/cpuidle/cpuidle.h
> @@ -30,7 +30,7 @@ extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
>
>  struct device;
>
> -extern int cpuidle_add_interface(struct device *dev);
> +extern int cpuidle_add_interface(void);
>  extern void cpuidle_remove_interface(struct device *dev);
>  extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
>  extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
> index 48948b171749..84e4946f1072 100644
> --- a/drivers/cpuidle/sysfs.c
> +++ b/drivers/cpuidle/sysfs.c
> @@ -119,11 +119,17 @@ static struct attribute_group cpuidle_attr_group = {
>
>  /**
>   * cpuidle_add_interface - add CPU global sysfs attributes
> - * @dev: the target device
>   */
> -int cpuidle_add_interface(struct device *dev)
> +int cpuidle_add_interface(void)
>  {
> -       return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
> +       struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +       int retval = -EINVAL;
> +
> +       if (dev_root) {
> +               retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
> +               put_device(dev_root);
> +       }
> +       return retval;

I would prefer

  if (!dev_root)
          return -EINVAL;

  retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
  put_device(dev_root);
  return retval;

assuming that successful group creation will bump up the reference
counter of dev_root.

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

* Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-13 18:29 ` [PATCH 32/36] dmaengine: idxd: use " Greg Kroah-Hartman
@ 2023-03-13 19:07   ` Fenghua Yu
  2023-03-16 10:16     ` Greg Kroah-Hartman
  2023-03-17 17:19   ` Vinod Koul
  2023-03-17 17:33   ` Dave Jiang
  2 siblings, 1 reply; 89+ messages in thread
From: Fenghua Yu @ 2023-03-13 19:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Dave Jiang, Vinod Koul, dmaengine

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 <fenghua.yu@intel.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: dmaengine@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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

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

* Re: [PATCH 05/36] platform/x86: intel-uncore-freq: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 05/36] platform/x86: intel-uncore-freq: " Greg Kroah-Hartman
@ 2023-03-13 19:14   ` srinivas pandruvada
  2023-03-15 12:46   ` Hans de Goede
  1 sibling, 0 replies; 89+ messages in thread
From: srinivas pandruvada @ 2023-03-13 19:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Hans de Goede, Mark Gross, platform-driver-x86

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: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
> 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.
> 
>  .../intel/uncore-frequency/uncore-frequency-common.c | 12 +++++++++-
> --
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-
> frequency-common.c b/drivers/platform/x86/intel/uncore-
> frequency/uncore-frequency-common.c
> index cb24de9e97dc..1a300e14f350 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c
> @@ -224,9 +224,15 @@ int uncore_freq_common_init(int
> (*read_control_freq)(struct uncore_data *data, u
>         uncore_write = write_control_freq;
>         uncore_read_freq = read_freq;
>  
> -       if (!uncore_root_kobj)
> -               uncore_root_kobj =
> kobject_create_and_add("intel_uncore_frequency",
> -                                                          
> &cpu_subsys.dev_root->kobj);
> +       if (!uncore_root_kobj) {
> +               struct device *dev_root =
> bus_get_dev_root(&cpu_subsys);
> +
> +               if (dev_root) {
> +                       uncore_root_kobj =
> kobject_create_and_add("intel_uncore_frequency",
> +                                                                
> &dev_root->kobj);
> +                       put_device(dev_root);
> +               }
> +       }
>         if (uncore_root_kobj)
>                 ++uncore_instance_count;
>         mutex_unlock(&uncore_lock);


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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
@ 2023-03-13 19:14   ` Bjorn Helgaas
  2023-03-13 22:41   ` Wei Liu
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 89+ messages in thread
From: Bjorn Helgaas @ 2023-03-13 19:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, David S. Miller, James E.J. Bottomley,
	K. Y. Srinivasan, Martin K. Petersen, Alex Shi,
	Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si

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" <davem@davemloft.net>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Alex Shi <alexs@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Alexandre Bounine <alex.bou9@gmail.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Hu Haowen <src.res@email.cn>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Iwona Winiarska <iwona.winiarska@intel.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Matt Porter <mporter@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>	# 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;

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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
  2023-03-13 19:14   ` Bjorn Helgaas
@ 2023-03-13 22:41   ` Wei Liu
  2023-03-13 23:01   ` Ira Weiny
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 89+ messages in thread
From: Wei Liu @ 2023-03-13 22:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, David S. Miller, James E.J. Bottomley,
	K. Y. Srinivasan, Martin K. Petersen, Alex Shi,
	Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si

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 <wei.liu@kernel.org>

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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
  2023-03-13 19:14   ` Bjorn Helgaas
  2023-03-13 22:41   ` Wei Liu
@ 2023-03-13 23:01   ` Ira Weiny
  2023-03-14  7:10   ` Harald Freudenberger
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 89+ messages in thread
From: Ira Weiny @ 2023-03-13 23:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Greg Kroah-Hartman, David S. Miller,
	James E.J. Bottomley, K. Y. Srinivasan, Martin K. Petersen,
	Alex Shi, Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si

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" <davem@davemloft.net>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Alex Shi <alexs@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Alexandre Bounine <alex.bou9@gmail.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Hu Haowen <src.res@email.cn>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Iwona Winiarska <iwona.winiarska@intel.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Matt Porter <mporter@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Ira Weiny <ira.weiny@intel.com> # 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);

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

* Re: [PATCH 08/36] workqueue: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 08/36] workqueue: " Greg Kroah-Hartman
@ 2023-03-14  3:31   ` Tejun Heo
  0 siblings, 0 replies; 89+ messages in thread
From: Tejun Heo @ 2023-03-14  3:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, rafael, Lai Jiangshan

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 <tj@kernel.org>
> Cc: Lai Jiangshan <jiangshanlai@gmail.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Tejun Heo <tj@kernel.org>

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

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

* Re: [PATCH 20/36] cpufreq: amd-pstate: move to use bus_get_dev_root()
  2023-03-13 18:29 ` [PATCH 20/36] cpufreq: amd-pstate: " Greg Kroah-Hartman
@ 2023-03-14  6:04   ` Huang Rui
  0 siblings, 0 replies; 89+ messages in thread
From: Huang Rui @ 2023-03-14  6:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, rafael, Viresh Kumar, linux-pm

On Tue, Mar 14, 2023 at 02:29:02AM +0800, 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.
> 
> In doing so, remove the unneded kobject structure that was only being
> created to cause a subdirectory for the attributes.  The name of the
> attribute group is the correct way to do this, saving code and
> complexity as well as allowing the attributes to properly show up to
> userspace tools (the raw kobject would not allow that.)
> 
> Cc: Huang Rui <ray.huang@amd.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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.

Thanks Greg.

Acked-by: Huang Rui <ray.huang@.amd.com>

> 
>  drivers/cpufreq/amd-pstate.c | 24 ++++++++++--------------
>  1 file changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 73c7643b2697..b92454c50118 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -63,7 +63,6 @@ static struct cpufreq_driver *current_pstate_driver;
>  static struct cpufreq_driver amd_pstate_driver;
>  static struct cpufreq_driver amd_pstate_epp_driver;
>  static int cppc_state = AMD_PSTATE_DISABLE;
> -struct kobject *amd_pstate_kobj;
>  
>  /*
>   * AMD Energy Preference Performance (EPP)
> @@ -932,6 +931,7 @@ static struct attribute *pstate_global_attributes[] = {
>  };
>  
>  static const struct attribute_group amd_pstate_global_attr_group = {
> +	.name = "amd_pstate",
>  	.attrs = pstate_global_attributes,
>  };
>  
> @@ -1253,6 +1253,7 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
>  
>  static int __init amd_pstate_init(void)
>  {
> +	struct device *dev_root;
>  	int ret;
>  
>  	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
> @@ -1299,24 +1300,19 @@ static int __init amd_pstate_init(void)
>  	if (ret)
>  		pr_err("failed to register with return %d\n", ret);
>  
> -	amd_pstate_kobj = kobject_create_and_add("amd_pstate", &cpu_subsys.dev_root->kobj);
> -	if (!amd_pstate_kobj) {
> -		ret = -EINVAL;
> -		pr_err("global sysfs registration failed.\n");
> -		goto kobject_free;
> -	}
> -
> -	ret = sysfs_create_group(amd_pstate_kobj, &amd_pstate_global_attr_group);
> -	if (ret) {
> -		pr_err("sysfs attribute export failed with error %d.\n", ret);
> -		goto global_attr_free;
> +	dev_root = bus_get_dev_root(&cpu_subsys);
> +	if (dev_root) {
> +		ret = sysfs_create_group(&dev_root->kobj, &amd_pstate_global_attr_group);
> +		put_device(dev_root);
> +		if (ret) {
> +			pr_err("sysfs attribute export failed with error %d.\n", ret);
> +			goto global_attr_free;
> +		}
>  	}
>  
>  	return ret;
>  
>  global_attr_free:
> -	kobject_put(amd_pstate_kobj);
> -kobject_free:
>  	cpufreq_unregister_driver(current_pstate_driver);
>  	return ret;
>  }
> -- 
> 2.39.2
> 

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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                     ` (2 preceding siblings ...)
  2023-03-13 23:01   ` Ira Weiny
@ 2023-03-14  7:10   ` Harald Freudenberger
  2023-03-14 17:43   ` Dan Williams
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 89+ messages in thread
From: Harald Freudenberger @ 2023-03-14  7:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, David S. Miller, James E.J. Bottomley,
	K. Y. Srinivasan, Martin K. Petersen, Alex Shi,
	Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke, Heiko Carstens,
	Hu Haowen, Ilya Dryomov, Ira Weiny, Iwona Winiarska,
	Jakub Kicinski, Jens Axboe, Jonathan Corbet, Laurentiu Tudor,
	Matt Porter, Michael Ellerman, Paolo Abeni, Stuart Yoder,
	Vasily Gorbik, Vishal Verma, Wei Liu, Yanteng Si

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" <davem@davemloft.net>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Alex Shi <alexs@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Alexandre Bounine <alex.bou9@gmail.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Hu Haowen <src.res@email.cn>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Iwona Winiarska <iwona.winiarska@intel.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Matt Porter <mporter@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 
<freude@linux.ibm.com>

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

* Re: [PATCH 29/36] crypto: hisilicon/qm - make struct bus_type * const
  2023-03-13 18:29 ` [PATCH 29/36] crypto: hisilicon/qm - make struct bus_type * const Greg Kroah-Hartman
@ 2023-03-14  8:22   ` Herbert Xu
  0 siblings, 0 replies; 89+ messages in thread
From: Herbert Xu @ 2023-03-14  8:22 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Weili Qian, Zhou Wang, David S. Miller,
	linux-crypto

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 <qianweili@huawei.com>
> Cc: Zhou Wang <wangzhou1@hisilicon.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: linux-crypto@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <herbert@gondor.apana.org.au>
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH 36/36] USB: mark all struct bus_type as const
  2023-03-13 18:29 ` [PATCH 36/36] USB: mark all struct bus_type as const Greg Kroah-Hartman
@ 2023-03-14  8:48   ` Heikki Krogerus
  0 siblings, 0 replies; 89+ messages in thread
From: Heikki Krogerus @ 2023-03-14  8:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Johan Hovold, Evan Green, Alan Stern, linux-usb

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 <heikki.krogerus@linux.intel.com>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Evan Green <evgreen@chromium.org>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

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

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

* Re: [PATCH 18/36] s390/topology: move to use bus_get_dev_root()
  2023-03-13 18:29 ` [PATCH 18/36] s390/topology: " Greg Kroah-Hartman
@ 2023-03-14 11:34   ` Heiko Carstens
  0 siblings, 0 replies; 89+ messages in thread
From: Heiko Carstens @ 2023-03-14 11:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, linux-s390

On Mon, Mar 13, 2023 at 07:29:00PM +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: Heiko Carstens <hca@linux.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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/s390/kernel/topology.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

Acked-by: Heiko Carstens <hca@linux.ibm.com>

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

* Re: [PATCH 19/36] s390/smp: move to use bus_get_dev_root()
  2023-03-13 18:29 ` [PATCH 19/36] s390/smp: " Greg Kroah-Hartman
@ 2023-03-14 11:35   ` Heiko Carstens
  0 siblings, 0 replies; 89+ messages in thread
From: Heiko Carstens @ 2023-03-14 11:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Ilya Leoshkevich,
	linux-s390

On Mon, Mar 13, 2023 at 07:29:01PM +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: Heiko Carstens <hca@linux.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
> Cc: Sven Schnelle <svens@linux.ibm.com>
> Cc: Ilya Leoshkevich <iii@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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/s390/kernel/smp.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

Acked-by: Heiko Carstens <hca@linux.ibm.com>

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

* RE: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                     ` (3 preceding siblings ...)
  2023-03-14  7:10   ` Harald Freudenberger
@ 2023-03-14 17:43   ` Dan Williams
  2023-03-15  2:33   ` Martin K. Petersen
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 89+ messages in thread
From: Dan Williams @ 2023-03-14 17:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Greg Kroah-Hartman, David S. Miller,
	James E.J. Bottomley, K. Y. Srinivasan, Martin K. Petersen,
	Alex Shi, Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si

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 <dan.j.williams@intel.com>
[..]
> 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 <dan.j.williams@intel.com>

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

* Re: [PATCH 14/36] powerpc/pseries: move to use bus_get_dev_root()
  2023-03-13 18:28   ` Greg Kroah-Hartman
@ 2023-03-15  2:00     ` Michael Ellerman
  -1 siblings, 0 replies; 89+ messages in thread
From: Michael Ellerman @ 2023-03-15  2:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Nicholas Piggin, Christophe Leroy,
	linuxppc-dev

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> 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: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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.
>
>  .../platforms/pseries/pseries_energy.c        | 28 +++++++++++--------
>  arch/powerpc/platforms/pseries/suspend.c      | 10 +++++--
>  2 files changed, 25 insertions(+), 13 deletions(-)

Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

The other powerpc changes look OK too.

cheers

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

* Re: [PATCH 14/36] powerpc/pseries: move to use bus_get_dev_root()
@ 2023-03-15  2:00     ` Michael Ellerman
  0 siblings, 0 replies; 89+ messages in thread
From: Michael Ellerman @ 2023-03-15  2:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Greg Kroah-Hartman, linuxppc-dev, Nicholas Piggin, rafael

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
> 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: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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.
>
>  .../platforms/pseries/pseries_energy.c        | 28 +++++++++++--------
>  arch/powerpc/platforms/pseries/suspend.c      | 10 +++++--
>  2 files changed, 25 insertions(+), 13 deletions(-)

Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

The other powerpc changes look OK too.

cheers

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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                     ` (4 preceding siblings ...)
  2023-03-14 17:43   ` Dan Williams
@ 2023-03-15  2:33   ` Martin K. Petersen
  2023-03-15 11:10   ` Ilya Dryomov
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 89+ messages in thread
From: Martin K. Petersen @ 2023-03-15  2:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, David S. Miller, James E.J. Bottomley,
	K. Y. Srinivasan, Martin K. Petersen, Alex Shi,
	Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si


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 <martin.petersen@oracle.com> # scsi

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
  2023-03-13 18:29   ` [Intel-gfx] " Greg Kroah-Hartman
  (?)
@ 2023-03-15 10:15     ` Tvrtko Ursulin
  -1 siblings, 0 replies; 89+ messages in thread
From: Tvrtko Ursulin @ 2023-03-15 10:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Tony Ye, Alan Previn, rafael, intel-gfx, Daniele Ceraolo Spurio,
	dri-devel, Rodrigo Vivi, Vitaly Lubart, John Harrison


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 <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Tony Ye <tony.ye@intel.com>
> Cc: Vitaly Lubart <vitaly.lubart@intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <tvrtko.ursulin@intel.com>

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)
>   {

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

* Re: [Intel-gfx] [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
@ 2023-03-15 10:15     ` Tvrtko Ursulin
  0 siblings, 0 replies; 89+ messages in thread
From: Tvrtko Ursulin @ 2023-03-15 10:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: Alan Previn, rafael, intel-gfx, dri-devel, Daniel Vetter,
	Rodrigo Vivi, David Airlie, Vitaly Lubart


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 <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Tony Ye <tony.ye@intel.com>
> Cc: Vitaly Lubart <vitaly.lubart@intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <tvrtko.ursulin@intel.com>

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)
>   {

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

* Re: [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
@ 2023-03-15 10:15     ` Tvrtko Ursulin
  0 siblings, 0 replies; 89+ messages in thread
From: Tvrtko Ursulin @ 2023-03-15 10:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, David Airlie,
	Daniel Vetter, Daniele Ceraolo Spurio, Alan Previn,
	John Harrison, Tony Ye, Vitaly Lubart, intel-gfx, dri-devel


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 <jani.nikula@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Tony Ye <tony.ye@intel.com>
> Cc: Vitaly Lubart <vitaly.lubart@intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <tvrtko.ursulin@intel.com>

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)
>   {

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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                     ` (5 preceding siblings ...)
  2023-03-15  2:33   ` Martin K. Petersen
@ 2023-03-15 11:10   ` Ilya Dryomov
  2023-03-15 11:51   ` Alex Shi
  2023-03-15 15:05   ` Winiarska, Iwona
  8 siblings, 0 replies; 89+ messages in thread
From: Ilya Dryomov @ 2023-03-15 11:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, David S. Miller, James E.J. Bottomley,
	K. Y. Srinivasan, Martin K. Petersen, Alex Shi,
	Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ira Weiny,
	Iwona Winiarska, Jakub Kicinski, Jens Axboe, Jonathan Corbet,
	Laurentiu Tudor, Matt Porter, Michael Ellerman, Paolo Abeni,
	Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu, Yanteng Si

On Mon, Mar 13, 2023 at 7:30 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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" <davem@davemloft.net>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Alex Shi <alexs@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Alexandre Bounine <alex.bou9@gmail.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Hu Haowen <src.res@email.cn>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Iwona Winiarska <iwona.winiarska@intel.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Matt Porter <mporter@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <idryomov@gmail.com> # rbd

Thanks,

                Ilya

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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                     ` (6 preceding siblings ...)
  2023-03-15 11:10   ` Ilya Dryomov
@ 2023-03-15 11:51   ` Alex Shi
  2023-03-15 15:05   ` Winiarska, Iwona
  8 siblings, 0 replies; 89+ messages in thread
From: Alex Shi @ 2023-03-15 11:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, David S. Miller, James E.J. Bottomley,
	K. Y. Srinivasan, Martin K. Petersen, Alex Shi,
	Alexander Gordeev, Alexandre Bounine, Alison Schofield,
	Ben Widawsky, Bjorn Helgaas, Dan Williams, Dexuan Cui,
	Eric Dumazet, Haiyang Zhang, Hannes Reinecke,
	Harald Freudenberger, Heiko Carstens, Hu Haowen, Ilya Dryomov,
	Ira Weiny, Iwona Winiarska, Jakub Kicinski, Jens Axboe,
	Jonathan Corbet, Laurentiu Tudor, Matt Porter, Michael Ellerman,
	Paolo Abeni, Stuart Yoder, Vasily Gorbik, Vishal Verma, Wei Liu,
	Yanteng Si

On Tue, Mar 14, 2023 at 2:30 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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 <alexs@kernel.org>

> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Alex Shi <alexs@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Alexandre Bounine <alex.bou9@gmail.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Hu Haowen <src.res@email.cn>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Iwona Winiarska <iwona.winiarska@intel.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Matt Porter <mporter@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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
>

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

* Re: [PATCH 04/36] platform/x86: ibm_rtl: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 04/36] platform/x86: ibm_rtl: " Greg Kroah-Hartman
@ 2023-03-15 12:46   ` Hans de Goede
  0 siblings, 0 replies; 89+ messages in thread
From: Hans de Goede @ 2023-03-15 12:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel; +Cc: rafael, Mark Gross, platform-driver-x86

Hi,

On 3/13/23 19:28, 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: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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.

Taking this upstream through the driver-core tree is fine by me:

Acked-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



>  drivers/platform/x86/ibm_rtl.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c
> index 5fc665f7d9b3..2ab7d9ac542d 100644
> --- a/drivers/platform/x86/ibm_rtl.c
> +++ b/drivers/platform/x86/ibm_rtl.c
> @@ -199,16 +199,26 @@ static int rtl_setup_sysfs(void) {
>  
>  	ret = subsys_system_register(&rtl_subsys, NULL);
>  	if (!ret) {
> -		for (i = 0; rtl_attributes[i]; i ++)
> -			device_create_file(rtl_subsys.dev_root, rtl_attributes[i]);
> +		struct device *dev_root = bus_get_dev_root(&rtl_subsys);
> +
> +		if (dev_root) {
> +			for (i = 0; rtl_attributes[i]; i ++)
> +				device_create_file(dev_root, rtl_attributes[i]);
> +			put_device(dev_root);
> +		}
>  	}
>  	return ret;
>  }
>  
>  static void rtl_teardown_sysfs(void) {
> +	struct device *dev_root = bus_get_dev_root(&rtl_subsys);
>  	int i;
> -	for (i = 0; rtl_attributes[i]; i ++)
> -		device_remove_file(rtl_subsys.dev_root, rtl_attributes[i]);
> +
> +	if (dev_root) {
> +		for (i = 0; rtl_attributes[i]; i ++)
> +			device_remove_file(dev_root, rtl_attributes[i]);
> +		put_device(dev_root);
> +	}
>  	bus_unregister(&rtl_subsys);
>  }
>  


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

* Re: [PATCH 05/36] platform/x86: intel-uncore-freq: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 05/36] platform/x86: intel-uncore-freq: " Greg Kroah-Hartman
  2023-03-13 19:14   ` srinivas pandruvada
@ 2023-03-15 12:46   ` Hans de Goede
  1 sibling, 0 replies; 89+ messages in thread
From: Hans de Goede @ 2023-03-15 12:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Srinivas Pandruvada, Mark Gross, platform-driver-x86

Hi,

On 3/13/23 19:28, 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: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> Cc: platform-driver-x86@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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.

Taking this upstream through the driver-core tree is fine by me:

Acked-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans




> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> index cb24de9e97dc..1a300e14f350 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
> @@ -224,9 +224,15 @@ int uncore_freq_common_init(int (*read_control_freq)(struct uncore_data *data, u
>  	uncore_write = write_control_freq;
>  	uncore_read_freq = read_freq;
>  
> -	if (!uncore_root_kobj)
> -		uncore_root_kobj = kobject_create_and_add("intel_uncore_frequency",
> -							    &cpu_subsys.dev_root->kobj);
> +	if (!uncore_root_kobj) {
> +		struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +
> +		if (dev_root) {
> +			uncore_root_kobj = kobject_create_and_add("intel_uncore_frequency",
> +								  &dev_root->kobj);
> +			put_device(dev_root);
> +		}
> +	}
>  	if (uncore_root_kobj)
>  		++uncore_instance_count;
>  	mutex_unlock(&uncore_lock);


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

* Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
  2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
                     ` (7 preceding siblings ...)
  2023-03-15 11:51   ` Alex Shi
@ 2023-03-15 15:05   ` Winiarska, Iwona
  8 siblings, 0 replies; 89+ messages in thread
From: Winiarska, Iwona @ 2023-03-15 15:05 UTC (permalink / raw)
  To: gregkh, linux-kernel
  Cc: alexs, Williams, Dan J, wei.liu, siyanteng, agordeev, davem,
	haiyangz, kys, axboe, hca, pabeni, corbet, Verma, Vishal L,
	laurentiu.tudor, bwidawsk, mpe, rafael, kuba, Cui, Dexuan, hare,
	bhelgaas, jejb, src.res, gor, edumazet, martin.petersen, mporter,
	Weiny, Ira, idryomov, freude, alex.bou9, stuyoder, Schofield,
	Alison

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" <davem@davemloft.net>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Alex Shi <alexs@kernel.org>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Alexandre Bounine <alex.bou9@gmail.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Ben Widawsky <bwidawsk@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <hca@linux.ibm.com>
> Cc: Hu Haowen <src.res@email.cn>
> Cc: Ilya Dryomov <idryomov@gmail.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Iwona Winiarska <iwona.winiarska@intel.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jonathan Corbet <corbet@lwn.net>
> Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Cc: Matt Porter <mporter@kernel.crashing.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Yanteng Si <siyanteng@loongson.cn>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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 <iwona.winiarska@intel.com>

Thanks
-Iwona

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

* Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-13 19:07   ` Fenghua Yu
@ 2023-03-16 10:16     ` Greg Kroah-Hartman
  2023-03-16 23:57       ` Fenghua Yu
  0 siblings, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-16 10:16 UTC (permalink / raw)
  To: Fenghua Yu; +Cc: linux-kernel, rafael, Dave Jiang, Vinod Koul, dmaengine

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 <fenghua.yu@intel.com>
> > Cc: Dave Jiang <dave.jiang@intel.com>
> > Cc: Vinod Koul <vkoul@kernel.org>
> > Cc: dmaengine@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > 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

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

* Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-16 10:16     ` Greg Kroah-Hartman
@ 2023-03-16 23:57       ` Fenghua Yu
  2023-03-24  8:57         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 89+ messages in thread
From: Fenghua Yu @ 2023-03-16 23:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Dave Jiang, Vinod Koul, dmaengine

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 <fenghua.yu@intel.com>
>>> Cc: Dave Jiang <dave.jiang@intel.com>
>>> Cc: Vinod Koul <vkoul@kernel.org>
>>> Cc: dmaengine@vger.kernel.org
>>> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> ---
>>> 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 <fenghua.yu@intel.com>

Thanks.

-Fenghua

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

* Re: [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
  2023-03-13 18:43   ` Rafael J. Wysocki
@ 2023-03-17 14:50     ` Greg Kroah-Hartman
  2023-03-22  8:36     ` [PATCH v2 02/19] " Greg Kroah-Hartman
  1 sibling, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-17 14:50 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-kernel, Len Brown, linux-acpi

On Mon, Mar 13, 2023 at 07:43:22PM +0100, Rafael J. Wysocki wrote:
> On Mon, Mar 13, 2023 at 7:29 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> 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" <rafael@kernel.org>
> > Cc: Len Brown <lenb@kernel.org>
> > Cc: linux-acpi@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > 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/acpi/acpi_lpit.c | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> > index 3843d2576d3f..73b5c4800150 100644
> > --- a/drivers/acpi/acpi_lpit.c
> > +++ b/drivers/acpi/acpi_lpit.c
> > @@ -98,6 +98,8 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
> >  static void lpit_update_residency(struct lpit_residency_info *info,
> >                                  struct acpi_lpit_native *lpit_native)
> >  {
> > +       struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> > +
> 
> This can return here right away if dev_root is NULL, because it will
> not do anything useful in that case anyway.

Thanks for the review of these, I'll redo some of them and send out a
v2 of them next week.

greg k-h

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

* Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-13 18:29 ` [PATCH 32/36] dmaengine: idxd: use " Greg Kroah-Hartman
  2023-03-13 19:07   ` Fenghua Yu
@ 2023-03-17 17:19   ` Vinod Koul
  2023-03-17 17:33   ` Dave Jiang
  2 siblings, 0 replies; 89+ messages in thread
From: Vinod Koul @ 2023-03-17 17:19 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, rafael, Fenghua Yu, Dave Jiang, dmaengine

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 <vkoul@kernel.org>

-- 
~Vinod

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

* Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-13 18:29 ` [PATCH 32/36] dmaengine: idxd: use " Greg Kroah-Hartman
  2023-03-13 19:07   ` Fenghua Yu
  2023-03-17 17:19   ` Vinod Koul
@ 2023-03-17 17:33   ` Dave Jiang
  2 siblings, 0 replies; 89+ messages in thread
From: Dave Jiang @ 2023-03-17 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Fenghua Yu, Vinod Koul, dmaengine



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 <fenghua.yu@intel.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: dmaengine@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Dave Jiang <dave.jiang@intel.com>

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

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

* Re: [PATCH 07/36] cpu/hotplug: move to use bus_get_dev_root()
  2023-03-13 18:28 ` [PATCH 07/36] cpu/hotplug: " Greg Kroah-Hartman
@ 2023-03-20 13:59   ` Thomas Gleixner
  0 siblings, 0 replies; 89+ messages in thread
From: Thomas Gleixner @ 2023-03-20 13:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel
  Cc: rafael, Greg Kroah-Hartman, Valentin Schneider, Phil Auld,
	Steven Price, Juri Lelli, Vincent Donnefort,
	Kuppuswamy Sathyanarayanan, Jason A. Donenfeld

On Mon, Mar 13 2023 at 19:28, 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: Thomas Gleixner <tglx@linutronix.de>
> Cc: Valentin Schneider <vschneid@redhat.com>
> Cc: Phil Auld <pauld@redhat.com>
> Cc: Steven Price <steven.price@arm.com>
> Cc: Juri Lelli <juri.lelli@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Vincent Donnefort <vdonnefort@google.com>
> Cc: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

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

No problem.

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

* [PATCH v2 02/19] ACPI: LPIT: move to use bus_get_dev_root()
  2023-03-13 18:43   ` Rafael J. Wysocki
  2023-03-17 14:50     ` Greg Kroah-Hartman
@ 2023-03-22  8:36     ` Greg Kroah-Hartman
  2023-03-22 14:15       ` Rafael J. Wysocki
  1 sibling, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-22  8:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Len Brown, linux-acpi

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" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2: - change logic to test for dev_root at the beginning of the function
      and error out then based on review comments from Rafael.
    - fix error handling for ioremap() call to properly drop the
      reference on dev_root if it failed.

 drivers/acpi/acpi_lpit.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
index 3843d2576d3f..c5598b6d5db8 100644
--- a/drivers/acpi/acpi_lpit.c
+++ b/drivers/acpi/acpi_lpit.c
@@ -98,6 +98,12 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
 static void lpit_update_residency(struct lpit_residency_info *info,
 				 struct acpi_lpit_native *lpit_native)
 {
+	struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+
+	/* Silently fail, if cpuidle attribute group is not present */
+	if (!dev_root)
+		return;
+
 	info->frequency = lpit_native->counter_frequency ?
 				lpit_native->counter_frequency : tsc_khz * 1000;
 	if (!info->frequency)
@@ -108,18 +114,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
 		info->iomem_addr = ioremap(info->gaddr.address,
 						   info->gaddr.bit_width / 8);
 		if (!info->iomem_addr)
-			return;
+			goto exit;
 
-		/* Silently fail, if cpuidle attribute group is not present */
-		sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
+		sysfs_add_file_to_group(&dev_root->kobj,
 					&dev_attr_low_power_idle_system_residency_us.attr,
 					"cpuidle");
 	} else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
-		/* Silently fail, if cpuidle attribute group is not present */
-		sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
+		sysfs_add_file_to_group(&dev_root->kobj,
 					&dev_attr_low_power_idle_cpu_residency_us.attr,
 					"cpuidle");
 	}
+exit:
+	put_device(dev_root);
 }
 
 static void lpit_process(u64 begin, u64 end)
-- 
2.40.0


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

* Re: [PATCH 06/36] cpuidle: move to use bus_get_dev_root()
  2023-03-13 18:58   ` Rafael J. Wysocki
@ 2023-03-22  9:04     ` Greg Kroah-Hartman
  2023-03-22  9:05     ` [PATCH v2 03/19] " Greg Kroah-Hartman
  1 sibling, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-22  9:04 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-kernel, Daniel Lezcano, linux-pm

On Mon, Mar 13, 2023 at 07:58:02PM +0100, Rafael J. Wysocki wrote:
> On Mon, Mar 13, 2023 at 7:30 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> 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.
> >
> > This allows us to clean up the cpuidle_add_interface() call a bit as it
> > was only called in one place, with the same argument so just put that
> > into the function itself.  Note that cpuidle_remove_interface() should
> > also probably be removed in the future as there are no callers of it for
> > some reason.
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: linux-pm@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > 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/cpuidle/cpuidle.c |  2 +-
> >  drivers/cpuidle/cpuidle.h |  2 +-
> >  drivers/cpuidle/sysfs.c   | 12 +++++++++---
> >  3 files changed, 11 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> > index 0b00f21cefe3..8e929f6602ce 100644
> > --- a/drivers/cpuidle/cpuidle.c
> > +++ b/drivers/cpuidle/cpuidle.c
> > @@ -808,7 +808,7 @@ static int __init cpuidle_init(void)
> >         if (cpuidle_disabled())
> >                 return -ENODEV;
> >
> > -       return cpuidle_add_interface(cpu_subsys.dev_root);
> > +       return cpuidle_add_interface();
> >  }
> >
> >  module_param(off, int, 0444);
> > diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
> > index 9f336af17fa6..52701d9588f1 100644
> > --- a/drivers/cpuidle/cpuidle.h
> > +++ b/drivers/cpuidle/cpuidle.h
> > @@ -30,7 +30,7 @@ extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
> >
> >  struct device;
> >
> > -extern int cpuidle_add_interface(struct device *dev);
> > +extern int cpuidle_add_interface(void);
> >  extern void cpuidle_remove_interface(struct device *dev);
> >  extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
> >  extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
> > diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
> > index 48948b171749..84e4946f1072 100644
> > --- a/drivers/cpuidle/sysfs.c
> > +++ b/drivers/cpuidle/sysfs.c
> > @@ -119,11 +119,17 @@ static struct attribute_group cpuidle_attr_group = {
> >
> >  /**
> >   * cpuidle_add_interface - add CPU global sysfs attributes
> > - * @dev: the target device
> >   */
> > -int cpuidle_add_interface(struct device *dev)
> > +int cpuidle_add_interface(void)
> >  {
> > -       return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
> > +       struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> > +       int retval = -EINVAL;
> > +
> > +       if (dev_root) {
> > +               retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
> > +               put_device(dev_root);
> > +       }
> > +       return retval;
> 
> I would prefer
> 
>   if (!dev_root)
>           return -EINVAL;
> 
>   retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
>   put_device(dev_root);
>   return retval;
> 
> assuming that successful group creation will bump up the reference
> counter of dev_root.

That is correct.  I'll respin this with this change in it now, thanks
for the review!

greg k-h

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

* [PATCH v2 03/19] cpuidle: move to use bus_get_dev_root()
  2023-03-13 18:58   ` Rafael J. Wysocki
  2023-03-22  9:04     ` Greg Kroah-Hartman
@ 2023-03-22  9:05     ` Greg Kroah-Hartman
  2023-03-22 14:27       ` Rafael J. Wysocki
  1 sibling, 1 reply; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-22  9:05 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Daniel Lezcano, linux-pm

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.

This allows us to clean up the cpuidle_add_interface() call a bit as it
was only called in one place, with the same argument so just put that
into the function itself.  Note that cpuidle_remove_interface() should
also probably be removed in the future as there are no callers of it for
some reason.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v2: - reworked cpuidle_add_interface() to exit early if dev_root is not
      valid based on review from Rafael.

 drivers/cpuidle/cpuidle.c |  2 +-
 drivers/cpuidle/cpuidle.h |  2 +-
 drivers/cpuidle/sysfs.c   | 13 ++++++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 0b00f21cefe3..8e929f6602ce 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -808,7 +808,7 @@ static int __init cpuidle_init(void)
 	if (cpuidle_disabled())
 		return -ENODEV;
 
-	return cpuidle_add_interface(cpu_subsys.dev_root);
+	return cpuidle_add_interface();
 }
 
 module_param(off, int, 0444);
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index 9f336af17fa6..52701d9588f1 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -30,7 +30,7 @@ extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
 
 struct device;
 
-extern int cpuidle_add_interface(struct device *dev);
+extern int cpuidle_add_interface(void);
 extern void cpuidle_remove_interface(struct device *dev);
 extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
 extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 48948b171749..d6f5da61cb7d 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -119,11 +119,18 @@ static struct attribute_group cpuidle_attr_group = {
 
 /**
  * cpuidle_add_interface - add CPU global sysfs attributes
- * @dev: the target device
  */
-int cpuidle_add_interface(struct device *dev)
+int cpuidle_add_interface(void)
 {
-	return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
+	struct device *dev_root = bus_get_dev_root(&cpu_subsys);
+	int retval;
+
+	if (!dev_root)
+		return -EINVAL;
+
+	retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
+	put_device(dev_root);
+	return retval;
 }
 
 /**
-- 
2.40.0


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

* Re: [PATCH 34/36] iommu: make the pointer to struct bus_type constant
  2023-03-13 18:29 ` [PATCH 34/36] iommu: make the pointer to struct bus_type constant Greg Kroah-Hartman
@ 2023-03-22 12:13   ` Joerg Roedel
  0 siblings, 0 replies; 89+ messages in thread
From: Joerg Roedel @ 2023-03-22 12:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, rafael, Will Deacon, Robin Murphy, iommu

On Mon, Mar 13, 2023 at 07:29:16PM +0100, Greg Kroah-Hartman wrote:
> A number of iommu functions take a struct bus_type * and never modify
> the data passed in, so make them all const * as that is what the driver
> core is expecting to have passed into as well.
> 
> This is a step toward making all struct bus_type pointers constant in
> the kernel.
> 
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Will Deacon <will@kernel.org>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: iommu@lists.linux.dev
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> 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.

This will probably cause conflicts in linux-next, but anyway, those
should be easy to resolve. So

Acked-by: Joerg Roedel <jroedel@suse.de>


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

* Re: [PATCH v2 02/19] ACPI: LPIT: move to use bus_get_dev_root()
  2023-03-22  8:36     ` [PATCH v2 02/19] " Greg Kroah-Hartman
@ 2023-03-22 14:15       ` Rafael J. Wysocki
  0 siblings, 0 replies; 89+ messages in thread
From: Rafael J. Wysocki @ 2023-03-22 14:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Rafael J. Wysocki, Len Brown, linux-acpi

On Wed, Mar 22, 2023 at 9:36 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

> ---
> v2: - change logic to test for dev_root at the beginning of the function
>       and error out then based on review comments from Rafael.
>     - fix error handling for ioremap() call to properly drop the
>       reference on dev_root if it failed.
>
>  drivers/acpi/acpi_lpit.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index 3843d2576d3f..c5598b6d5db8 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -98,6 +98,12 @@ EXPORT_SYMBOL_GPL(lpit_read_residency_count_address);
>  static void lpit_update_residency(struct lpit_residency_info *info,
>                                  struct acpi_lpit_native *lpit_native)
>  {
> +       struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +
> +       /* Silently fail, if cpuidle attribute group is not present */
> +       if (!dev_root)
> +               return;
> +
>         info->frequency = lpit_native->counter_frequency ?
>                                 lpit_native->counter_frequency : tsc_khz * 1000;
>         if (!info->frequency)
> @@ -108,18 +114,18 @@ static void lpit_update_residency(struct lpit_residency_info *info,
>                 info->iomem_addr = ioremap(info->gaddr.address,
>                                                    info->gaddr.bit_width / 8);
>                 if (!info->iomem_addr)
> -                       return;
> +                       goto exit;
>
> -               /* Silently fail, if cpuidle attribute group is not present */
> -               sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> +               sysfs_add_file_to_group(&dev_root->kobj,
>                                         &dev_attr_low_power_idle_system_residency_us.attr,
>                                         "cpuidle");
>         } else if (info->gaddr.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
> -               /* Silently fail, if cpuidle attribute group is not present */
> -               sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj,
> +               sysfs_add_file_to_group(&dev_root->kobj,
>                                         &dev_attr_low_power_idle_cpu_residency_us.attr,
>                                         "cpuidle");
>         }
> +exit:
> +       put_device(dev_root);
>  }
>
>  static void lpit_process(u64 begin, u64 end)
> --
> 2.40.0
>

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

* Re: [PATCH v2 03/19] cpuidle: move to use bus_get_dev_root()
  2023-03-22  9:05     ` [PATCH v2 03/19] " Greg Kroah-Hartman
@ 2023-03-22 14:27       ` Rafael J. Wysocki
  2023-03-24  8:56         ` Greg Kroah-Hartman
  0 siblings, 1 reply; 89+ messages in thread
From: Rafael J. Wysocki @ 2023-03-22 14:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Rafael J. Wysocki, Daniel Lezcano, linux-pm

On Wed, Mar 22, 2023 at 10:06 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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.
>
> This allows us to clean up the cpuidle_add_interface() call a bit as it
> was only called in one place, with the same argument so just put that
> into the function itself.  Note that cpuidle_remove_interface() should
> also probably be removed in the future as there are no callers of it for
> some reason.
>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

> ---
> v2: - reworked cpuidle_add_interface() to exit early if dev_root is not
>       valid based on review from Rafael.
>
>  drivers/cpuidle/cpuidle.c |  2 +-
>  drivers/cpuidle/cpuidle.h |  2 +-
>  drivers/cpuidle/sysfs.c   | 13 ++++++++++---
>  3 files changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 0b00f21cefe3..8e929f6602ce 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -808,7 +808,7 @@ static int __init cpuidle_init(void)
>         if (cpuidle_disabled())
>                 return -ENODEV;
>
> -       return cpuidle_add_interface(cpu_subsys.dev_root);
> +       return cpuidle_add_interface();
>  }
>
>  module_param(off, int, 0444);
> diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
> index 9f336af17fa6..52701d9588f1 100644
> --- a/drivers/cpuidle/cpuidle.h
> +++ b/drivers/cpuidle/cpuidle.h
> @@ -30,7 +30,7 @@ extern int cpuidle_switch_governor(struct cpuidle_governor *gov);
>
>  struct device;
>
> -extern int cpuidle_add_interface(struct device *dev);
> +extern int cpuidle_add_interface(void);
>  extern void cpuidle_remove_interface(struct device *dev);
>  extern int cpuidle_add_device_sysfs(struct cpuidle_device *device);
>  extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
> index 48948b171749..d6f5da61cb7d 100644
> --- a/drivers/cpuidle/sysfs.c
> +++ b/drivers/cpuidle/sysfs.c
> @@ -119,11 +119,18 @@ static struct attribute_group cpuidle_attr_group = {
>
>  /**
>   * cpuidle_add_interface - add CPU global sysfs attributes
> - * @dev: the target device
>   */
> -int cpuidle_add_interface(struct device *dev)
> +int cpuidle_add_interface(void)
>  {
> -       return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
> +       struct device *dev_root = bus_get_dev_root(&cpu_subsys);
> +       int retval;
> +
> +       if (!dev_root)
> +               return -EINVAL;
> +
> +       retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group);
> +       put_device(dev_root);
> +       return retval;
>  }
>
>  /**
> --
> 2.40.0
>

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

* Re: [PATCH v2 03/19] cpuidle: move to use bus_get_dev_root()
  2023-03-22 14:27       ` Rafael J. Wysocki
@ 2023-03-24  8:56         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-24  8:56 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-kernel, Daniel Lezcano, linux-pm

On Wed, Mar 22, 2023 at 03:27:45PM +0100, Rafael J. Wysocki wrote:
> On Wed, Mar 22, 2023 at 10:06 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> 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.
> >
> > This allows us to clean up the cpuidle_add_interface() call a bit as it
> > was only called in one place, with the same argument so just put that
> > into the function itself.  Note that cpuidle_remove_interface() should
> > also probably be removed in the future as there are no callers of it for
> > some reason.
> >
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Cc: linux-pm@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> Acked-by: Rafael J. Wysocki <rafael@kernel.org>

Great, thanks for the quick reviews!

greg k-h

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

* Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
  2023-03-16 23:57       ` Fenghua Yu
@ 2023-03-24  8:57         ` Greg Kroah-Hartman
  0 siblings, 0 replies; 89+ messages in thread
From: Greg Kroah-Hartman @ 2023-03-24  8:57 UTC (permalink / raw)
  To: Fenghua Yu; +Cc: linux-kernel, rafael, Dave Jiang, Vinod Koul, dmaengine

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 <fenghua.yu@intel.com>
> > > > Cc: Dave Jiang <dave.jiang@intel.com>
> > > > Cc: Vinod Koul <vkoul@kernel.org>
> > > > Cc: dmaengine@vger.kernel.org
> > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > ---
> > > > 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 <fenghua.yu@intel.com>

Great, thanks for this, I've now queued up the series in my tree.

greg k-h

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

end of thread, other threads:[~2023-03-24  8:58 UTC | newest]

Thread overview: 89+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 18:28 [PATCH 01/36] EDAC/sysfs: move to use bus_get_dev_root() Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 02/36] ACPI: LPIT: " Greg Kroah-Hartman
2023-03-13 18:43   ` Rafael J. Wysocki
2023-03-17 14:50     ` Greg Kroah-Hartman
2023-03-22  8:36     ` [PATCH v2 02/19] " Greg Kroah-Hartman
2023-03-22 14:15       ` Rafael J. Wysocki
2023-03-13 18:28 ` [PATCH 03/36] cpufreq: " Greg Kroah-Hartman
2023-03-13 18:45   ` Rafael J. Wysocki
2023-03-13 18:28 ` [PATCH 04/36] platform/x86: ibm_rtl: " Greg Kroah-Hartman
2023-03-15 12:46   ` Hans de Goede
2023-03-13 18:28 ` [PATCH 05/36] platform/x86: intel-uncore-freq: " Greg Kroah-Hartman
2023-03-13 19:14   ` srinivas pandruvada
2023-03-15 12:46   ` Hans de Goede
2023-03-13 18:28 ` [PATCH 06/36] cpuidle: " Greg Kroah-Hartman
2023-03-13 18:58   ` Rafael J. Wysocki
2023-03-22  9:04     ` Greg Kroah-Hartman
2023-03-22  9:05     ` [PATCH v2 03/19] " Greg Kroah-Hartman
2023-03-22 14:27       ` Rafael J. Wysocki
2023-03-24  8:56         ` Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 07/36] cpu/hotplug: " Greg Kroah-Hartman
2023-03-20 13:59   ` Thomas Gleixner
2023-03-13 18:28 ` [PATCH 08/36] workqueue: " Greg Kroah-Hartman
2023-03-14  3:31   ` Tejun Heo
2023-03-13 18:28 ` [PATCH 09/36] x86/microcode: " Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 10/36] x86/umwait: " Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 11/36] arm64: cpufeature: " Greg Kroah-Hartman
2023-03-13 18:28   ` Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 12/36] powerpc/sysfs: " Greg Kroah-Hartman
2023-03-13 18:28   ` Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 13/36] powerpc/powernv: " Greg Kroah-Hartman
2023-03-13 18:28   ` Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 14/36] powerpc/pseries: " Greg Kroah-Hartman
2023-03-13 18:28   ` Greg Kroah-Hartman
2023-03-15  2:00   ` Michael Ellerman
2023-03-15  2:00     ` Michael Ellerman
2023-03-13 18:28 ` [PATCH 15/36] powerpc/fsl: " Greg Kroah-Hartman
2023-03-13 18:28   ` Greg Kroah-Hartman
2023-03-13 18:28 ` [PATCH 16/36] sh: dma-sysfs: " Greg Kroah-Hartman
2023-03-13 18:38   ` John Paul Adrian Glaubitz
2023-03-13 18:48   ` John Paul Adrian Glaubitz
2023-03-13 18:28 ` [PATCH 17/36] sh: intc: " Greg Kroah-Hartman
2023-03-13 18:39   ` John Paul Adrian Glaubitz
2023-03-13 18:29 ` [PATCH 18/36] s390/topology: " Greg Kroah-Hartman
2023-03-14 11:34   ` Heiko Carstens
2023-03-13 18:29 ` [PATCH 19/36] s390/smp: " Greg Kroah-Hartman
2023-03-14 11:35   ` Heiko Carstens
2023-03-13 18:29 ` [PATCH 20/36] cpufreq: amd-pstate: " Greg Kroah-Hartman
2023-03-14  6:04   ` Huang Rui
2023-03-13 18:29 ` [PATCH 21/36] irqchip/mbigen: " Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 22/36] driver core: bus: move dev_root out of struct bus_type Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant Greg Kroah-Hartman
2023-03-13 19:14   ` Bjorn Helgaas
2023-03-13 22:41   ` Wei Liu
2023-03-13 23:01   ` Ira Weiny
2023-03-14  7:10   ` Harald Freudenberger
2023-03-14 17:43   ` Dan Williams
2023-03-15  2:33   ` Martin K. Petersen
2023-03-15 11:10   ` Ilya Dryomov
2023-03-15 11:51   ` Alex Shi
2023-03-15 15:05   ` Winiarska, Iwona
2023-03-13 18:29 ` [PATCH 24/36] driver core: bus: constantify bus_register() Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 25/36] driver core: bus: constify bus_rescan_devices() Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 26/36] driver core: bus: constify driver_find() Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 27/36] driver core: bus: constify bus_get() Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 28/36] driver core: make the bus_type in struct device_driver constant Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 29/36] crypto: hisilicon/qm - make struct bus_type * const Greg Kroah-Hartman
2023-03-14  8:22   ` Herbert Xu
2023-03-13 18:29 ` [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers Greg Kroah-Hartman
2023-03-13 18:29   ` Greg Kroah-Hartman
2023-03-13 18:29   ` [Intel-gfx] " Greg Kroah-Hartman
2023-03-15 10:15   ` Tvrtko Ursulin
2023-03-15 10:15     ` Tvrtko Ursulin
2023-03-15 10:15     ` [Intel-gfx] " Tvrtko Ursulin
2023-03-13 18:29 ` [PATCH 31/36] vhost-vdpa: vhost_vdpa_alloc_domain() should be using a const struct bus_type * Greg Kroah-Hartman
2023-03-13 18:29   ` Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 32/36] dmaengine: idxd: use " Greg Kroah-Hartman
2023-03-13 19:07   ` Fenghua Yu
2023-03-16 10:16     ` Greg Kroah-Hartman
2023-03-16 23:57       ` Fenghua Yu
2023-03-24  8:57         ` Greg Kroah-Hartman
2023-03-17 17:19   ` Vinod Koul
2023-03-17 17:33   ` Dave Jiang
2023-03-13 18:29 ` [PATCH 33/36] ARM/dma-mapping: const a pointer to bus_type in arm_iommu_create_mapping() Greg Kroah-Hartman
2023-03-13 18:29   ` Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 34/36] iommu: make the pointer to struct bus_type constant Greg Kroah-Hartman
2023-03-22 12:13   ` Joerg Roedel
2023-03-13 18:29 ` [PATCH 35/36] driver core: device.h: make struct bus_type a const * Greg Kroah-Hartman
2023-03-13 18:29 ` [PATCH 36/36] USB: mark all struct bus_type as const Greg Kroah-Hartman
2023-03-14  8:48   ` Heikki Krogerus

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