From: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
To: linux-sh@vger.kernel.org
Subject: Re: [RFC, PATCH 1/4] net: sh_eth: modify the definitions of register
Date: Thu, 17 Feb 2011 00:21:43 +0000 [thread overview]
Message-ID: <AANLkTimvaLOuBXcqJ=co1LakTxJqGEUQC3Cif+wBoJhm@mail.gmail.com> (raw)
In-Reply-To: <4D5A67CC.80107@renesas.com>
2011/2/15 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>:
> The previous code cannot handle the ETHER and GETHER both as same time
> because the definitions of register was hardcoded.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> arch/sh/include/asm/sh_eth.h | 7 +
> drivers/net/sh_eth.c | 322 +++++++++++-----------
> drivers/net/sh_eth.h | 623 ++++++++++++++++++++++++------------------
> 3 files changed, 537 insertions(+), 415 deletions(-)
>
<snip>
>
> +static const u16 *sh_eth_get_register_offset(int register_type)
> +{
> + const u16 *reg_offset = NULL;
> +
> + switch (register_type) {
> + case SH_ETH_REG_GIGABIT:
> + reg_offset = sh_eth_offset_gigabit;
> + break;
> + case SH_ETH_REG_FAST_SH4:
> + reg_offset = sh_eth_offset_fast_sh4;
> + break;
> + case SH_ETH_REG_FAST_SH3_SH2:
> + reg_offset = sh_eth_offset_fast_sh3_sh2;
> + break;
> + case SH_ETH_REG_DEFAULT:
> +#if defined(CONFIG_CPU_SUBTYPE_SH7763)
> + reg_offset = sh_eth_offset_gigabit;
> +#elif defined(CONFIG_CPU_SH4)
> + reg_offset = sh_eth_offset_fast_sh4;
> +#else
> + reg_offset = sh_eth_offset_fast_sh3_sh2;
> +#endif
> + break;
> + default:
> + printk(KERN_ERR "Unknown register type (%d)\n", register_type);
> + break;
> + }
> +
> + return reg_offset;
> +}
> +
Is the handling of SH_ETH_REG_DEFAULT necessary?
>
> +static inline void sh_eth_write(struct net_device *ndev, unsigned long data,
> + int enum_index)
> +{
> + struct sh_eth_private *mdp = netdev_priv(ndev);
> +
> + writel(data, ndev->base_addr + mdp->reg_offset[enum_index]);
> +}
> +
> +static inline unsigned long sh_eth_read(struct net_device *ndev,
> + int enum_index)
> +{
> + struct sh_eth_private *mdp = netdev_priv(ndev);
> +
> + return readl(ndev->base_addr + mdp->reg_offset[enum_index]);
> +}
> +
> +static inline void sh_eth_tsu_write(struct sh_eth_private *mdp,
> + unsigned long data, int enum_index)
> +{
> + writel(data, mdp->tsu_addr + mdp->reg_offset[enum_index]);
> +}
> +
> +static inline unsigned long sh_eth_tsu_read(struct sh_eth_private *mdp,
> + int enum_index)
> +{
> + return readl(mdp->tsu_addr + mdp->reg_offset[enum_index]);
> +}
> +
> #endif /* #ifndef __SH_ETH_H__ */
I do not think that a new function is necessary.
I think it use MACRO.
For example,
#define sh_eth_write(data,reg) \
{\
writel(data, ndev->base_addr + mdp->reg_offset[reg]); \
}
Best regards,
Nobuhiro
--
Nobuhiro Iwamatsu
iwamatsu at {nigauri.org / debian.org}
GPG ID: 40AD1FA6
next prev parent reply other threads:[~2011-02-17 0:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 11:47 [RFC, PATCH 1/4] net: sh_eth: modify the definitions of register Yoshihiro Shimoda
2011-02-17 0:21 ` Nobuhiro Iwamatsu [this message]
2011-02-17 0:56 ` Nobuhiro Iwamatsu
2011-02-17 6:51 ` Yoshihiro Shimoda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTimvaLOuBXcqJ=co1LakTxJqGEUQC3Cif+wBoJhm@mail.gmail.com' \
--to=iwamatsu@nigauri.org \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).