cpuidle: move to use bus_get_dev_root()
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 09:05:57 +0000 (10:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 19:25:23 +0000 (20:25 +0100)
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>
drivers/cpuidle/cpuidle.c
drivers/cpuidle/cpuidle.h
drivers/cpuidle/sysfs.c

index 0b00f21..8e929f6 100644 (file)
@@ -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);
index 9f336af..52701d9 100644 (file)
@@ -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);
index 48948b1..d6f5da6 100644 (file)
@@ -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;
 }
 
 /**