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.

cpufreq: amd-pstate: 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.

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: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org
Acked-by: Huang Rui <ray.huang@.amd.com>
Link: https://lore.kernel.org/r/20230313182918.1312597-20-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+10 -14
+10 -14
drivers/cpufreq/amd-pstate.c
··· 63 63 static struct cpufreq_driver amd_pstate_driver; 64 64 static struct cpufreq_driver amd_pstate_epp_driver; 65 65 static int cppc_state = AMD_PSTATE_DISABLE; 66 - struct kobject *amd_pstate_kobj; 67 66 68 67 /* 69 68 * AMD Energy Preference Performance (EPP) ··· 931 932 }; 932 933 933 934 static const struct attribute_group amd_pstate_global_attr_group = { 935 + .name = "amd_pstate", 934 936 .attrs = pstate_global_attributes, 935 937 }; 936 938 ··· 1253 1253 1254 1254 static int __init amd_pstate_init(void) 1255 1255 { 1256 + struct device *dev_root; 1256 1257 int ret; 1257 1258 1258 1259 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) ··· 1300 1299 if (ret) 1301 1300 pr_err("failed to register with return %d\n", ret); 1302 1301 1303 - amd_pstate_kobj = kobject_create_and_add("amd_pstate", &cpu_subsys.dev_root->kobj); 1304 - if (!amd_pstate_kobj) { 1305 - ret = -EINVAL; 1306 - pr_err("global sysfs registration failed.\n"); 1307 - goto kobject_free; 1308 - } 1309 - 1310 - ret = sysfs_create_group(amd_pstate_kobj, &amd_pstate_global_attr_group); 1311 - if (ret) { 1312 - pr_err("sysfs attribute export failed with error %d.\n", ret); 1313 - goto global_attr_free; 1302 + dev_root = bus_get_dev_root(&cpu_subsys); 1303 + if (dev_root) { 1304 + ret = sysfs_create_group(&dev_root->kobj, &amd_pstate_global_attr_group); 1305 + put_device(dev_root); 1306 + if (ret) { 1307 + pr_err("sysfs attribute export failed with error %d.\n", ret); 1308 + goto global_attr_free; 1309 + } 1314 1310 } 1315 1311 1316 1312 return ret; 1317 1313 1318 1314 global_attr_free: 1319 - kobject_put(amd_pstate_kobj); 1320 - kobject_free: 1321 1315 cpufreq_unregister_driver(current_pstate_driver); 1322 1316 return ret; 1323 1317 }