Commit 196b7e1b authored by Steve Glendinning's avatar Steve Glendinning Committed by David S. Miller

smsc9420: handle magic field of ethtool_eeprom

ethtool.h says the driver should set the magic field in get_eeprom and
verify it in set_eeprom.  This patch adds this functionality using an
arbitary driver-specific magic value constant (0x9420).
Signed-off-by: default avatarSteve Glendinning <steve.glendinning@smsc.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 62660e28
...@@ -413,6 +413,7 @@ static int smsc9420_ethtool_get_eeprom(struct net_device *dev, ...@@ -413,6 +413,7 @@ static int smsc9420_ethtool_get_eeprom(struct net_device *dev,
} }
memcpy(data, &eeprom_data[eeprom->offset], len); memcpy(data, &eeprom_data[eeprom->offset], len);
eeprom->magic = SMSC9420_EEPROM_MAGIC;
eeprom->len = len; eeprom->len = len;
return 0; return 0;
} }
...@@ -423,6 +424,9 @@ static int smsc9420_ethtool_set_eeprom(struct net_device *dev, ...@@ -423,6 +424,9 @@ static int smsc9420_ethtool_set_eeprom(struct net_device *dev,
struct smsc9420_pdata *pd = netdev_priv(dev); struct smsc9420_pdata *pd = netdev_priv(dev);
int ret; int ret;
if (eeprom->magic != SMSC9420_EEPROM_MAGIC)
return -EINVAL;
smsc9420_eeprom_enable_access(pd); smsc9420_eeprom_enable_access(pd);
smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWEN_); smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWEN_);
ret = smsc9420_eeprom_write_location(pd, eeprom->offset, *data); ret = smsc9420_eeprom_write_location(pd, eeprom->offset, *data);
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#define LAN_REGISTER_EXTENT (0x400) #define LAN_REGISTER_EXTENT (0x400)
#define SMSC9420_EEPROM_SIZE ((u32)11) #define SMSC9420_EEPROM_SIZE ((u32)11)
#define SMSC9420_EEPROM_MAGIC (0x9420)
#define PKT_BUF_SZ (VLAN_ETH_FRAME_LEN + NET_IP_ALIGN + 4) #define PKT_BUF_SZ (VLAN_ETH_FRAME_LEN + NET_IP_ALIGN + 4)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment