* [PATCH v4 net 0/3] lan78xx: This series of patches are for lan78xx driver. @ 2017-09-18 22:02 Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 1/3] lan78xx: Fix for eeprom read/write when device auto suspend Nisar Sayed ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Nisar Sayed @ 2017-09-18 22:02 UTC (permalink / raw) To: davem; +Cc: UNGLinuxDriver, netdev This series of patches are for lan78xx driver. These patches fixes potential issues associated with lan78xx driver. 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 Nisar Sayed (3): Fix for eeprom read/write when device auto suspend Allow EEPROM write for less than MAX_EEPROM_SIZE Use default values loaded from EEPROM/OTP after reset drivers/net/usb/lan78xx.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) -- 2.14.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 net 1/3] lan78xx: Fix for eeprom read/write when device auto suspend 2017-09-18 22:02 [PATCH v4 net 0/3] lan78xx: This series of patches are for lan78xx driver Nisar Sayed @ 2017-09-18 22:02 ` Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 3/3] lan78xx: Use default values loaded from EEPROM/OTP after reset Nisar Sayed 2 siblings, 0 replies; 6+ messages in thread From: Nisar Sayed @ 2017-09-18 22:02 UTC (permalink / raw) To: davem; +Cc: UNGLinuxDriver, netdev Fix for eeprom read/write when device auto suspend Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com> --- drivers/net/usb/lan78xx.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index b99a7fb09f8e..fcf85ae37435 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1265,30 +1265,46 @@ 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); + 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); - return -EINVAL; + usb_autopm_put_interface(dev->intf); + + return ret; } static void lan78xx_get_strings(struct net_device *netdev, u32 stringset, -- 2.14.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE 2017-09-18 22:02 [PATCH v4 net 0/3] lan78xx: This series of patches are for lan78xx driver Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 1/3] lan78xx: Fix for eeprom read/write when device auto suspend Nisar Sayed @ 2017-09-18 22:02 ` Nisar Sayed 2017-09-18 19:29 ` Sergei Shtylyov 2017-09-18 22:02 ` [PATCH v4 net 3/3] lan78xx: Use default values loaded from EEPROM/OTP after reset Nisar Sayed 2 siblings, 1 reply; 6+ messages in thread From: Nisar Sayed @ 2017-09-18 22:02 UTC (permalink / raw) To: davem; +Cc: UNGLinuxDriver, netdev Allow EEPROM write for less than MAX_EEPROM_SIZE Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com> --- drivers/net/usb/lan78xx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index fcf85ae37435..3292f56ffe02 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -1290,11 +1290,10 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev, 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)) + /* Invalid EEPROM_INDICATOR at offset zero will result in fail 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) && -- 2.14.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE 2017-09-18 22:02 ` [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE Nisar Sayed @ 2017-09-18 19:29 ` Sergei Shtylyov 2017-09-20 15:27 ` Nisar.Sayed 0 siblings, 1 reply; 6+ messages in thread From: Sergei Shtylyov @ 2017-09-18 19:29 UTC (permalink / raw) To: Nisar Sayed, davem; +Cc: UNGLinuxDriver, netdev Hello! On 09/19/2017 01:02 AM, Nisar Sayed wrote: > Allow EEPROM write for less than MAX_EEPROM_SIZE > > Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") > Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com> > --- > drivers/net/usb/lan78xx.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c > index fcf85ae37435..3292f56ffe02 100644 > --- a/drivers/net/usb/lan78xx.c > +++ b/drivers/net/usb/lan78xx.c > @@ -1290,11 +1290,10 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev, > 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)) > + /* Invalid EEPROM_INDICATOR at offset zero will result in fail to s/fail/a failure/. > + * 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) && > MBR, Sergei ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE 2017-09-18 19:29 ` Sergei Shtylyov @ 2017-09-20 15:27 ` Nisar.Sayed 0 siblings, 0 replies; 6+ messages in thread From: Nisar.Sayed @ 2017-09-20 15:27 UTC (permalink / raw) To: sergei.shtylyov, davem; +Cc: UNGLinuxDriver, netdev Thanks Sergei, I will update it and submit next version. - Nisar > Hello! > > On 09/19/2017 01:02 AM, Nisar Sayed wrote: > > > Allow EEPROM write for less than MAX_EEPROM_SIZE > > > > Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to > > 10/100/1000 Ethernet device driver") > > Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com> > > --- > > drivers/net/usb/lan78xx.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c > > index fcf85ae37435..3292f56ffe02 100644 > > --- a/drivers/net/usb/lan78xx.c > > +++ b/drivers/net/usb/lan78xx.c > > @@ -1290,11 +1290,10 @@ static int lan78xx_ethtool_set_eeprom(struct > net_device *netdev, > > 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)) > > + /* Invalid EEPROM_INDICATOR at offset zero will result in fail to > > s/fail/a failure/. > > > + * 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) && > > > > MBR, Sergei ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 net 3/3] lan78xx: Use default values loaded from EEPROM/OTP after reset 2017-09-18 22:02 [PATCH v4 net 0/3] lan78xx: This series of patches are for lan78xx driver Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 1/3] lan78xx: Fix for eeprom read/write when device auto suspend Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE Nisar Sayed @ 2017-09-18 22:02 ` Nisar Sayed 2 siblings, 0 replies; 6+ messages in thread From: Nisar Sayed @ 2017-09-18 22:02 UTC (permalink / raw) To: davem; +Cc: UNGLinuxDriver, netdev Use default value of auto duplex and auto speed values loaded from EEPROM/OTP after reset. The LAN78xx allows platform configurations to be loaded from EEPROM/OTP. Ex: When external phy is connected, the MAC can be configured to have correct auto speed, auto duplex, auto polarity configured from the EEPROM/OTP. Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com> --- drivers/net/usb/lan78xx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 3292f56ffe02..0fc3c19d5aef 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2449,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); -- 2.14.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-20 15:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-09-18 22:02 [PATCH v4 net 0/3] lan78xx: This series of patches are for lan78xx driver Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 1/3] lan78xx: Fix for eeprom read/write when device auto suspend Nisar Sayed 2017-09-18 22:02 ` [PATCH v4 net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE Nisar Sayed 2017-09-18 19:29 ` Sergei Shtylyov 2017-09-20 15:27 ` Nisar.Sayed 2017-09-18 22:02 ` [PATCH v4 net 3/3] lan78xx: Use default values loaded from EEPROM/OTP after reset Nisar Sayed
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).