[PATCH] perf/x86/intel/pt: Return an error code only as a constant in pt_pmu_hw_init()

From: Markus Elfring
Date: Sat Dec 23 2023 - 15:31:32 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 23 Dec 2023 21:06:27 +0100

Return an error code without storing it in an intermediate variable.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
arch/x86/events/intel/pt.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 8e2a12235e62..24fd18e2da34 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -190,7 +190,6 @@ static int __init pt_pmu_hw_init(void)
struct attribute **attrs;
size_t size;
u64 reg;
- int ret;
long i;

rdmsrl(MSR_PLATFORM_INFO, reg);
@@ -242,11 +241,10 @@ static int __init pt_pmu_hw_init(void)
&pt_pmu.caps[CPUID_EDX + i*PT_CPUID_REGS_NUM]);
}

- ret = -ENOMEM;
size = sizeof(struct attribute *) * (ARRAY_SIZE(pt_caps)+1);
attrs = kzalloc(size, GFP_KERNEL);
if (!attrs)
- goto fail;
+ return -ENOMEM;

size = sizeof(struct dev_ext_attribute) * (ARRAY_SIZE(pt_caps)+1);
de_attrs = kzalloc(size, GFP_KERNEL);
@@ -273,8 +271,7 @@ static int __init pt_pmu_hw_init(void)

fail:
kfree(attrs);
-
- return ret;
+ return -ENOMEM;
}

#define RTIT_CTL_CYC_PSB (RTIT_CTL_CYCLEACC | \
--
2.43.0