[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <54FF4E1F.7050508@cogentembedded.com>
Date: Tue, 10 Mar 2015 23:03:43 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Ben Dooks <ben.dooks@...ethink.co.uk>,
Ben Hutchings <ben.hutchings@...ethink.co.uk>,
Geert Uytterhoeven <geert@...ux-m68k.org>
CC: linux-kernel@...ts.codethink.co.uk,
Yoshihiro Kaneko <ykaneko0929@...il.com>,
Mitsuhiro Kimura <mitsuhiro.kimura.kc@...esas.com>,
netdev@...r.kernel.org,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@...esas.com>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [Linux-kernel] [net-next, 2/5] sh_eth: WARN on access to a register
not implemented in a particular chip
Hello.
On 03/09/2015 11:50 AM, Ben Dooks wrote:
>>>> 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@...ethink.co.uk>
>>>> Acked-by: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
>>> While this may be a good idea for debugging...
>>>> --- 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);
> does de-referencing this each time make a difference? Looks like
It's not a dereference, it's just a pointer addition.
> it would have been easier to pass an "struct sh_eth_private" instead
> of the "struct net_device *ndev"
Hm, maybe...
>>>> + u16 offset = mdp->reg_offset[enum_index];
>>>> +
>>>> + if (WARN_ON(offset == SH_ETH_OFFSET_INVALID))
>>>> + return;
> You could cange the mdp->reg_offset to an mdp->reg_pointer and make
> any invalid registers a NULL. This would at-least make it fail on an
> invalid access.
Interesting idea...
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists