Skip to content

Commit aadf7b3

Browse files
zhang-ruiKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Len Brown <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/ae3d1903407fd6e3684234b674f4f0e62c2ab54c.1557769318.git.len.brown@intel.com
1 parent 212bf4f commit aadf7b3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/powercap/intel_rapl.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,9 @@ static struct powercap_control_type *control_type; /* PowerCap Controller */
264264
static struct rapl_domain *platform_rapl_domain; /* Platform (PSys) domain */
265265

266266
/* caller to ensure CPU hotplug lock is held */
267-
static struct rapl_package *find_package_by_id(int id)
267+
static struct rapl_package *rapl_find_package_domain(int cpu)
268268
{
269+
int id = topology_physical_package_id(cpu);
269270
struct rapl_package *rp;
270271

271272
list_for_each_entry(rp, &rapl_packages, plist) {
@@ -1300,7 +1301,7 @@ static int __init rapl_register_psys(void)
13001301
rd->rpl[0].name = pl1_name;
13011302
rd->rpl[1].prim_id = PL2_ENABLE;
13021303
rd->rpl[1].name = pl2_name;
1303-
rd->rp = find_package_by_id(0);
1304+
rd->rp = rapl_find_package_domain(0);
13041305

13051306
power_zone = powercap_register_zone(&rd->power_zone, control_type,
13061307
"psys", NULL,
@@ -1456,8 +1457,9 @@ static void rapl_remove_package(struct rapl_package *rp)
14561457
}
14571458

14581459
/* called from CPU hotplug notifier, hotplug lock held */
1459-
static struct rapl_package *rapl_add_package(int cpu, int pkgid)
1460+
static struct rapl_package *rapl_add_package(int cpu)
14601461
{
1462+
int id = topology_physical_package_id(cpu);
14611463
struct rapl_package *rp;
14621464
int ret;
14631465

@@ -1466,7 +1468,7 @@ static struct rapl_package *rapl_add_package(int cpu, int pkgid)
14661468
return ERR_PTR(-ENOMEM);
14671469

14681470
/* add the new package to the list */
1469-
rp->id = pkgid;
1471+
rp->id = id;
14701472
rp->lead_cpu = cpu;
14711473

14721474
/* check if the package contains valid domains */
@@ -1497,12 +1499,11 @@ static struct rapl_package *rapl_add_package(int cpu, int pkgid)
14971499
*/
14981500
static int rapl_cpu_online(unsigned int cpu)
14991501
{
1500-
int pkgid = topology_physical_package_id(cpu);
15011502
struct rapl_package *rp;
15021503

1503-
rp = find_package_by_id(pkgid);
1504+
rp = rapl_find_package_domain(cpu);
15041505
if (!rp) {
1505-
rp = rapl_add_package(cpu, pkgid);
1506+
rp = rapl_add_package(cpu);
15061507
if (IS_ERR(rp))
15071508
return PTR_ERR(rp);
15081509
}
@@ -1512,11 +1513,10 @@ static int rapl_cpu_online(unsigned int cpu)
15121513

15131514
static int rapl_cpu_down_prep(unsigned int cpu)
15141515
{
1515-
int pkgid = topology_physical_package_id(cpu);
15161516
struct rapl_package *rp;
15171517
int lead_cpu;
15181518

1519-
rp = find_package_by_id(pkgid);
1519+
rp = rapl_find_package_domain(cpu);
15201520
if (!rp)
15211521
return 0;
15221522

0 commit comments

Comments
 (0)