lan78xx: Fix for eeprom read/write when device auto suspend
Fix for eeprom read/write when device auto suspend
Fixes: 55d7de9de6
("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
59ec693a45
commit
8a7ffeb795
|
@ -1265,30 +1265,46 @@ static int lan78xx_ethtool_get_eeprom(struct net_device *netdev,
|
||||||
struct ethtool_eeprom *ee, u8 *data)
|
struct ethtool_eeprom *ee, u8 *data)
|
||||||
{
|
{
|
||||||
struct lan78xx_net *dev = netdev_priv(netdev);
|
struct lan78xx_net *dev = netdev_priv(netdev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = usb_autopm_get_interface(dev->intf);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
ee->magic = LAN78XX_EEPROM_MAGIC;
|
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,
|
static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
|
||||||
struct ethtool_eeprom *ee, u8 *data)
|
struct ethtool_eeprom *ee, u8 *data)
|
||||||
{
|
{
|
||||||
struct lan78xx_net *dev = netdev_priv(netdev);
|
struct lan78xx_net *dev = netdev_priv(netdev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = usb_autopm_get_interface(dev->intf);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
/* Allow entire eeprom update only */
|
/* Allow entire eeprom update only */
|
||||||
if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
|
if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
|
||||||
(ee->offset == 0) &&
|
(ee->offset == 0) &&
|
||||||
(ee->len == 512) &&
|
(ee->len == 512) &&
|
||||||
(data[0] == EEPROM_INDICATOR))
|
(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) &&
|
else if ((ee->magic == LAN78XX_OTP_MAGIC) &&
|
||||||
(ee->offset == 0) &&
|
(ee->offset == 0) &&
|
||||||
(ee->len == 512) &&
|
(ee->len == 512) &&
|
||||||
(data[0] == OTP_INDICATOR_1))
|
(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);
|
||||||
|
|
||||||
return -EINVAL;
|
usb_autopm_put_interface(dev->intf);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lan78xx_get_strings(struct net_device *netdev, u32 stringset,
|
static void lan78xx_get_strings(struct net_device *netdev, u32 stringset,
|
||||||
|
|
Loading…
Reference in New Issue