powercap/intel_rapl: Simplify rapl_find_package()

Simplify how the code to discover a package is called.  Rename
find_package_by_id() to rapl_find_package_domain()

Syntax only, no functional or semantic change.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: linux-pm@vger.kernel.org
Link: https://lkml.kernel.org/r/ae3d1903407fd6e3684234b674f4f0e62c2ab54c.1557769318.git.len.brown@intel.com
This commit is contained in:
Zhang Rui 2019-05-13 13:58:50 -04:00 committed by Thomas Gleixner
parent 212bf4fdb7
commit aadf7b3833
1 changed files with 9 additions and 9 deletions

View File

@ -264,8 +264,9 @@ static struct powercap_control_type *control_type; /* PowerCap Controller */
static struct rapl_domain *platform_rapl_domain; /* Platform (PSys) domain */ static struct rapl_domain *platform_rapl_domain; /* Platform (PSys) domain */
/* caller to ensure CPU hotplug lock is held */ /* caller to ensure CPU hotplug lock is held */
static struct rapl_package *find_package_by_id(int id) static struct rapl_package *rapl_find_package_domain(int cpu)
{ {
int id = topology_physical_package_id(cpu);
struct rapl_package *rp; struct rapl_package *rp;
list_for_each_entry(rp, &rapl_packages, plist) { list_for_each_entry(rp, &rapl_packages, plist) {
@ -1300,7 +1301,7 @@ static int __init rapl_register_psys(void)
rd->rpl[0].name = pl1_name; rd->rpl[0].name = pl1_name;
rd->rpl[1].prim_id = PL2_ENABLE; rd->rpl[1].prim_id = PL2_ENABLE;
rd->rpl[1].name = pl2_name; rd->rpl[1].name = pl2_name;
rd->rp = find_package_by_id(0); rd->rp = rapl_find_package_domain(0);
power_zone = powercap_register_zone(&rd->power_zone, control_type, power_zone = powercap_register_zone(&rd->power_zone, control_type,
"psys", NULL, "psys", NULL,
@ -1456,8 +1457,9 @@ static void rapl_remove_package(struct rapl_package *rp)
} }
/* called from CPU hotplug notifier, hotplug lock held */ /* called from CPU hotplug notifier, hotplug lock held */
static struct rapl_package *rapl_add_package(int cpu, int pkgid) static struct rapl_package *rapl_add_package(int cpu)
{ {
int id = topology_physical_package_id(cpu);
struct rapl_package *rp; struct rapl_package *rp;
int ret; int ret;
@ -1466,7 +1468,7 @@ static struct rapl_package *rapl_add_package(int cpu, int pkgid)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
/* add the new package to the list */ /* add the new package to the list */
rp->id = pkgid; rp->id = id;
rp->lead_cpu = cpu; rp->lead_cpu = cpu;
/* check if the package contains valid domains */ /* check if the package contains valid domains */
@ -1497,12 +1499,11 @@ err_free_package:
*/ */
static int rapl_cpu_online(unsigned int cpu) static int rapl_cpu_online(unsigned int cpu)
{ {
int pkgid = topology_physical_package_id(cpu);
struct rapl_package *rp; struct rapl_package *rp;
rp = find_package_by_id(pkgid); rp = rapl_find_package_domain(cpu);
if (!rp) { if (!rp) {
rp = rapl_add_package(cpu, pkgid); rp = rapl_add_package(cpu);
if (IS_ERR(rp)) if (IS_ERR(rp))
return PTR_ERR(rp); return PTR_ERR(rp);
} }
@ -1512,11 +1513,10 @@ static int rapl_cpu_online(unsigned int cpu)
static int rapl_cpu_down_prep(unsigned int cpu) static int rapl_cpu_down_prep(unsigned int cpu)
{ {
int pkgid = topology_physical_package_id(cpu);
struct rapl_package *rp; struct rapl_package *rp;
int lead_cpu; int lead_cpu;
rp = find_package_by_id(pkgid); rp = rapl_find_package_domain(cpu);
if (!rp) if (!rp)
return 0; return 0;