Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pseries: 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.

Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxppc-dev@lists.ozlabs.org
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Link: https://lore.kernel.org/r/20230313182918.1312597-14-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+25 -13
+17 -11
arch/powerpc/platforms/pseries/pseries_energy.c
··· 300 300 static int __init pseries_energy_init(void) 301 301 { 302 302 int cpu, err; 303 - struct device *cpu_dev; 303 + struct device *cpu_dev, *dev_root; 304 304 305 305 if (!firmware_has_feature(FW_FEATURE_BEST_ENERGY)) 306 306 return 0; /* H_BEST_ENERGY hcall not supported */ 307 307 308 308 /* Create the sysfs files */ 309 - err = device_create_file(cpu_subsys.dev_root, 310 - &attr_cpu_activate_hint_list); 311 - if (!err) 312 - err = device_create_file(cpu_subsys.dev_root, 313 - &attr_cpu_deactivate_hint_list); 309 + dev_root = bus_get_dev_root(&cpu_subsys); 310 + if (dev_root) { 311 + err = device_create_file(dev_root, &attr_cpu_activate_hint_list); 312 + if (!err) 313 + err = device_create_file(dev_root, &attr_cpu_deactivate_hint_list); 314 + put_device(dev_root); 315 + if (err) 316 + return err; 317 + } 314 318 315 - if (err) 316 - return err; 317 319 for_each_possible_cpu(cpu) { 318 320 cpu_dev = get_cpu_device(cpu); 319 321 err = device_create_file(cpu_dev, ··· 339 337 static void __exit pseries_energy_cleanup(void) 340 338 { 341 339 int cpu; 342 - struct device *cpu_dev; 340 + struct device *cpu_dev, *dev_root; 343 341 344 342 if (!sysfs_entries) 345 343 return; 346 344 347 345 /* Remove the sysfs files */ 348 - device_remove_file(cpu_subsys.dev_root, &attr_cpu_activate_hint_list); 349 - device_remove_file(cpu_subsys.dev_root, &attr_cpu_deactivate_hint_list); 346 + dev_root = bus_get_dev_root(&cpu_subsys); 347 + if (dev_root) { 348 + device_remove_file(dev_root, &attr_cpu_activate_hint_list); 349 + device_remove_file(dev_root, &attr_cpu_deactivate_hint_list); 350 + put_device(dev_root); 351 + } 350 352 351 353 for_each_possible_cpu(cpu) { 352 354 cpu_dev = get_cpu_device(cpu);
+8 -2
arch/powerpc/platforms/pseries/suspend.c
··· 143 143 **/ 144 144 static int pseries_suspend_sysfs_register(struct device *dev) 145 145 { 146 + struct device *dev_root; 146 147 int rc; 147 148 148 149 if ((rc = subsys_system_register(&suspend_subsys, NULL))) ··· 152 151 dev->id = 0; 153 152 dev->bus = &suspend_subsys; 154 153 155 - if ((rc = device_create_file(suspend_subsys.dev_root, &dev_attr_hibernate))) 156 - goto subsys_unregister; 154 + dev_root = bus_get_dev_root(&suspend_subsys); 155 + if (dev_root) { 156 + rc = device_create_file(dev_root, &dev_attr_hibernate); 157 + put_device(dev_root); 158 + if (rc) 159 + goto subsys_unregister; 160 + } 157 161 158 162 return 0; 159 163