drivers: misc: ad525x_dpot: Add missing check in dpot_read_spi
diff mbox series

Message ID 20210301125057.28819-1-dinghao.liu@zju.edu.cn
State Accepted
Commit f8096ff38d5f62d8a2c473e1bec0163a1b2b86d8
Headers show
Series
  • drivers: misc: ad525x_dpot: Add missing check in dpot_read_spi
Related show

Commit Message

Dinghao Liu March 1, 2021, 12:50 p.m. UTC
The use of dpot_read_r8d8() after checking dpot->uid is similar.
However, we check the return value and return an error code only
in one path, which is odd.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/misc/ad525x_dpot.c | 3 +++
 1 file changed, 3 insertions(+)

Patch
diff mbox series

diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 6f164522b028..5d8f3f6a95f2 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -139,6 +139,9 @@  static s32 dpot_read_spi(struct dpot_data *dpot, u8 reg)
 			value = dpot_read_r8d8(dpot,
 				DPOT_AD5291_READ_RDAC << 2);
 
+			if (value < 0)
+				return value;
+
 			if (dpot->uid == DPOT_UID(AD5291_ID))
 				value = value >> 2;