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

Configure Feed

Select the types of activity you want to include in your feed.

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

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

Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-pm@vger.kernel.org
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230322090557.2943479-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+12 -5
+1 -1
drivers/cpuidle/cpuidle.c
··· 808 808 if (cpuidle_disabled()) 809 809 return -ENODEV; 810 810 811 - return cpuidle_add_interface(cpu_subsys.dev_root); 811 + return cpuidle_add_interface(); 812 812 } 813 813 814 814 module_param(off, int, 0444);
+1 -1
drivers/cpuidle/cpuidle.h
··· 30 30 31 31 struct device; 32 32 33 - extern int cpuidle_add_interface(struct device *dev); 33 + extern int cpuidle_add_interface(void); 34 34 extern void cpuidle_remove_interface(struct device *dev); 35 35 extern int cpuidle_add_device_sysfs(struct cpuidle_device *device); 36 36 extern void cpuidle_remove_device_sysfs(struct cpuidle_device *device);
+10 -3
drivers/cpuidle/sysfs.c
··· 119 119 120 120 /** 121 121 * cpuidle_add_interface - add CPU global sysfs attributes 122 - * @dev: the target device 123 122 */ 124 - int cpuidle_add_interface(struct device *dev) 123 + int cpuidle_add_interface(void) 125 124 { 126 - return sysfs_create_group(&dev->kobj, &cpuidle_attr_group); 125 + struct device *dev_root = bus_get_dev_root(&cpu_subsys); 126 + int retval; 127 + 128 + if (!dev_root) 129 + return -EINVAL; 130 + 131 + retval = sysfs_create_group(&dev_root->kobj, &cpuidle_attr_group); 132 + put_device(dev_root); 133 + return retval; 127 134 } 128 135 129 136 /**