Skip to contentSkip to conversation

drivers: firmware: Handle error case in the zynqmp_pm_feature

PATCH Superseded Venkatesh Yadav Abbarapu 2 participants 2 messages Oct 10, 2023 Arm/Zynq architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: firmware: Handle error case in the zynqmp_pm_feature

There is a unused variable ret, due to which we are getting sparse warning as below.
warning: variable 'ret' set but not used [-Wunused-but-set-variable]. In case of error return the "ret" value.

---
 drivers/firmware/firmware-zynqmp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/firmware/firmware-zynqmp.c +3 -0
index 43fb7fa778..57d5a1f469 100644
@@ -204,6 +204,9 @@ int zynqmp_pm_feature(const u32 api_id)
 	ret = xilinx_pm_request(PM_FEATURE_CHECK, api_id, 0, 0, 0,
 				ret_payload);
 
+	if (ret)
+		return ret;
+
 	/* Return feature check version */
 	return ret_payload[1] & FIRMWARE_VERSION_MASK;
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 1 line · Venkatesh Yadav Abbarapu

There is a unused variable ret, due to which we are getting sparse warning

I wouldn't say unused because it is used but only for writing not for reading.

Quoted 3 lines

as below.
warning: variable 'ret' set but not used [-Wunused-but-set-variable]. In case of error return the "ret" value.

I would revert description. Subject is correct.
It is unhandled error coming from xilinx_pm_request() but return value is not read back that's why also sparse warns about it as below:

Quoted 11 lines
---
  drivers/firmware/firmware-zynqmp.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/firmware/firmware-zynqmp.c +0 -0
index 43fb7fa778..57d5a1f469 100644

drivers/firmware/firmware-zynqmp.c int zynqmp_pm_feature(const u32 api_id) · line 206

Quoted 3 lines
drivers/firmware/firmware-zynqmp.c +0 -0
@@ -204,6 +204,9 @@ int zynqmp_pm_feature(const u32 api_id)
  	ret = xilinx_pm_request(PM_FEATURE_CHECK, api_id, 0, 0, 0,
  				ret_payload);
 

remove this newline.

drivers/firmware/firmware-zynqmp.c int zynqmp_pm_feature(const u32 api_id) · line 212

Quoted 6 lines
drivers/firmware/firmware-zynqmp.c +3 -0
+	if (ret)
+		return ret;
+
  	/* Return feature check version */
  	return ret_payload[1] & FIRMWARE_VERSION_MASK;
  }

M

Signature · 6 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs
TF-A maintainer - Xilinx ZynqMP/Versal/Versal NET SoCs