Skip to contentSkip to conversation

usb: eth: lan78xx: Fix logic in lan78xx_read_otp() to avoid a warning

PATCH In review Tom Rini 2 participants 3 messages Jun 4, 2020 – Jun 20, 2023 USB

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 usb: eth: lan78xx: Fix logic in lan78xx_read_otp() to avoid a warning

In lan78xx_read_otp() we want to know if sig is LAN78XX_OTP_INDICATOR_1 or LAN78XX_OTP_INDICATOR_2. In the case of matching the first one we set offset to itself, and clang warns about this. Rework the logic so that if sig is the second indicator we adjust the offset as today and if it does not match the first indicator we return -EINVAL

---
 drivers/usb/eth/lan78xx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/eth/lan78xx.c +2 -4
index e34ad2603fbb..d147412990de 100644
@@ -146,11 +146,9 @@ static int lan78xx_read_otp(struct usb_device *udev, u32 offset,
 	ret = lan78xx_read_raw_otp(udev, 0, 1, &sig);
 
 	if (!ret) {
-		if (sig == LAN78XX_OTP_INDICATOR_1)
-			offset = offset;
-		else if (sig == LAN78XX_OTP_INDICATOR_2)
+		if (sig == LAN78XX_OTP_INDICATOR_2)
 			offset += 0x100;
-		else
+		else if (sig != LAN78XX_OTP_INDICATOR_1)
 			return -EINVAL;
 		ret = lan78xx_read_raw_otp(udev, offset, length, data);
 		if (ret)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 usb: eth: lan78xx: Fix logic in lan78xx_read_otp() to avoid a warning

Quoted 8 lines · Tom Rini

In lan78xx_read_otp() we want to know if sig is LAN78XX_OTP_INDICATOR_1 or LAN78XX_OTP_INDICATOR_2. In the case of matching the first one we set offset to itself, and clang warns about this. Rework the logic so that if sig is the second indicator we adjust the offset as today and if it does not match the first indicator we return -EINVAL

author
#2 lore raw
In reply to Tom Rini
Quoted 8 lines · Tom Rini

In lan78xx_read_otp() we want to know if sig is LAN78XX_OTP_INDICATOR_1 or LAN78XX_OTP_INDICATOR_2. In the case of matching the first one we set offset to itself, and clang warns about this. Rework the logic so that if sig is the second indicator we adjust the offset as today and if it does not match the first indicator we return -EINVAL

[...]

Applied to u-boot/next, thanks!

Signature · 1 line
Tom