Skip to content

Commit

Permalink
Merge branch 'lan78xx-fixes'
Browse files Browse the repository at this point in the history
Nisar Sayed says:

====================
lan78xx: This series of patches are for lan78xx driver.

This series of patches are for lan78xx driver.

These patches fixes potential issues associated with lan78xx driver.

v5
- Updated changes as per comments

v4
- Updated changes to handle return values as per comments
- Updated EEPROM write handling as per comments

v3
- Updated chagnes as per comments

v2
- Added patch version information
- Added fixes tag
- Updated patch description
- Updated chagnes as per comments

v1
- Splitted patches as per comments
- Dropped "fixed_phy device support" and "Fix for system suspend" changes
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 21, 2017
2 parents 59ec693 + e365280 commit 687740c
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions drivers/net/usb/lan78xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,30 +1265,45 @@ 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;

ret = usb_autopm_get_interface(dev->intf);
if (ret)
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;

ret = usb_autopm_get_interface(dev->intf);
if (ret)
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);
/* Invalid EEPROM_INDICATOR at offset zero will result in a failure
* to load data from EEPROM
*/
if (ee->magic == LAN78XX_EEPROM_MAGIC)
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);

usb_autopm_put_interface(dev->intf);

return -EINVAL;
return ret;
}

static void lan78xx_get_strings(struct net_device *netdev, u32 stringset,
Expand Down Expand Up @@ -2434,7 +2449,6 @@ static int lan78xx_reset(struct lan78xx_net *dev)
/* LAN7801 only has RGMII mode */
if (dev->chipid == ID_REV_CHIP_ID_7801_)
buf &= ~MAC_CR_GMII_EN_;
buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
ret = lan78xx_write_reg(dev, MAC_CR, buf);

ret = lan78xx_read_reg(dev, MAC_TX, &buf);
Expand Down

0 comments on commit 687740c

Please sign in to comment.