[PATCH net 3/4] lan78xx: Fix for eeprom read/write when device autosuspend

Subsystems: networking drivers, the rest, usb lan78xx ethernet driver, usb networking drivers

STALE3283d

3 messages, 2 authors, 2017-09-06 · open the first message on its own page

[PATCH net 3/4] lan78xx: Fix for eeprom read/write when device autosuspend

From: <hidden>
Date: 2017-09-06 10:52:56

From: Nisar Sayed <redacted>

Fix for eeprom read/write when device autosuspend

Signed-off-by: Nisar Sayed <redacted>
---
 drivers/net/usb/lan78xx.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 6242cb7..e04ec23 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1278,30 +1278,48 @@ static int lan78xx_ethtool_get_eeprom(struct net_device *netdev,
 				      struct ethtool_eeprom *ee, u8 *data)
 {
 	struct lan78xx_net *dev = netdev_priv(netdev);
+	int ret = -EINVAL;
+
+	if (usb_autopm_get_interface(dev->intf) < 0)
+		return ret;
 
 	ee->magic = LAN78XX_EEPROM_MAGIC;
 
-	return lan78xx_read_raw_eeprom(dev, ee->offset, ee->len, data);
+	ret = lan78xx_read_raw_eeprom(dev, ee->offset, ee->len, data);
+
+	usb_autopm_put_interface(dev->intf);
+
+	return ret;
 }
 
 static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
 				      struct ethtool_eeprom *ee, u8 *data)
 {
 	struct lan78xx_net *dev = netdev_priv(netdev);
+	int ret = -EINVAL;
+
+	if (usb_autopm_get_interface(dev->intf) < 0)
+		return ret;
 
 	/* Allow entire eeprom update only */
 	if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
 	    (ee->offset == 0) &&
 	    (ee->len == 512) &&
 	    (data[0] == EEPROM_INDICATOR))
-		return lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
+		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
 	else if ((ee->magic == LAN78XX_OTP_MAGIC) &&
 		 (ee->offset == 0) &&
 		 (ee->len == 512) &&
 		 (data[0] == OTP_INDICATOR_1))
-		return lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
+		ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
+	else if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
+		 (ee->offset >= 0 && ee->offset < MAX_EEPROM_SIZE) &&
+		 (ee->len > 0 && (ee->offset + ee->len) <= MAX_EEPROM_SIZE))
+		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
 
-	return -EINVAL;
+	usb_autopm_put_interface(dev->intf);
+
+	return ret;
 }
 
 static void lan78xx_get_strings(struct net_device *netdev, u32 stringset,
-- 
1.9.1

Re: [PATCH net 3/4] lan78xx: Fix for eeprom read/write when device autosuspend

From: Andrew Lunn <andrew@lunn.ch>
Date: 2017-09-06 14:06:08

Hi Nisar
+	else if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
+		 (ee->offset >= 0 && ee->offset < MAX_EEPROM_SIZE) &&
+		 (ee->len > 0 && (ee->offset + ee->len) <= MAX_EEPROM_SIZE))
+		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
This change does not appear to have anything to do with auto suspend.
Please make it a separate patch.

       Andrew

RE: [PATCH net 3/4] lan78xx: Fix for eeprom read/write when device autosuspend

From: <hidden>
Date: 2017-09-06 17:35:45

Thanks, will make separate patch.
Hi Nisar
quoted
+	else if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
+		 (ee->offset >= 0 && ee->offset < MAX_EEPROM_SIZE) &&
+		 (ee->len > 0 && (ee->offset + ee->len) <=
MAX_EEPROM_SIZE))
quoted
+		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len,
data);

This change does not appear to have anything to do with auto suspend.
Please make it a separate patch.

       Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help