diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2015-02-26 20:34:14 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-04 15:40:54 -0500 |
commit | 3365711df024f60d2e1e0ba9b40b6e965ab83bf6 (patch) | |
tree | e0d9b2b4a420e20cc02f0465b3d11b0e88cf2c6b /drivers/net/ethernet/renesas/sh_eth.h | |
parent | 25b77ad774a88cd7a9a8f63e122d4bda68479267 (diff) | |
download | op-kernel-dev-3365711df024f60d2e1e0ba9b40b6e965ab83bf6.zip op-kernel-dev-3365711df024f60d2e1e0ba9b40b6e965ab83bf6.tar.gz |
sh_eth: WARN on access to a register not implemented in a particular chip
Currently we may silently read/write a register at offset 0. Change
this to WARN and then ignore the write or read-back all-ones.
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/renesas/sh_eth.h')
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.h b/drivers/net/ethernet/renesas/sh_eth.h index 259d03f..33a360c 100644 --- a/drivers/net/ethernet/renesas/sh_eth.h +++ b/drivers/net/ethernet/renesas/sh_eth.h @@ -543,19 +543,29 @@ static inline void sh_eth_soft_swap(char *src, int len) #endif } +#define SH_ETH_OFFSET_INVALID ((u16) ~0) + static inline void sh_eth_write(struct net_device *ndev, u32 data, int enum_index) { struct sh_eth_private *mdp = netdev_priv(ndev); + u16 offset = mdp->reg_offset[enum_index]; + + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) + return; - iowrite32(data, mdp->addr + mdp->reg_offset[enum_index]); + iowrite32(data, mdp->addr + offset); } static inline u32 sh_eth_read(struct net_device *ndev, int enum_index) { struct sh_eth_private *mdp = netdev_priv(ndev); + u16 offset = mdp->reg_offset[enum_index]; + + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID)) + return ~0U; - return ioread32(mdp->addr + mdp->reg_offset[enum_index]); + return ioread32(mdp->addr + offset); } static inline void *sh_eth_tsu_get_offset(struct sh_eth_private *mdp, |