EDAC/sysfs: move to use bus_get_dev_root()
Subsystems (51)
Greg Kroah-Hartman
maintainerPATCH 1/36 EDAC/sysfs: move to use bus_get_dev_root()
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.
---
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(-)
drivers/edac/edac_device_sysfs.c +9 -7
@@ -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);
drivers/edac/edac_pci_sysfs.c +9 -5
@@ -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;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 2/36 ACPI: LPIT: move to use bus_get_dev_root()
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.
---
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(-)
drivers/acpi/acpi_lpit.c +11 -6
@@ -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)
Signature · 1 line
2.39.2
Rafael J. Wysocki
maintainerRe: [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
Quoted 24 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/acpi/acpi_lpit.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)drivers/acpi/acpi_lpit.c +0
-0
drivers/acpi/acpi_lpit.c EXPORT_SYMBOL_GPL(lpit_read_residency_count_address); · line 102
Quoted 5 lines
drivers/acpi/acpi_lpit.c +2
-0@@ -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.
Quoted 31 lines
drivers/acpi/acpi_lpit.c +9
-7info->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
Greg Kroah-Hartman
maintainerRe: [PATCH 02/36] ACPI: LPIT: move to use bus_get_dev_root()
Quoted 21 lines · Rafael J. Wysocki
Quoted 19 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/acpi/acpi_lpit.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Quoted 13 lines
drivers/acpi/acpi_lpit.c EXPORT_SYMBOL_GPL(lpit_read_residency_count_address); · line 102
Quoted 10 lines
drivers/acpi/acpi_lpit.c +2
-0@@ -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_rootis 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
Greg Kroah-Hartman
maintainerPATCH v2 2/19 ACPI: LPIT: move to use bus_get_dev_root()
In reply to Rafael J. WysockiDirect 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.
---
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(-)
drivers/acpi/acpi_lpit.c +11 -5
@@ -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)
Signature · 1 line
2.40.0
Re: [PATCH v2 02/19] ACPI: LPIT: move to use bus_get_dev_root()
Quoted 9 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc "Rafael J. Wysocki" <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 53 lines
---
v2: - change logic to test fordev_rootat the beginning of the function
and error out then based on review comments from Rafael.
- fix error handling forioremap()call to properly drop the reference ondev_rootif it failed.drivers/acpi/acpi_lpit.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)drivers/acpi/acpi_lpit.c +11
-6@@ -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
Greg Kroah-Hartman
maintainerPATCH 3/36 cpufreq: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
drivers/cpufreq/cpufreq.c +6 -1
@@ -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))
drivers/cpufreq/intel_pstate.c +5 -2
@@ -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 ;
Signature · 1 line
2.39.2
Re: [PATCH 03/36] cpufreq: move to use bus_get_dev_root()
Quoted 11 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Cc Srinivas Pandruvada <[email protected]>Cc Len Brown <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 56 lines
---
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(-)drivers/cpufreq/cpufreq.c +6
-1@@ -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))drivers/cpufreq/intel_pstate.c +5
-3@@ -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
Greg Kroah-Hartman
maintainerPATCH 4/36 platform/x86: ibm_rtl: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
drivers/platform/x86/ibm_rtl.c +14 -4
@@ -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); }
Signature · 1 line
2.39.2
Re: [PATCH 04/36] platform/x86: ibm_rtl: move to use bus_get_dev_root()
Hi,
Quoted 8 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Hans de Goede <[email protected]>Cc Mark Gross <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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:
Regards,
Hans
Quoted 38 lines
drivers/platform/x86/ibm_rtl.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/platform/x86/ibm_rtl.c +14
-4@@ -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); }
Greg Kroah-Hartman
maintainerPATCH 5/36 platform/x86: intel-uncore-freq: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +9 -3
@@ -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);
Signature · 1 line
2.39.2
Re: [PATCH 05/36] platform/x86: intel-uncore-freq: move to use bus_get_dev_root()
Quoted 11 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon
so replace that with a call tobus_get_dev_root()instead, which is what
it is there for.Cc Srinivas Pandruvada <[email protected]>Cc Hans de Goede <[email protected]>Cc Mark Gross <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 47 lines
---
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(-)(quoted diff) +0
-0
frequency-common.cb/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
indexcb24de9e97dc..1a300e14f350100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c(quoted diff) +0
-0@@ -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);
Re: [PATCH 05/36] platform/x86: intel-uncore-freq: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanHi,
Quoted 9 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Srinivas Pandruvada <[email protected]>Cc Hans de Goede <[email protected]>Cc Mark Gross <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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:
Regards,
Hans
Quoted 23 lines
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +9
-3@@ -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);
Greg Kroah-Hartman
maintainerPATCH 6/36 cpuidle: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
drivers/cpuidle/cpuidle.c +1 -1
@@ -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 );
drivers/cpuidle/cpuidle.h +1 -1
@@ -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);
drivers/cpuidle/sysfs.c +9 -3
@@ -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; }/**
Signature · 1 line
2.39.2
Rafael J. Wysocki
maintainerRe: [PATCH 06/36] cpuidle: move to use bus_get_dev_root()
Quoted 65 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_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 thatcpuidle_remove_interface()should also probably be removed in the future as there are no callers of it for some reason.Cc "Rafael J. Wysocki" <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/cpuidle.h | 2 +- drivers/cpuidle/sysfs.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-)drivers/cpuidle/cpuidle.c +1
-1@@ -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 );drivers/cpuidle/cpuidle.h +1
-1@@ -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);drivers/cpuidle/sysfs.c +1
-2@@ -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 )
drivers/cpuidle/sysfs.c static struct attribute_group cpuidle_attr_group = { · line 132
Quoted 10 lines
drivers/cpuidle/sysfs.c +8
-1{ -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.
Greg Kroah-Hartman
maintainerRe: [PATCH 06/36] cpuidle: move to use bus_get_dev_root()
Quoted 81 lines · Rafael J. Wysocki
Quoted 65 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_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 thatcpuidle_remove_interface()should also probably be removed in the future as there are no callers of it for some reason.Cc "Rafael J. Wysocki" <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/cpuidle/cpuidle.c | 2 +- drivers/cpuidle/cpuidle.h | 2 +- drivers/cpuidle/sysfs.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-)drivers/cpuidle/cpuidle.c +1
-1@@ -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 );drivers/cpuidle/cpuidle.h +1
-1@@ -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);drivers/cpuidle/sysfs.c +1
-2@@ -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 )drivers/cpuidle/sysfs.c static struct attribute_group cpuidle_attr_group = { · line 132
Quoted 10 lines
drivers/cpuidle/sysfs.c +8
-1{ -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)
Quoted 8 lines
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
Greg Kroah-Hartman
maintainerPATCH v2 3/19 cpuidle: move to use bus_get_dev_root()
In reply to Rafael J. WysockiDirect 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.
---
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(-)
drivers/cpuidle/cpuidle.c +1 -1
@@ -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 );
drivers/cpuidle/cpuidle.h +1 -1
@@ -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);
drivers/cpuidle/sysfs.c +10 -3
@@ -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; }/**
Signature · 1 line
2.40.0
Re: [PATCH v2 03/19] cpuidle: move to use bus_get_dev_root()
Quoted 11 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_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 thatcpuidle_remove_interface()should also probably be removed in the future as there are no callers of it for some reason.
Quoted 4 lines
Cc "Rafael J. Wysocki" <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 64 lines
---
v2: - reworkedcpuidle_add_interface()to exit early ifdev_rootis 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(-)drivers/cpuidle/cpuidle.c +1
-1@@ -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 );drivers/cpuidle/cpuidle.h +1
-1@@ -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);drivers/cpuidle/sysfs.c +10
-4@@ -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
Greg Kroah-Hartman
maintainerRe: [PATCH v2 03/19] cpuidle: move to use bus_get_dev_root()
Quoted 13 lines · Rafael J. Wysocki
Quoted 11 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_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 thatcpuidle_remove_interface()should also probably be removed in the future as there are no callers of it for some reason.
Quoted 6 lines
Quoted 4 lines
Cc "Rafael J. Wysocki" <[email protected]>Cc Daniel Lezcano <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Great, thanks for the quick reviews!
greg k-h
Greg Kroah-Hartman
maintainerPATCH 7/36 cpu/hotplug: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
kernel/cpu.c +17 -6
@@ -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);
Signature · 1 line
2.39.2
Re: [PATCH 07/36] cpu/hotplug: move to use bus_get_dev_root()
Quoted 4 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.
Quoted 10 lines
Cc Thomas Gleixner <[email protected]>Cc Valentin Schneider <[email protected]>Cc Phil Auld <[email protected]>Cc Steven Price <[email protected]>Cc Juri Lelli <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Vincent Donnefort <[email protected]>Cc Kuppuswamy Sathyanarayanan <[email protected]>Cc "Jason A. Donenfeld" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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.
Greg Kroah-Hartman
maintainerPATCH 8/36 workqueue: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
kernel/workqueue.c +7 -1
@@ -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);
Signature · 1 line
2.39.2
Re: [PATCH 08/36] workqueue: move to use bus_get_dev_root()
Quoted 7 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Tejun Heo <[email protected]>Cc Lai Jiangshan <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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.
Signature · 1 line
tejun
Greg Kroah-Hartman
maintainerPATCH 9/36 x86/microcode: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/x86/kernel/cpu/microcode/core.c +9 -4
@@ -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 */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 10/36 x86/umwait: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/x86/kernel/cpu/umwait.c +6 -2
@@ -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);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 11/36 arm64: cpufeature: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/arm64/kernel/cpufeature.c +9 -1
@@ -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);
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 12/36 powerpc/sysfs: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/powerpc/kernel/sysfs.c +12 -2
@@ -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 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 13/36 powerpc/powernv: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/powerpc/platforms/powernv/idle.c +7 -2
@@ -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 ();
arch/powerpc/platforms/powernv/subcore.c +8 -2
@@ -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);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 14/36 powerpc/pseries: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/powerpc/platforms/pseries/pseries_energy.c +17 -11
@@ -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);
arch/powerpc/platforms/pseries/suspend.c +8 -2
@@ -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 ;
Signature · 1 line
2.39.2
Re: [PATCH 14/36] powerpc/pseries: move to use bus_get_dev_root()
Quoted 17 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Michael Ellerman <[email protected]>Cc Nicholas Piggin <[email protected]>Cc Christophe Leroy <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.
Quoted 3 lines
.../platforms/pseries/pseries_energy.c | 28 +++++++++++-------- arch/powerpc/platforms/pseries/suspend.c | 10 +++++-- 2 files changed, 25 insertions(+), 13 deletions(-)
The other powerpc changes look OK too.
cheers
Greg Kroah-Hartman
maintainerPATCH 15/36 powerpc/fsl: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c +15 -4
@@ -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);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 16/36 sh: dma-sysfs: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/sh/drivers/dma/dma-sysfs.c +7 -1
@@ -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);
Signature · 1 line
2.39.2
Re: [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
Quoted 33 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Yoshinori Sato <[email protected]>Cc Rich Felker <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.arch/sh/drivers/dma/dma-sysfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)arch/sh/drivers/dma/dma-sysfs.c +1
-0@@ -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;
arch/sh/drivers/dma/dma-sysfs.c static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL); · line 63
Quoted 10 lines
arch/sh/drivers/dma/dma-sysfs.c +6
-1-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);
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
John Paul Adrian Glaubitz
maintainerRe: [PATCH 16/36] sh: dma-sysfs: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanHi Greg!
Quoted 33 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Yoshinori Sato <[email protected]>Cc Rich Felker <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.arch/sh/drivers/dma/dma-sysfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)arch/sh/drivers/dma/dma-sysfs.c +1
-0@@ -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;
arch/sh/drivers/dma/dma-sysfs.c static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL); · line 63
Quoted 10 lines
arch/sh/drivers/dma/dma-sysfs.c +6
-1-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
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Greg Kroah-Hartman
maintainerPATCH 17/36 sh: intc: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
drivers/sh/intc/userimask.c +9 -1
@@ -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);
Signature · 1 line
2.39.2
Re: [PATCH 17/36] sh: intc: move to use bus_get_dev_root()
Quoted 32 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Yoshinori Sato <[email protected]>Cc Rich Felker <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/sh/intc/userimask.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/sh/intc/userimask.c +3
-0@@ -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 ;
drivers/sh/intc/userimask.c static DEVICE_ATTR(userimask, S_IRUSR | S_IWUSR, · line 78
Quoted 10 lines
drivers/sh/intc/userimask.c +6
-1-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);
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Greg Kroah-Hartman
maintainerPATCH 18/36 s390/topology: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/s390/kernel/topology.c +10 -1
@@ -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);
Signature · 1 line
2.39.2
Re: [PATCH 18/36] s390/topology: move to use bus_get_dev_root()
Quoted 18 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Sven Schnelle <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.
Quoted 2 lines
arch/s390/kernel/topology.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Greg Kroah-Hartman
maintainerPATCH 19/36 s390/smp: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
arch/s390/kernel/smp.c +9 -3
@@ -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)
Signature · 1 line
2.39.2
Re: [PATCH 19/36] s390/smp: move to use bus_get_dev_root()
Quoted 19 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_get_dev_root()instead, which is what it is there for.Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Sven Schnelle <[email protected]>Cc Ilya Leoshkevich <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.
Quoted 2 lines
arch/s390/kernel/smp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 20/36 cpufreq: amd-pstate: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.)
---
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(-)
drivers/cpufreq/amd-pstate.c +10 -14
@@ -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; }
Signature · 1 line
2.39.2
Re: [PATCH 20/36] cpufreq: amd-pstate: move to use bus_get_dev_root()
Quoted 15 lines · Greg Kroah-Hartman
Direct access to the struct
bus_typedev_rootpointer is going away soon so replace that with a call tobus_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 <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Viresh Kumar <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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.
Quoted 68 lines
drivers/cpufreq/amd-pstate.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)drivers/cpufreq/amd-pstate.c +10
-14@@ -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; }Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 21/36 irqchip/mbigen: move to use bus_get_dev_root()
In reply to Greg Kroah-HartmanDirect 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.
---
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(-)
drivers/irqchip/irq-mbigen.c +8 -5
@@ -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",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 22/36 driver core: bus: move dev_root out of struct bus_type
In reply to Greg Kroah-HartmanNow 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.
--- drivers/base/base.h | 2 ++ drivers/base/bus.c | 28 ++++++++++++++++++++++------ include/linux/device/bus.h | 2 -- 3 files changed, 24 insertions(+), 8 deletions(-)
drivers/base/base.h +2 -0
@@ -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;
drivers/base/bus.c +22 -6
@@ -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);
include/linux/device/bus.h +0 -2
@@ -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;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 23/36 driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-Hartmanstruct 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.
---
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(-)
Documentation/driver-api/driver-model/bus.rst +2 -2
@@ -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
Documentation/filesystems/sysfs.rst +2 -2
@@ -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::
Documentation/translations/zh_CN/filesystems/sysfs.txt +2 -2
@@ -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); }; 声明:
Documentation/translations/zh_TW/filesystems/sysfs.txt +2 -2
@@ -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); }; 聲明:
arch/powerpc/platforms/pseries/ibmebus.c +2 -2
@@ -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;
arch/powerpc/platforms/pseries/vio.c +4 -4
@@ -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;
drivers/ata/pata_parport/pata_parport.c +2 -4
@@ -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;
drivers/base/bus.c +4 -4
@@ -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);
drivers/block/rbd.c +15 -19
@@ -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); }/*
drivers/bus/fsl-mc/fsl-mc-bus.c +3 -3
@@ -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);
drivers/cxl/core/port.c +1 -1
@@ -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);
drivers/hv/vmbus_drv.c +1 -1
@@ -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 ()); }
drivers/net/netdevsim/bus.c +2 -2
@@ -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;
drivers/pci/pci-sysfs.c +1 -1
@@ -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 ;
drivers/pci/pci.c +2 -2
@@ -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;
drivers/peci/sysfs.c +1 -1
@@ -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;
drivers/rapidio/rio-sysfs.c +1 -1
@@ -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;
drivers/s390/crypto/ap_bus.c +21 -21
159 lines not on this page · raw message
drivers/scsi/fcoe/fcoe_sysfs.c +4 -4
@@ -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);
drivers/scsi/fcoe/fcoe_transport.c +2 -4
@@ -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 ;
include/linux/device/bus.h +2 -2
@@ -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) \
include/scsi/libfcoe.h +2 -4
@@ -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 */
Signature · 1 line
2.39.2
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
Quoted 31 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.Cc "David S. Miller" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Alex Shi <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Alexandre Bounine <[email protected]>Cc Alison Schofield <[email protected]>Cc Ben Widawsky <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Dan Williams <[email protected]>Cc Dexuan Cui <[email protected]>Cc Eric Dumazet <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Harald Freudenberger <[email protected]>Cc Heiko Carstens <[email protected]>Cc Hu Haowen <[email protected]>Cc Ilya Dryomov <[email protected]>Cc Ira Weiny <[email protected]>Cc Iwona Winiarska <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jens Axboe <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Matt Porter <[email protected]>
Quoted 8 lines
Cc Michael Ellerman <[email protected]>Cc Paolo Abeni <[email protected]>Cc Stuart Yoder <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Vishal Verma <[email protected]>Cc Wei Liu <[email protected]>Cc Yanteng Si <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 35 lines
drivers/pci/pci-sysfs.c +1
-1@@ -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 ;drivers/pci/pci.c +2
-2@@ -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;
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 4 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.
[...]
drivers/hv/vmbus_drv.c static const struct attribute_group vmbus_dev_group = { · line 690
Quoted 13 lines
drivers/hv/vmbus_drv.c +1
-1@@ -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 ()); }
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 31 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.Cc "David S. Miller" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Alex Shi <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Alexandre Bounine <[email protected]>Cc Alison Schofield <[email protected]>Cc Ben Widawsky <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Dan Williams <[email protected]>Cc Dexuan Cui <[email protected]>Cc Eric Dumazet <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Harald Freudenberger <[email protected]>Cc Heiko Carstens <[email protected]>Cc Hu Haowen <[email protected]>Cc Ilya Dryomov <[email protected]>Cc Ira Weiny <[email protected]>Cc Iwona Winiarska <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jens Axboe <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Matt Porter <[email protected]>
Quoted 8 lines
Cc Michael Ellerman <[email protected]>Cc Paolo Abeni <[email protected]>Cc Stuart Yoder <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Vishal Verma <[email protected]>Cc Wei Liu <[email protected]>Cc Yanteng Si <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 31 lines
---
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(-)
[...]
Quoted 13 lines
drivers/cxl/core/port.c +1
-1@@ -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);
Harald Freudenberger
maintainerRe: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 864 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.Cc "David S. Miller" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Alex Shi <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Alexandre Bounine <[email protected]>Cc Alison Schofield <[email protected]>Cc Ben Widawsky <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Dan Williams <[email protected]>Cc Dexuan Cui <[email protected]>Cc Eric Dumazet <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Harald Freudenberger <[email protected]>Cc Heiko Carstens <[email protected]>Cc Hu Haowen <[email protected]>Cc Ilya Dryomov <[email protected]>Cc Ira Weiny <[email protected]>Cc Iwona Winiarska <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jens Axboe <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Matt Porter <[email protected]>Cc Michael Ellerman <[email protected]>Cc Paolo Abeni <[email protected]>Cc Stuart Yoder <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Vishal Verma <[email protected]>Cc Wei Liu <[email protected]>Cc Yanteng Si <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.Documentation/driver-api/driver-model/bus.rst | 4 +- Documentation/filesystems/sysfs.rst | 4 +- .../translations/zh_CN/filesystems/sysfs.txt | 4 +- .../translations/zh_TW/filesystems/sysfs.txt | 4 +- arch/powerpc/platforms/pseries/ibmebus.c | 4 +- arch/powerpc/platforms/pseries/vio.c | 8 ++-- drivers/ata/pata_parport/pata_parport.c | 6 +-- drivers/base/bus.c | 8 ++-- drivers/block/rbd.c | 34 +++++++-------- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +-- drivers/cxl/core/port.c | 2 +- drivers/hv/vmbus_drv.c | 2 +- drivers/net/netdevsim/bus.c | 4 +- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/pci.c | 4 +- drivers/peci/sysfs.c | 2 +- drivers/rapidio/rio-sysfs.c | 2 +- drivers/s390/crypto/ap_bus.c | 42 +++++++++---------- drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++-- drivers/scsi/fcoe/fcoe_transport.c | 6 +-- include/linux/device/bus.h | 4 +- include/scsi/libfcoe.h | 6 +-- 22 files changed, 78 insertions(+), 88 deletions(-)Documentation/driver-api/driver-model/bus.rst +2
-2@@ -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_RWmacro that
worksDocumentation/filesystems/sysfs.rst +2
-2@@ -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::
Documentation/translations/zh_CN/filesystems/sysfs.txt +0
-0@@ -329,8 +329,8 @@ void device_remove_file(struct device *dev, conststruct
device_attribute* attrstruct bus_attribute { struct attribute attr;Documentation/translations/zh_CN/filesystems/sysfs.txt +0
-2- ssize_t (*show)(struct bus_type *, char * buf); - ssize_t (*store)(struct bus_type *, const char * buf, size_tcount);
Documentation/translations/zh_CN/filesystems/sysfs.txt +2
-0+ ssize_t (*show)(const struct bus_type *, char * buf); + ssize_t (*store)(const struct bus_type *, const char * buf,
size_tcount);
};声明:
Documentation/translations/zh_TW/filesystems/sysfs.txt +0
-0@@ -332,8 +332,8 @@ void device_remove_file(struct device *dev, conststruct
device_attribute* attrstruct bus_attribute { struct attribute attr;Documentation/translations/zh_TW/filesystems/sysfs.txt +0
-2- ssize_t (*show)(struct bus_type *, char * buf); - ssize_t (*store)(struct bus_type *, const char * buf, size_tcount);
Documentation/translations/zh_TW/filesystems/sysfs.txt +2
-0+ ssize_t (*show)(const struct bus_type *, char * buf); + ssize_t (*store)(const struct bus_type *, const char * buf,
size_tcount);
};聲明:
arch/powerpc/platforms/pseries/ibmebus.c +1
-1@@ -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){
arch/powerpc/platforms/pseries/ibmebus.c +1
-1struct 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){
arch/powerpc/platforms/pseries/ibmebus.c +0
-0struct device *dev;char *path;arch/powerpc/platforms/pseries/vio.c +1
-1@@ -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) \{
\arch/powerpc/platforms/pseries/vio.c +3
-3return 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) {arch/powerpc/platforms/pseries/vio.c +0
-0unsigned long flags;drivers/ata/pata_parport/pata_parport.c +1
-2@@ -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) {drivers/ata/pata_parport/pata_parport.c +1
-2char 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, constchar *buf,size_t count) {drivers/ata/pata_parport/pata_parport.c +0
-0struct device *dev;drivers/base/bus.c +1
-1@@ -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) {drivers/base/bus.c +1
-1struct 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) {drivers/base/bus.c +1
-1struct subsys_private *sp =bus_to_subsys (bus);@@ -304,7 +304,7 @@ static ssize_t drivers_autoprobe_store(structbus_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) {drivers/base/bus.c +1
-1struct 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);drivers/block/rbd.c +3
-3@@ -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,
drivers/block/rbd.c +0
-1size_t count); -static ssize_t remove_single_major_store(struct bus_type *bus, constchar *buf,
+staticssize_tremove_single_major_store(const structbus_type*bus, const char *buf,drivers/block/rbd.c +1
-1size_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){
drivers/block/rbd.c +1
-3return 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 ;drivers/block/rbd.c +5
-7struct 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 ;drivers/block/rbd.c +3
-3struct 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){
drivers/block/rbd.c +1
-1-return do_rbd_remove (bus, buf, count); +return do_rbd_remove (buf, count); }/* drivers/bus/fsl-mc/fsl-mc-bus.c +1
-1@@ -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) {drivers/bus/fsl-mc/fsl-mc-bus.c +1
-1unsigned 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) {drivers/bus/fsl-mc/fsl-mc-bus.c +1
-1bus_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);drivers/bus/fsl-mc/fsl-mc-bus.c +0
-0return strlen (buf);drivers/cxl/core/port.c +1
-1@@ -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){
drivers/cxl/core/port.c +0
-0if (sysfs_streq (buf,"1" )) {flush_workqueue (cxl_bus_wq);drivers/hv/vmbus_drv.c +1
-1@@ -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 ());}
drivers/net/netdevsim/bus.c +1
-1@@ -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) {drivers/net/netdevsim/bus.c +1
-1unsigned 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;drivers/net/netdevsim/bus.c +0
-0unsigned int id;drivers/pci/pci-sysfs.c +1
-1@@ -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){
drivers/pci/pci-sysfs.c +0
-0unsigned long val;struct pci_bus *b =NULL ;drivers/pci/pci.c +1
-1@@ -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){
drivers/pci/pci.c +1
-1size_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) {drivers/pci/pci.c +0
-0char *param, *old, *end;drivers/peci/sysfs.c +1
-1@@ -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){
drivers/peci/sysfs.c +0
-0bool res;int ret;drivers/rapidio/rio-sysfs.c +1
-1@@ -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) {drivers/rapidio/rio-sysfs.c +0
-0long val;int rc;drivers/s390/crypto/ap_bus.c +3
-3@@ -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){
drivers/s390/crypto/ap_bus.c +1
-1if (!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){
drivers/s390/crypto/ap_bus.c +1
-1if (!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) {drivers/s390/crypto/ap_bus.c +1
-1if (!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) {drivers/s390/crypto/ap_bus.c +2
-2return 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) {drivers/s390/crypto/ap_bus.c +2
-2int time;@@ -1265,12 +1265,12 @@ static ssize_t config_time_store(structbus_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) {drivers/s390/crypto/ap_bus.c +2
-2int flag, rc;@@ -1289,12 +1289,12 @@ static ssize_t poll_thread_store(structbus_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, constchar *buf,
drivers/s390/crypto/ap_bus.c +3
-3size_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){
drivers/s390/crypto/ap_bus.c +1
-1int 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) {drivers/s390/crypto/ap_bus.c +2
-2int 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) {drivers/s390/crypto/ap_bus.c +2
-2int 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){
drivers/s390/crypto/ap_bus.c +1
-1AP_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;drivers/s390/crypto/ap_bus.c +0
-0unsigned int apqns, n;drivers/scsi/fcoe/fcoe_sysfs.c +3
-3@@ -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, constchar *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, constchar *buf,size_t count){
drivers/scsi/fcoe/fcoe_sysfs.c +1
-1-return fcoe_ctlr_destroy_store (bus, buf, count); +return fcoe_ctlr_destroy_store (buf, count); }static BUS_ATTR_WO (ctlr_destroy);drivers/scsi/fcoe/fcoe_transport.c +1
-2@@ -745,8 +745,7 @@ static int libfcoe_device_notification(structnotifier_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 ;drivers/scsi/fcoe/fcoe_transport.c +1
-2struct 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 ;drivers/scsi/fcoe/fcoe_transport.c +0
-0struct net_device *netdev =NULL ;include/linux/device/bus.h +2
-2@@ -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)\include/scsi/libfcoe.h +0
-0@@ -397,10 +397,8 @@ int fcoe_transport_attach(struct fcoe_transport *ft);int fcoe_transport_detach (struct fcoe_transport *ft);
include/scsi/libfcoe.h int fcoe_transport_attach(struct fcoe_transport · line 404
Quoted 10 lines
include/scsi/libfcoe.h +2
-4/* sysfs store handler for ctrl_control interface */ -ssize_t fcoe_ctlr_create_store (struct bus_type *bus, -const char *buf,size_t count); -ssize_t fcoe_ctlr_destroy_store (struct bus_type *bus, -const char *buf,size_t count); +ssize_t fcoe_ctlr_create_store (const char *buf,size_t count); +ssize_t fcoe_ctlr_destroy_store (const char *buf,size_t count);#endif /* _LIBFCOE_H */
For the ap_bus.c part: Reviewed-by: Harald Freudenberger <[email protected]>
RE: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 5 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.
[..]
Quoted 1 line
Cc Dan Williams <[email protected]>
[..]
drivers/cxl/core/port.c bool schedule_cxl_memdev_detach(struct cxl_memdev *cxlmd) · line 1933
Quoted 13 lines
drivers/cxl/core/port.c +1
-1@@ -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:
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanGreg,
Quoted 4 lines
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 752 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.Cc "David S. Miller" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Alex Shi <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Alexandre Bounine <[email protected]>Cc Alison Schofield <[email protected]>Cc Ben Widawsky <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Dan Williams <[email protected]>Cc Dexuan Cui <[email protected]>Cc Eric Dumazet <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Harald Freudenberger <[email protected]>Cc Heiko Carstens <[email protected]>Cc Hu Haowen <[email protected]>Cc Ilya Dryomov <[email protected]>Cc Ira Weiny <[email protected]>Cc Iwona Winiarska <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jens Axboe <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Matt Porter <[email protected]>Cc Michael Ellerman <[email protected]>Cc Paolo Abeni <[email protected]>Cc Stuart Yoder <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Vishal Verma <[email protected]>Cc Wei Liu <[email protected]>Cc Yanteng Si <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.Documentation/driver-api/driver-model/bus.rst | 4 +- Documentation/filesystems/sysfs.rst | 4 +- .../translations/zh_CN/filesystems/sysfs.txt | 4 +- .../translations/zh_TW/filesystems/sysfs.txt | 4 +- arch/powerpc/platforms/pseries/ibmebus.c | 4 +- arch/powerpc/platforms/pseries/vio.c | 8 ++-- drivers/ata/pata_parport/pata_parport.c | 6 +-- drivers/base/bus.c | 8 ++-- drivers/block/rbd.c | 34 +++++++-------- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +-- drivers/cxl/core/port.c | 2 +- drivers/hv/vmbus_drv.c | 2 +- drivers/net/netdevsim/bus.c | 4 +- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/pci.c | 4 +- drivers/peci/sysfs.c | 2 +- drivers/rapidio/rio-sysfs.c | 2 +- drivers/s390/crypto/ap_bus.c | 42 +++++++++---------- drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++-- drivers/scsi/fcoe/fcoe_transport.c | 6 +-- include/linux/device/bus.h | 4 +- include/scsi/libfcoe.h | 6 +-- 22 files changed, 78 insertions(+), 88 deletions(-)Documentation/driver-api/driver-model/bus.rst +2
-2@@ -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 worksDocumentation/filesystems/sysfs.rst +2
-2@@ -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::Documentation/translations/zh_CN/filesystems/sysfs.txt +2
-2@@ -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); }; 声明:Documentation/translations/zh_TW/filesystems/sysfs.txt +2
-2@@ -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); }; 聲明:arch/powerpc/platforms/pseries/ibmebus.c +2
-2@@ -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;arch/powerpc/platforms/pseries/vio.c +4
-4@@ -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;drivers/ata/pata_parport/pata_parport.c +2
-4@@ -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;drivers/base/bus.c +4
-4@@ -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);drivers/block/rbd.c +15
-19@@ -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); }/* drivers/bus/fsl-mc/fsl-mc-bus.c +3
-3@@ -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);drivers/cxl/core/port.c +1
-1@@ -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);drivers/hv/vmbus_drv.c +1
-1@@ -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 ()); }drivers/net/netdevsim/bus.c +2
-2@@ -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;drivers/pci/pci-sysfs.c +1
-1@@ -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 ;drivers/pci/pci.c +2
-2@@ -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;drivers/peci/sysfs.c +1
-1@@ -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;drivers/rapidio/rio-sysfs.c +1
-1@@ -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;drivers/s390/crypto/ap_bus.c +21
-21@@ -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;drivers/scsi/fcoe/fcoe_sysfs.c +4
-4@@ -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);drivers/scsi/fcoe/fcoe_transport.c +2
-4@@ -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 ;include/linux/device/bus.h +2
-2@@ -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) \include/scsi/libfcoe.h +2
-5@@ -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 */ --
Quoted 2 lines
2.39.2
Thanks,
Ilya
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 6 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.
LGTM.
Quoted 748 lines
Cc "David S. Miller" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Alex Shi <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Alexandre Bounine <[email protected]>Cc Alison Schofield <[email protected]>Cc Ben Widawsky <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Dan Williams <[email protected]>Cc Dexuan Cui <[email protected]>Cc Eric Dumazet <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Harald Freudenberger <[email protected]>Cc Heiko Carstens <[email protected]>Cc Hu Haowen <[email protected]>Cc Ilya Dryomov <[email protected]>Cc Ira Weiny <[email protected]>Cc Iwona Winiarska <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jens Axboe <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Matt Porter <[email protected]>Cc Michael Ellerman <[email protected]>Cc Paolo Abeni <[email protected]>Cc Stuart Yoder <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Vishal Verma <[email protected]>Cc Wei Liu <[email protected]>Cc Yanteng Si <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.Documentation/driver-api/driver-model/bus.rst | 4 +- Documentation/filesystems/sysfs.rst | 4 +- .../translations/zh_CN/filesystems/sysfs.txt | 4 +- .../translations/zh_TW/filesystems/sysfs.txt | 4 +- arch/powerpc/platforms/pseries/ibmebus.c | 4 +- arch/powerpc/platforms/pseries/vio.c | 8 ++-- drivers/ata/pata_parport/pata_parport.c | 6 +-- drivers/base/bus.c | 8 ++-- drivers/block/rbd.c | 34 +++++++-------- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +-- drivers/cxl/core/port.c | 2 +- drivers/hv/vmbus_drv.c | 2 +- drivers/net/netdevsim/bus.c | 4 +- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/pci.c | 4 +- drivers/peci/sysfs.c | 2 +- drivers/rapidio/rio-sysfs.c | 2 +- drivers/s390/crypto/ap_bus.c | 42 +++++++++---------- drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++-- drivers/scsi/fcoe/fcoe_transport.c | 6 +-- include/linux/device/bus.h | 4 +- include/scsi/libfcoe.h | 6 +-- 22 files changed, 78 insertions(+), 88 deletions(-)Documentation/driver-api/driver-model/bus.rst +2
-2@@ -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 worksDocumentation/filesystems/sysfs.rst +2
-2@@ -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::Documentation/translations/zh_CN/filesystems/sysfs.txt +2
-2@@ -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); }; 声明:Documentation/translations/zh_TW/filesystems/sysfs.txt +2
-2@@ -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); }; 聲明:arch/powerpc/platforms/pseries/ibmebus.c +2
-2@@ -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;arch/powerpc/platforms/pseries/vio.c +4
-4@@ -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;drivers/ata/pata_parport/pata_parport.c +2
-4@@ -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;drivers/base/bus.c +4
-4@@ -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);drivers/block/rbd.c +15
-19@@ -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); }/* drivers/bus/fsl-mc/fsl-mc-bus.c +3
-3@@ -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);drivers/cxl/core/port.c +1
-1@@ -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);drivers/hv/vmbus_drv.c +1
-1@@ -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 ()); }drivers/net/netdevsim/bus.c +2
-2@@ -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;drivers/pci/pci-sysfs.c +1
-1@@ -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 ;drivers/pci/pci.c +2
-2@@ -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;drivers/peci/sysfs.c +1
-1@@ -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;drivers/rapidio/rio-sysfs.c +1
-1@@ -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;drivers/s390/crypto/ap_bus.c +21
-21@@ -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;drivers/scsi/fcoe/fcoe_sysfs.c +4
-4@@ -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);drivers/scsi/fcoe/fcoe_transport.c +2
-4@@ -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 ;include/linux/device/bus.h +2
-2@@ -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) \include/scsi/libfcoe.h +2
-5@@ -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
Re: [PATCH 23/36] driver core: bus: mark the struct bus_type for sysfs callbacks as constant
In reply to Greg Kroah-HartmanQuoted 70 lines · Greg Kroah-Hartman
struct
bus_typeshould 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 structbus_typeto be moved to read-only memory.Cc "David S. Miller" <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc Alex Shi <[email protected]>Cc Alexander Gordeev <[email protected]>Cc Alexandre Bounine <[email protected]>Cc Alison Schofield <[email protected]>Cc Ben Widawsky <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Dan Williams <[email protected]>Cc Dexuan Cui <[email protected]>Cc Eric Dumazet <[email protected]>Cc Haiyang Zhang <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Harald Freudenberger <[email protected]>Cc Heiko Carstens <[email protected]>Cc Hu Haowen <[email protected]>Cc Ilya Dryomov <[email protected]>Cc Ira Weiny <[email protected]>Cc Iwona Winiarska <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Jens Axboe <[email protected]>Cc Jonathan Corbet <[email protected]>Cc Laurentiu Tudor <[email protected]>Cc Matt Porter <[email protected]>Cc Michael Ellerman <[email protected]>Cc Paolo Abeni <[email protected]>Cc Stuart Yoder <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Vishal Verma <[email protected]>Cc Wei Liu <[email protected]>Cc Yanteng Si <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.Documentation/driver-api/driver-model/bus.rst | 4 +- Documentation/filesystems/sysfs.rst | 4 +- .../translations/zh_CN/filesystems/sysfs.txt | 4 +- .../translations/zh_TW/filesystems/sysfs.txt | 4 +- arch/powerpc/platforms/pseries/ibmebus.c | 4 +- arch/powerpc/platforms/pseries/vio.c | 8 ++-- drivers/ata/pata_parport/pata_parport.c | 6 +-- drivers/base/bus.c | 8 ++-- drivers/block/rbd.c | 34 +++++++-------- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +-- drivers/cxl/core/port.c | 2 +- drivers/hv/vmbus_drv.c | 2 +- drivers/net/netdevsim/bus.c | 4 +- drivers/pci/pci-sysfs.c | 2 +- drivers/pci/pci.c | 4 +- drivers/peci/sysfs.c | 2 +- drivers/rapidio/rio-sysfs.c | 2 +- drivers/s390/crypto/ap_bus.c | 42 +++++++++---------- drivers/scsi/fcoe/fcoe_sysfs.c | 8 ++-- drivers/scsi/fcoe/fcoe_transport.c | 6 +-- include/linux/device/bus.h | 4 +- include/scsi/libfcoe.h | 6 +--
22 files changed, 78 insertions(+), 88 deletions(-)
[..]
Quoted 7 lines
drivers/peci/sysfs.c +0
-0@@ -15,7 +15,7 @@ static int rescan_controller(struct device *dev, void *data) return peci_controller_scan_devices(to_peci_controller(dev)); }
Quoted 8 lines
-staticssize_trescan_store(struct bus_type *bus, const char *buf, size_t count)
+staticssize_trescan_store(const struct bus_type *bus, const char *buf, size_t count)
{
bool res;
int ret;
Thanks
-Iwona
Greg Kroah-Hartman
maintainerPATCH 24/36 driver core: bus: constantify bus_register()
In reply to Greg Kroah-Hartmanbus_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.
--- drivers/base/base.h | 2 +- drivers/base/bus.c | 2 +- include/linux/device/bus.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/base/base.h +1 -1
@@ -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;
drivers/base/bus.c +1 -1
@@ -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;
include/linux/device/bus.h +1 -1
@@ -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);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 25/36 driver core: bus: constify bus_rescan_devices()
In reply to Greg Kroah-HartmanThe 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.
--- drivers/base/bus.c | 2 +- include/linux/device/bus.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/bus.c +1 -1
@@ -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); }
include/linux/device/bus.h +1 -1
@@ -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;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 26/36 driver core: bus: constify driver_find()
In reply to Greg Kroah-HartmanThe driver_find() function can now take a const * to bus_type, not just a * so fix that up.
--- drivers/base/bus.c | 2 +- include/linux/device/driver.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/bus.c +1 -1
@@ -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;
include/linux/device/driver.h +1 -1
@@ -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 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 27/36 driver core: bus: constify bus_get()
In reply to Greg Kroah-HartmanIt'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.
--- drivers/base/bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/base/bus.c +3 -3
@@ -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 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 28/36 driver core: make the bus_type in struct device_driver constant
In reply to Greg Kroah-HartmanThe 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.
--- include/linux/device/driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/device/driver.h +1 -1
@@ -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 */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 29/36 crypto: hisilicon/qm - make struct bus_type * const
In reply to Greg Kroah-HartmanIn 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.
---
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(-)
drivers/crypto/hisilicon/qm.c +1 -1
@@ -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;
Signature · 1 line
2.39.2
Re: [PATCH 29/36] crypto: hisilicon/qm - make struct bus_type * const
Quoted 18 lines · Greg Kroah-Hartman
In the function,
qm_get_qos_value(), a structbus_type* is used, but it really should be a const pointer as it is not modified anywhere in the function, and the driver core function it is used in expects a constant pointer.Cc Weili Qian <[email protected]>Cc Zhou Wang <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.
Quoted 2 lines
drivers/crypto/hisilicon/qm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Greg Kroah-Hartman
maintainerPATCH 30/36 drm/i915/huc: use const struct bus_type pointers
In reply to Greg Kroah-HartmanThe 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.
---
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(-)
drivers/gpu/drm/i915/gt/uc/intel_huc.c +2 -2
@@ -183,7 +183,7 @@ static int gsc_notifier(struct notifier_block *nb, unsigned long action, void *dreturn 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 ;
drivers/gpu/drm/i915/gt/uc/intel_huc.h +2 -2
@@ -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) {
Signature · 1 line
2.39.2
Re: [PATCH 30/36] drm/i915/huc: use const struct bus_type pointers
Quoted 21 lines · Greg Kroah-Hartman
The struct
bus_typepointers in the functionsintel_huc_register_gsc_notifier()andintel_huc_unregister_gsc_notifier()should be a const pointer, as the structure is not modified anywhere in the functions, and the pointer they are passed will be a const * in the near future.Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Tvrtko Ursulin <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Daniele Ceraolo Spurio <[email protected]>Cc Alan Previn <[email protected]>Cc John Harrison <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Tony Ye <[email protected]>Cc Vitaly Lubart <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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.
Regards,
Tvrtko
Quoted 42 lines
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(-)drivers/gpu/drm/i915/gt/uc/intel_huc.c +2
-2@@ -183,7 +183,7 @@ static int gsc_notifier(struct notifier_block *nb, unsigned long action, void *dreturn 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 ;drivers/gpu/drm/i915/gt/uc/intel_huc.h +2
-2@@ -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) {
Greg Kroah-Hartman
maintainerPATCH 31/36 vhost-vdpa: vhost_vdpa_alloc_domain() should be using a const struct bus_type *
In reply to Greg Kroah-HartmanThe 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.
---
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(-)
drivers/vhost/vdpa.c +1 -1
@@ -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 */
Signature · 6 lines
2.39.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Greg Kroah-Hartman
maintainerPATCH 32/36 dmaengine: idxd: use const struct bus_type *
In reply to Greg Kroah-HartmanIn 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.
---
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(-)
drivers/dma/idxd/compat.c +2 -2
@@ -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 ;
Signature · 1 line
2.39.2
Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
Hi, Greg,
Quoted 34 lines · Greg Kroah-Hartman
In the functions
unbind_store()andbind_store(), a structbus_type* should be a const one, as the driver core bus functions used by this variable are expecting the pointer to be constant, and these functions do not modify the pointer at all.Cc Fenghua Yu <[email protected]>Cc Dave Jiang <[email protected]>Cc Vinod Koul <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/dma/idxd/compat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dma/idxd/compat.c +1
-1@@ -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 ;
drivers/dma/idxd/compat.c static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store); · line 38
Quoted 8 lines
drivers/dma/idxd/compat.c +1
-1@@ -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
Greg Kroah-Hartman
maintainerRe: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
Quoted 55 lines · Fenghua Yu
Hi, Greg,
Quoted 32 lines · Greg Kroah-Hartman
In the functions
unbind_store()andbind_store(), a structbus_type* should be a const one, as the driver core bus functions used by this variable are expecting the pointer to be constant, and these functions do not modify the pointer at all.Cc Fenghua Yu <[email protected]>Cc Dave Jiang <[email protected]>Cc Vinod Koul <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/dma/idxd/compat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dma/idxd/compat.c +1
-1@@ -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 ;drivers/dma/idxd/compat.c static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store); · line 37
Quoted 7 lines
drivers/dma/idxd/compat.c +1
-1@@ -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,
fromdrivers/dma/idxd/compat.c:6:./include/linux/device/driver.h:129:59: note: expected ‘structbus_type*’ but argument is of type ‘const structbus_type*’
Quoted 5 lines
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
Fenghua Yu
Acked-byRe: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
Hi, Greg,
Quoted 59 lines · Greg Kroah-Hartman
Quoted 58 lines · Fenghua Yu
Hi, Greg,
Quoted 32 lines · Greg Kroah-Hartman
In the functions
unbind_store()andbind_store(), a structbus_type* should be a const one, as the driver core bus functions used by this variable are expecting the pointer to be constant, and these functions do not modify the pointer at all.Cc Fenghua Yu <[email protected]>Cc Dave Jiang <[email protected]>Cc Vinod Koul <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/dma/idxd/compat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dma/idxd/compat.c +1
-1@@ -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 ;drivers/dma/idxd/compat.c static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store); · line 37
Quoted 7 lines
drivers/dma/idxd/compat.c +1
-1@@ -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,
fromdrivers/dma/idxd/compat.c:6:./include/linux/device/driver.h:129:59: note: expected ‘structbus_type*’ but argument is of type ‘const structbus_type*’129 | struct bus_type *bus); | ~~~~~~~~~~~~~~~~~^~~
Quoted 7 lines
Quoted 2 lines
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.
Thanks.
-Fenghua
Greg Kroah-Hartman
maintainerRe: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
Quoted 65 lines · Fenghua Yu
Hi, Greg,
Quoted 62 lines · Greg Kroah-Hartman
Quoted 60 lines · Fenghua Yu
Hi, Greg,
Quoted 32 lines · Greg Kroah-Hartman
In the functions
unbind_store()andbind_store(), a structbus_type* should be a const one, as the driver core bus functions used by this variable are expecting the pointer to be constant, and these functions do not modify the pointer at all.Cc Fenghua Yu <[email protected]>Cc Dave Jiang <[email protected]>Cc Vinod Koul <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Note, this is a patch that is a prepatory cleanup as part of a larger series of patches that is working on resolving some old driver core design mistakes. It will build and apply cleanly on top of 6.3-rc2 on its own, but I'd prefer if I could take it through my driver-core tree so that the driver core changes can be taken through there for 6.4-rc1.drivers/dma/idxd/compat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dma/idxd/compat.c +1
-1@@ -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 ;drivers/dma/idxd/compat.c static DRIVER_ATTR_IGNORE_LOCKDEP(unbind, 0200, NULL, unbind_store); · line 37
Quoted 7 lines
drivers/dma/idxd/compat.c +1
-1@@ -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,
fromdrivers/dma/idxd/compat.c:6:./include/linux/device/driver.h:129:59: note: expected ‘structbus_type*’ but argument is of type ‘const structbus_type*’129 | struct bus_type *bus); | ~~~~~~~~~~~~~~~~~^~~Should the "bus" parameter in
driver_find()definition be changed to const as well to avoid the warning?
Quoted 8 lines
Quoted 4 lines
Oops, yes, it needs an earlier patch in this series, sorry, I didn't call that out properly in the notes section of the patch.
So I can just take this through my tree if that's ok.
Sure.
Acked-by Fenghua Yu <[email protected]>
Great, thanks for this, I've now queued up the series in my tree.
greg k-h
Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
In reply to Greg Kroah-HartmanQuoted 4 lines · Greg Kroah-Hartman
In the functions
unbind_store()andbind_store(), a structbus_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.
Signature · 1 line
~Vinod
Re: [PATCH 32/36] dmaengine: idxd: use const struct bus_type *
In reply to Greg Kroah-HartmanQuoted 10 lines · Greg Kroah-Hartman
In the functions
unbind_store()andbind_store(), a structbus_type* should be a const one, as the driver core bus functions used by this variable are expecting the pointer to be constant, and these functions do not modify the pointer at all.Cc Fenghua Yu <[email protected]>Cc Dave Jiang <[email protected]>Cc Vinod Koul <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 32 lines
---
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(-)drivers/dma/idxd/compat.c +2
-2@@ -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 ;
Greg Kroah-Hartman
maintainerPATCH 33/36 ARM/dma-mapping: const a pointer to bus_type in arm_iommu_create_mapping()
In reply to Greg Kroah-HartmanChange 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.
---
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(-)
arch/arm/include/asm/dma-iommu.h +1 -1
@@ -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);
arch/arm/mm/dma-mapping.c +1 -1
@@ -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 );
Signature · 7 lines
2.39.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 34/36 iommu: make the pointer to struct bus_type constant
In reply to Greg Kroah-HartmanA 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.
---
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(-)
drivers/iommu/iommu.c +7 -7
@@ -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 ); }
include/linux/iommu.h +5 -5
@@ -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 ; }
Signature · 1 line
2.39.2
Re: [PATCH 34/36] iommu: make the pointer to struct bus_type constant
Quoted 12 lines · Greg Kroah-Hartman
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_typepointers constant in the kernel.Cc Joerg Roedel <[email protected]>Cc Will Deacon <[email protected]>Cc Robin Murphy <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
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
Greg Kroah-Hartman
maintainerPATCH 35/36 driver core: device.h: make struct bus_type a const *
In reply to Greg Kroah-HartmanNow 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.
--- include/linux/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/device.h +1 -1
@@ -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
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 36/36 USB: mark all struct bus_type as const
In reply to Greg Kroah-HartmanNow 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.
--- 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(-)
drivers/usb/common/ulpi.c +1 -1
@@ -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,
drivers/usb/core/driver.c +1 -1
@@ -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,
drivers/usb/core/usb.h +1 -1
@@ -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;
drivers/usb/gadget/udc/core.c +2 -2
@@ -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,
drivers/usb/serial/bus.c +1 -1
@@ -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,
drivers/usb/typec/bus.c +1 -1
@@ -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,
drivers/usb/typec/bus.h +1 -1
@@ -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)
include/linux/usb/serial.h +1 -1
@@ -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,
Signature · 1 line
2.39.2
Re: [PATCH 36/36] USB: mark all struct bus_type as const
Quoted 10 lines · Greg Kroah-Hartman
Now that the driver core can properly handle constant struct
bus_type, move all of the USB subsystem structbus_typestructures as const, placing them into read-only memory which can not be modified at runtime.Cc Heikki Krogerus <[email protected]>Cc Johan Hovold <[email protected]>Cc Evan Green <[email protected]>Cc Alan Stern <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 126 lines
--- 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(-)drivers/usb/common/ulpi.c +1
-1@@ -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,drivers/usb/core/driver.c +1
-1@@ -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,drivers/usb/core/usb.h +1
-1@@ -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;drivers/usb/gadget/udc/core.c +2
-2@@ -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,drivers/usb/serial/bus.c +1
-1@@ -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,drivers/usb/typec/bus.c +1
-1@@ -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,drivers/usb/typec/bus.h +1
-1@@ -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)include/linux/usb/serial.h +1
-1@@ -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,Signature · 1 line
2.39.2
Signature · 1 line
heikki