* [PATCH v5 0/8] sh_eth: deal with #ifdef'fery
@ 2013-06-06 19:39 Sergei Shtylyov
2013-06-06 19:43 ` [PATCH v5 1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions Sergei Shtylyov
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:39 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
Hello.
This series of 8 patches are against Dave's 'net-next.git' repository.
The series deals mostly with excess #ifdef'fery in the 'sh_eth' driver.
It doesn't yet get rid of all the #ifdef'fery but that's a matter of another
patchset. The last patch (it was almost in the middle of the series before),
contrariwise, adds one missing #ifdef...
[1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions
[2/8] sh_eth: use EDSR_ENALL to set EDSR
[3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions
[4/8] sh_eth: remove SH_ETH_HAS_TSU
[5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data'
[6/8] sh_eth: remove #ifdef around sh_eth_select_mii()
[7/8] sh_eth: consolidate sh_eth_reset()
[8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM
WBR, Sergei
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
@ 2013-06-06 19:43 ` Sergei Shtylyov
2013-06-06 19:44 ` [PATCH v5 2/8] sh_eth: use EDSR_ENALL to set EDSR Sergei Shtylyov
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:43 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Remove #ifdef around 'enum EDSR_BIT' and 'enum GECMR_BIT', replacing it with the
comments on which SoCs these registers exist.
SH7757 also has EDSR, so add a comment about it to 'enum EDSR_BIT'.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: folded in the former patch #2, updated the changelog, reworded the
subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 5:
- expanded the changelog.
Changes in version 4:
- folded in the former patch #2, updated the changelog accordingly;
- reworded the subject, changing the prefix.
Changes in version 3:
- fix comment.
drivers/net/ethernet/renesas/sh_eth.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.h
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.h
+++ net-next/drivers/net/ethernet/renesas/sh_eth.h
@@ -166,19 +166,16 @@ enum {
/*
* Register's bits
*/
-#if defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763) ||\
- defined(CONFIG_ARCH_R8A7740)
-/* EDSR */
+/* EDSR : sh7734, sh7757, sh7763, and r8a7740 only */
enum EDSR_BIT {
EDSR_ENT = 0x01, EDSR_ENR = 0x02,
};
#define EDSR_ENALL (EDSR_ENT|EDSR_ENR)
-/* GECMR */
+/* GECMR : sh7734, sh7763 and r8a7740 only */
enum GECMR_BIT {
GECMR_10 = 0x0, GECMR_100 = 0x04, GECMR_1000 = 0x01,
};
-#endif
/* EDMR */
enum DMAC_M_BIT {
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 2/8] sh_eth: use EDSR_ENALL to set EDSR
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
2013-06-06 19:43 ` [PATCH v5 1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions Sergei Shtylyov
@ 2013-06-06 19:44 ` Sergei Shtylyov
2013-06-06 19:45 ` [PATCH v5 3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions Sergei Shtylyov
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:44 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Use now always available EDSR_ENALL instead of the bare number to set EDSR.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: added the changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 4:
- added the changelog;
- reworded the subject, changing the prefix.
drivers/net/ethernet/renesas/sh_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -523,7 +523,7 @@ static int sh_eth_reset(struct net_devic
int ret = 0;
if (sh_eth_is_gether(mdp)) {
- sh_eth_write(ndev, 0x03, EDSR);
+ sh_eth_write(ndev, EDSR_ENALL, EDSR);
sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER,
EDMR);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
2013-06-06 19:43 ` [PATCH v5 1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions Sergei Shtylyov
2013-06-06 19:44 ` [PATCH v5 2/8] sh_eth: use EDSR_ENALL to set EDSR Sergei Shtylyov
@ 2013-06-06 19:45 ` Sergei Shtylyov
2013-06-06 19:48 ` [PATCH v5 4/8] sh_eth: remove SH_ETH_HAS_TSU Sergei Shtylyov
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:45 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Remove all the duplicate definitions of sh_eth_set_duplex() under different
#ifdef's, leaving only one outside the #ifdef's. We have to annotate it with
'__maybe_unused' since it's called not from all SoC #ifdef blocks.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: annotated sh_eth_set_duplex() as '__maybe_unused', added the changelog,
reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 4:
- annotated sh_eth_set_duplex() as '__maybe_unused';
- refreshed the patch;
- added the changelog;
- reworded the subject, changing the prefix.
Changes in version 3:
- remove empty sh_eth_set_duplex() for SH7619, SH7710 and SH7712 cases.
drivers/net/ethernet/renesas/sh_eth.c | 59 ++--------------------------------
1 file changed, 5 insertions(+), 54 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -341,10 +341,7 @@ static void sh_eth_select_mii(struct net
}
#endif
-/* There is CPU dependent code */
-#if defined(CONFIG_ARCH_R8A7778) || defined(CONFIG_ARCH_R8A7779)
-#define SH_ETH_RESET_DEFAULT 1
-static void sh_eth_set_duplex(struct net_device *ndev)
+static void __maybe_unused sh_eth_set_duplex(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -354,6 +351,9 @@ static void sh_eth_set_duplex(struct net
sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR);
}
+/* There is CPU dependent code */
+#if defined(CONFIG_ARCH_R8A7778) || defined(CONFIG_ARCH_R8A7779)
+#define SH_ETH_RESET_DEFAULT 1
static void sh_eth_set_rate(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -391,15 +391,6 @@ static struct sh_eth_cpu_data sh_eth_my_
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
#define SH_ETH_RESET_DEFAULT 1
-static void sh_eth_set_duplex(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
-
- if (mdp->duplex) /* Full */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR);
- else /* Half */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR);
-}
static void sh_eth_set_rate(struct net_device *ndev)
{
@@ -443,16 +434,6 @@ static struct sh_eth_cpu_data sh_eth_my_
#define SH_ETH_HAS_TSU 1
static int sh_eth_check_reset(struct net_device *ndev);
-static void sh_eth_set_duplex(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
-
- if (mdp->duplex) /* Full */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR);
- else /* Half */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR);
-}
-
static void sh_eth_set_rate(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -552,16 +533,6 @@ out:
return ret;
}
-static void sh_eth_set_duplex_giga(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
-
- if (mdp->duplex) /* Full */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR);
- else /* Half */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR);
-}
-
static void sh_eth_set_rate_giga(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -584,7 +555,7 @@ static void sh_eth_set_rate_giga(struct
/* SH7757(GETHERC) */
static struct sh_eth_cpu_data sh_eth_my_cpu_data_giga = {
.chip_reset = sh_eth_chip_reset_giga,
- .set_duplex = sh_eth_set_duplex_giga,
+ .set_duplex = sh_eth_set_duplex,
.set_rate = sh_eth_set_rate_giga,
.ecsr_value = ECSR_ICD | ECSR_MPD,
@@ -634,16 +605,6 @@ static void sh_eth_chip_reset(struct net
mdelay(1);
}
-static void sh_eth_set_duplex(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
-
- if (mdp->duplex) /* Full */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR);
- else /* Half */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR);
-}
-
static void sh_eth_set_rate(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -771,16 +732,6 @@ out:
return ret;
}
-static void sh_eth_set_duplex(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
-
- if (mdp->duplex) /* Full */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) | ECMR_DM, ECMR);
- else /* Half */
- sh_eth_write(ndev, sh_eth_read(ndev, ECMR) & ~ECMR_DM, ECMR);
-}
-
static void sh_eth_set_rate(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 4/8] sh_eth: remove SH_ETH_HAS_TSU
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
` (2 preceding siblings ...)
2013-06-06 19:45 ` [PATCH v5 3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions Sergei Shtylyov
@ 2013-06-06 19:48 ` Sergei Shtylyov
2013-06-06 19:49 ` [PATCH v5 5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data' Sergei Shtylyov
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:48 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Remove SH_ETH_HAS_TSU #define's and #ifdef's. Set three 'struct net_device_ops'
methods that depend on the presence of TSU basing on the 'tsu' field of 'struct
sh_eth_cpu_data'.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: made two method assignments one-liners, added the changelog, reworded
the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 4:
- made two method assignments one-liners;
- refreshed the patch;
- added the changelog;
- reworded the subject, changing the prefix.
drivers/net/ethernet/renesas/sh_eth.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -431,7 +431,6 @@ static struct sh_eth_cpu_data sh_eth_my_
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7757)
#define SH_ETH_HAS_BOTH_MODULES 1
-#define SH_ETH_HAS_TSU 1
static int sh_eth_check_reset(struct net_device *ndev);
static void sh_eth_set_rate(struct net_device *ndev)
@@ -592,7 +591,6 @@ static struct sh_eth_cpu_data *sh_eth_ge
}
#elif defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763)
-#define SH_ETH_HAS_TSU 1
static int sh_eth_check_reset(struct net_device *ndev);
static void sh_eth_reset_hw_crc(struct net_device *ndev);
@@ -693,7 +691,6 @@ static void sh_eth_reset_hw_crc(struct n
}
#elif defined(CONFIG_ARCH_R8A7740)
-#define SH_ETH_HAS_TSU 1
static int sh_eth_check_reset(struct net_device *ndev);
static void sh_eth_chip_reset(struct net_device *ndev)
@@ -791,7 +788,6 @@ static struct sh_eth_cpu_data sh_eth_my_
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
#define SH_ETH_RESET_DEFAULT 1
-#define SH_ETH_HAS_TSU 1
static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
.eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
.tsu = 1,
@@ -2105,7 +2101,6 @@ static int sh_eth_do_ioctl(struct net_de
return phy_mii_ioctl(phydev, rq, cmd);
}
-#if defined(SH_ETH_HAS_TSU)
/* For TSU_POSTn. Please refer to the manual about this (strange) bitfields */
static void *sh_eth_tsu_get_post_reg_offset(struct sh_eth_private *mdp,
int entry)
@@ -2448,7 +2443,6 @@ static int sh_eth_vlan_rx_kill_vid(struc
return 0;
}
-#endif /* SH_ETH_HAS_TSU */
/* SuperH's TSU register init function */
static void sh_eth_tsu_init(struct sh_eth_private *mdp)
@@ -2587,16 +2581,11 @@ static const u16 *sh_eth_get_register_of
return reg_offset;
}
-static const struct net_device_ops sh_eth_netdev_ops = {
+static struct net_device_ops sh_eth_netdev_ops = {
.ndo_open = sh_eth_open,
.ndo_stop = sh_eth_close,
.ndo_start_xmit = sh_eth_start_xmit,
.ndo_get_stats = sh_eth_get_stats,
-#if defined(SH_ETH_HAS_TSU)
- .ndo_set_rx_mode = sh_eth_set_multicast_list,
- .ndo_vlan_rx_add_vid = sh_eth_vlan_rx_add_vid,
- .ndo_vlan_rx_kill_vid = sh_eth_vlan_rx_kill_vid,
-#endif
.ndo_tx_timeout = sh_eth_tx_timeout,
.ndo_do_ioctl = sh_eth_do_ioctl,
.ndo_validate_addr = eth_validate_addr,
@@ -2677,6 +2666,13 @@ static int sh_eth_drv_probe(struct platf
sh_eth_set_default_cpu_data(mdp->cd);
/* set function */
+ if (mdp->cd->tsu) {
+ sh_eth_netdev_ops.ndo_set_rx_mode = sh_eth_set_multicast_list;
+ sh_eth_netdev_ops.ndo_vlan_rx_add_vid = sh_eth_vlan_rx_add_vid;
+ sh_eth_netdev_ops.ndo_vlan_rx_kill_vid =
+ sh_eth_vlan_rx_kill_vid;
+ }
+
ndev->netdev_ops = &sh_eth_netdev_ops;
SET_ETHTOOL_OPS(ndev, &sh_eth_ethtool_ops);
ndev->watchdog_timeo = TX_TIMEOUT;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data'
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
` (3 preceding siblings ...)
2013-06-06 19:48 ` [PATCH v5 4/8] sh_eth: remove SH_ETH_HAS_TSU Sergei Shtylyov
@ 2013-06-06 19:49 ` Sergei Shtylyov
2013-06-06 19:50 ` [PATCH v5 6/8] sh_eth: remove #ifdef around sh_eth_select_mii() Sergei Shtylyov
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:49 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
The driver supports some SH and SH-Mobile SOCs. There are SOCs with two or more
Ethernet devices, for these we need to pass IRQF_SHARED to request_irq(). Add
the 'irq_flags' field to the 'struct sh_eth_cpu_data' instead of #ifdef'fery.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: properly aligned request_irq() call continuation line, reworded the
changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 4:
- resolved reject;
- properly aligned request_irq() call continuation line;
- reworded the changelog;
- reworded the subject, changing the prefix.
Changes in version 3:
- remove 'irq_flags' from 'struct sh_eth_private';
- fix indentation.
drivers/net/ethernet/renesas/sh_eth.c | 13 +++++--------
drivers/net/ethernet/renesas/sh_eth.h | 1 +
2 files changed, 6 insertions(+), 8 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -462,6 +462,7 @@ static struct sh_eth_cpu_data sh_eth_my_
EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI,
.tx_error_check = EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE,
+ .irq_flags = IRQF_SHARED,
.apr = 1,
.mpr = 1,
.tpauser = 1,
@@ -570,6 +571,7 @@ static struct sh_eth_cpu_data sh_eth_my_
.fdr_value = 0x0000072f,
.rmcr_value = 0x00000001,
+ .irq_flags = IRQF_SHARED,
.apr = 1,
.mpr = 1,
.tpauser = 1,
@@ -650,6 +652,8 @@ static struct sh_eth_cpu_data sh_eth_my_
#if defined(CONFIG_CPU_SUBTYPE_SH7734)
.hw_crc = 1,
.select_mii = 1,
+#else
+ .irq_flags = IRQF_SHARED,
#endif
};
@@ -1908,14 +1912,7 @@ static int sh_eth_open(struct net_device
pm_runtime_get_sync(&mdp->pdev->dev);
ret = request_irq(ndev->irq, sh_eth_interrupt,
-#if defined(CONFIG_CPU_SUBTYPE_SH7763) || \
- defined(CONFIG_CPU_SUBTYPE_SH7764) || \
- defined(CONFIG_CPU_SUBTYPE_SH7757)
- IRQF_SHARED,
-#else
- 0,
-#endif
- ndev->name, ndev);
+ mdp->cd->irq_flags, ndev->name, ndev);
if (ret) {
dev_err(&ndev->dev, "Can not assign IRQ number\n");
return ret;
Index: net-next/drivers/net/ethernet/renesas/sh_eth.h
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.h
+++ net-next/drivers/net/ethernet/renesas/sh_eth.h
@@ -463,6 +463,7 @@ struct sh_eth_cpu_data {
unsigned long tx_error_check;
/* hardware features */
+ unsigned long irq_flags; /* IRQ configuration flags */
unsigned no_psr:1; /* EtherC DO NOT have PSR */
unsigned apr:1; /* EtherC have APR */
unsigned mpr:1; /* EtherC have MPR */
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 6/8] sh_eth: remove #ifdef around sh_eth_select_mii()
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
` (4 preceding siblings ...)
2013-06-06 19:49 ` [PATCH v5 5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data' Sergei Shtylyov
@ 2013-06-06 19:50 ` Sergei Shtylyov
2013-06-06 19:51 ` [PATCH v5 7/8] sh_eth: consolidate sh_eth_reset() Sergei Shtylyov
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:50 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
We can simply remove #ifdef'fery around sh_eth_select_mii(). We have to annotate
it with '__maybe_unused' then.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: added the changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 4:
- refreshed the patch;
- added the changelog;
- reworded the subject, changing the prefix.
Changes in version 3:
- annotated sh_eth_select_mii() with '__maybe_unused'.
drivers/net/ethernet/renesas/sh_eth.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -313,10 +313,7 @@ static const u16 sh_eth_offset_fast_sh3_
[TSU_ADRL31] = 0x01fc,
};
-#if defined(CONFIG_CPU_SUBTYPE_SH7734) || \
- defined(CONFIG_CPU_SUBTYPE_SH7763) || \
- defined(CONFIG_ARCH_R8A7740)
-static void sh_eth_select_mii(struct net_device *ndev)
+static void __maybe_unused sh_eth_select_mii(struct net_device *ndev)
{
u32 value = 0x0;
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -339,7 +336,6 @@ static void sh_eth_select_mii(struct net
sh_eth_write(ndev, value, RMII_MII);
}
-#endif
static void __maybe_unused sh_eth_set_duplex(struct net_device *ndev)
{
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 7/8] sh_eth: consolidate sh_eth_reset()
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
` (5 preceding siblings ...)
2013-06-06 19:50 ` [PATCH v5 6/8] sh_eth: remove #ifdef around sh_eth_select_mii() Sergei Shtylyov
@ 2013-06-06 19:51 ` Sergei Shtylyov
2013-06-06 19:52 ` [PATCH v5 8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM Sergei Shtylyov
2013-06-06 23:05 ` [PATCH v5 0/8] sh_eth: deal with #ifdef'fery David Miller
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:51 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
This driver has sh_eth_reset() function for each SoC and this function is almost
always the same, except for the several a bit different variations for Gigabit
Ethernet. Consolidate every variation into a single function -- which allows
us to get rid of some more #ifdef'fery.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: moved the new sh_eth_reset() and sh_eth_is_gether() up to decrease the
patch size, fixed function call continuation lines' indentation, reworded the
changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 5:
- moved sh_eth_is_gether() closer to the top of the file to fix the compilation
errors.
Changes in version 4:
- moved the new sh_eth_reset() up to decrease the patch size;
- fixed function call continuation lines' indentation;
- refreshed the patch;
- reworded the summary;
- reworded the subject, changing the prefix.
drivers/net/ethernet/renesas/sh_eth.c | 176 +++++++++-------------------------
1 file changed, 51 insertions(+), 125 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -313,6 +313,14 @@ static const u16 sh_eth_offset_fast_sh3_
[TSU_ADRL31] = 0x01fc,
};
+static int sh_eth_is_gether(struct sh_eth_private *mdp)
+{
+ if (mdp->reg_offset == sh_eth_offset_gigabit)
+ return 1;
+ else
+ return 0;
+}
+
static void __maybe_unused sh_eth_select_mii(struct net_device *ndev)
{
u32 value = 0x0;
@@ -349,7 +357,6 @@ static void __maybe_unused sh_eth_set_du
/* There is CPU dependent code */
#if defined(CONFIG_ARCH_R8A7778) || defined(CONFIG_ARCH_R8A7779)
-#define SH_ETH_RESET_DEFAULT 1
static void sh_eth_set_rate(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -386,7 +393,6 @@ static struct sh_eth_cpu_data sh_eth_my_
.hw_swap = 1,
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
-#define SH_ETH_RESET_DEFAULT 1
static void sh_eth_set_rate(struct net_device *ndev)
{
@@ -427,7 +433,6 @@ static struct sh_eth_cpu_data sh_eth_my_
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7757)
#define SH_ETH_HAS_BOTH_MODULES 1
-static int sh_eth_check_reset(struct net_device *ndev);
static void sh_eth_set_rate(struct net_device *ndev)
{
@@ -493,42 +498,6 @@ static void sh_eth_chip_reset_giga(struc
}
}
-static int sh_eth_is_gether(struct sh_eth_private *mdp);
-static int sh_eth_reset(struct net_device *ndev)
-{
- struct sh_eth_private *mdp = netdev_priv(ndev);
- int ret = 0;
-
- if (sh_eth_is_gether(mdp)) {
- sh_eth_write(ndev, EDSR_ENALL, EDSR);
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER,
- EDMR);
-
- ret = sh_eth_check_reset(ndev);
- if (ret)
- goto out;
-
- /* Table Init */
- sh_eth_write(ndev, 0x0, TDLAR);
- sh_eth_write(ndev, 0x0, TDFAR);
- sh_eth_write(ndev, 0x0, TDFXR);
- sh_eth_write(ndev, 0x0, TDFFR);
- sh_eth_write(ndev, 0x0, RDLAR);
- sh_eth_write(ndev, 0x0, RDFAR);
- sh_eth_write(ndev, 0x0, RDFXR);
- sh_eth_write(ndev, 0x0, RDFFR);
- } else {
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER,
- EDMR);
- mdelay(3);
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER,
- EDMR);
- }
-
-out:
- return ret;
-}
-
static void sh_eth_set_rate_giga(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -589,8 +558,6 @@ static struct sh_eth_cpu_data *sh_eth_ge
}
#elif defined(CONFIG_CPU_SUBTYPE_SH7734) || defined(CONFIG_CPU_SUBTYPE_SH7763)
-static int sh_eth_check_reset(struct net_device *ndev);
-static void sh_eth_reset_hw_crc(struct net_device *ndev);
static void sh_eth_chip_reset(struct net_device *ndev)
{
@@ -653,45 +620,8 @@ static struct sh_eth_cpu_data sh_eth_my_
#endif
};
-static int sh_eth_reset(struct net_device *ndev)
-{
- int ret = 0;
-
- sh_eth_write(ndev, EDSR_ENALL, EDSR);
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR);
-
- ret = sh_eth_check_reset(ndev);
- if (ret)
- goto out;
-
- /* Table Init */
- sh_eth_write(ndev, 0x0, TDLAR);
- sh_eth_write(ndev, 0x0, TDFAR);
- sh_eth_write(ndev, 0x0, TDFXR);
- sh_eth_write(ndev, 0x0, TDFFR);
- sh_eth_write(ndev, 0x0, RDLAR);
- sh_eth_write(ndev, 0x0, RDFAR);
- sh_eth_write(ndev, 0x0, RDFXR);
- sh_eth_write(ndev, 0x0, RDFFR);
-
- /* Reset HW CRC register */
- sh_eth_reset_hw_crc(ndev);
-
- /* Select MII mode */
- if (sh_eth_my_cpu_data.select_mii)
- sh_eth_select_mii(ndev);
-out:
- return ret;
-}
-
-static void sh_eth_reset_hw_crc(struct net_device *ndev)
-{
- if (sh_eth_my_cpu_data.hw_crc)
- sh_eth_write(ndev, 0x0, CSMR);
-}
#elif defined(CONFIG_ARCH_R8A7740)
-static int sh_eth_check_reset(struct net_device *ndev);
static void sh_eth_chip_reset(struct net_device *ndev)
{
@@ -704,31 +634,6 @@ static void sh_eth_chip_reset(struct net
sh_eth_select_mii(ndev);
}
-static int sh_eth_reset(struct net_device *ndev)
-{
- int ret = 0;
-
- sh_eth_write(ndev, EDSR_ENALL, EDSR);
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER, EDMR);
-
- ret = sh_eth_check_reset(ndev);
- if (ret)
- goto out;
-
- /* Table Init */
- sh_eth_write(ndev, 0x0, TDLAR);
- sh_eth_write(ndev, 0x0, TDFAR);
- sh_eth_write(ndev, 0x0, TDFXR);
- sh_eth_write(ndev, 0x0, TDFFR);
- sh_eth_write(ndev, 0x0, RDLAR);
- sh_eth_write(ndev, 0x0, RDFAR);
- sh_eth_write(ndev, 0x0, RDFXR);
- sh_eth_write(ndev, 0x0, RDFFR);
-
-out:
- return ret;
-}
-
static void sh_eth_set_rate(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -777,7 +682,6 @@ static struct sh_eth_cpu_data sh_eth_my_
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
-#define SH_ETH_RESET_DEFAULT 1
static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
.eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
@@ -787,7 +691,6 @@ static struct sh_eth_cpu_data sh_eth_my_
.hw_swap = 1,
};
#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
-#define SH_ETH_RESET_DEFAULT 1
static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
.eesipr_value = DMAC_M_RFRMER | DMAC_M_ECI | 0x003fffff,
.tsu = 1,
@@ -822,17 +725,6 @@ static void sh_eth_set_default_cpu_data(
cd->tx_error_check = DEFAULT_TX_ERROR_CHECK;
}
-#if defined(SH_ETH_RESET_DEFAULT)
-/* Chip Reset */
-static int sh_eth_reset(struct net_device *ndev)
-{
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER, EDMR);
- mdelay(3);
- sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER, EDMR);
-
- return 0;
-}
-#else
static int sh_eth_check_reset(struct net_device *ndev)
{
int ret = 0;
@@ -850,7 +742,49 @@ static int sh_eth_check_reset(struct net
}
return ret;
}
-#endif
+
+static int sh_eth_reset(struct net_device *ndev)
+{
+ struct sh_eth_private *mdp = netdev_priv(ndev);
+ int ret = 0;
+
+ if (sh_eth_is_gether(mdp)) {
+ sh_eth_write(ndev, EDSR_ENALL, EDSR);
+ sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_GETHER,
+ EDMR);
+
+ ret = sh_eth_check_reset(ndev);
+ if (ret)
+ goto out;
+
+ /* Table Init */
+ sh_eth_write(ndev, 0x0, TDLAR);
+ sh_eth_write(ndev, 0x0, TDFAR);
+ sh_eth_write(ndev, 0x0, TDFXR);
+ sh_eth_write(ndev, 0x0, TDFFR);
+ sh_eth_write(ndev, 0x0, RDLAR);
+ sh_eth_write(ndev, 0x0, RDFAR);
+ sh_eth_write(ndev, 0x0, RDFXR);
+ sh_eth_write(ndev, 0x0, RDFFR);
+
+ /* Reset HW CRC register */
+ if (mdp->cd->hw_crc)
+ sh_eth_write(ndev, 0x0, CSMR);
+
+ /* Select MII mode */
+ if (mdp->cd->select_mii)
+ sh_eth_select_mii(ndev);
+ } else {
+ sh_eth_write(ndev, sh_eth_read(ndev, EDMR) | EDMR_SRST_ETHER,
+ EDMR);
+ mdelay(3);
+ sh_eth_write(ndev, sh_eth_read(ndev, EDMR) & ~EDMR_SRST_ETHER,
+ EDMR);
+ }
+
+out:
+ return ret;
+}
#if defined(CONFIG_CPU_SH4) || defined(CONFIG_ARCH_SHMOBILE)
static void sh_eth_set_receive_align(struct sk_buff *skb)
@@ -926,14 +860,6 @@ static void read_mac_address(struct net_
}
}
-static int sh_eth_is_gether(struct sh_eth_private *mdp)
-{
- if (mdp->reg_offset == sh_eth_offset_gigabit)
- return 1;
- else
- return 0;
-}
-
static unsigned long sh_eth_get_edtrr_trns(struct sh_eth_private *mdp)
{
if (sh_eth_is_gether(mdp))
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v5 8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
` (6 preceding siblings ...)
2013-06-06 19:51 ` [PATCH v5 7/8] sh_eth: consolidate sh_eth_reset() Sergei Shtylyov
@ 2013-06-06 19:52 ` Sergei Shtylyov
2013-06-06 23:05 ` [PATCH v5 0/8] sh_eth: deal with #ifdef'fery David Miller
8 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-06 19:52 UTC (permalink / raw)
To: netdev; +Cc: nobuhiro.iwamatsu.yj, linux-sh
From: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Put '#ifdef CONFIG_PM' around sh_eth_runtime_nop() and 'sh_eth_dev_pm_ops'.
Add '#define SH_ETH_PM_OPS' to facilitate initialization of driver's 'pm' field
depending on whether CONFIG_PM is enabled.
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: added the changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
Changes in version 5:
-refreshed the patch.
Changes in version 4:
- refreshed the patch;
- added the changelog;
- reworded the subject, changing the prefix.
Changes in version 3:
- fixed "ERROR: Macros with complex values should be enclosed in parenthesis" by
scripts/checkpatch.pl.
drivers/net/ethernet/renesas/sh_eth.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -2673,6 +2673,7 @@ static int sh_eth_drv_remove(struct plat
return 0;
}
+#ifdef CONFIG_PM
static int sh_eth_runtime_nop(struct device *dev)
{
/*
@@ -2686,17 +2687,21 @@ static int sh_eth_runtime_nop(struct dev
return 0;
}
-static struct dev_pm_ops sh_eth_dev_pm_ops = {
+static const struct dev_pm_ops sh_eth_dev_pm_ops = {
.runtime_suspend = sh_eth_runtime_nop,
.runtime_resume = sh_eth_runtime_nop,
};
+#define SH_ETH_PM_OPS (&sh_eth_dev_pm_ops)
+#else
+#define SH_ETH_PM_OPS NULL
+#endif
static struct platform_driver sh_eth_driver = {
.probe = sh_eth_drv_probe,
.remove = sh_eth_drv_remove,
.driver = {
.name = CARDNAME,
- .pm = &sh_eth_dev_pm_ops,
+ .pm = SH_ETH_PM_OPS,
},
};
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 0/8] sh_eth: deal with #ifdef'fery
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
` (7 preceding siblings ...)
2013-06-06 19:52 ` [PATCH v5 8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM Sergei Shtylyov
@ 2013-06-06 23:05 ` David Miller
2013-06-07 12:24 ` Sergei Shtylyov
8 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2013-06-06 23:05 UTC (permalink / raw)
To: sergei.shtylyov; +Cc: netdev, nobuhiro.iwamatsu.yj, linux-sh
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date: Thu, 6 Jun 2013 23:39:20 +0400
> This series of 8 patches are against Dave's 'net-next.git' repository.
> The series deals mostly with excess #ifdef'fery in the 'sh_eth' driver.
> It doesn't yet get rid of all the #ifdef'fery but that's a matter of another
> patchset. The last patch (it was almost in the middle of the series before),
> contrariwise, adds one missing #ifdef...
>
> [1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions
> [2/8] sh_eth: use EDSR_ENALL to set EDSR
> [3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions
> [4/8] sh_eth: remove SH_ETH_HAS_TSU
> [5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data'
> [6/8] sh_eth: remove #ifdef around sh_eth_select_mii()
> [7/8] sh_eth: consolidate sh_eth_reset()
> [8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM
All applied, thanks.
I think you should have two sets of const netdev_ops to cover the two
cases, instead of writing to a non-const netdev_ops. Could you send a
follow-on patch which does that?
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v5 0/8] sh_eth: deal with #ifdef'fery
2013-06-06 23:05 ` [PATCH v5 0/8] sh_eth: deal with #ifdef'fery David Miller
@ 2013-06-07 12:24 ` Sergei Shtylyov
0 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2013-06-07 12:24 UTC (permalink / raw)
To: David Miller; +Cc: netdev, nobuhiro.iwamatsu.yj, linux-sh
Hello.
On 07-06-2013 3:05, David Miller wrote:
>> This series of 8 patches are against Dave's 'net-next.git' repository.
>> The series deals mostly with excess #ifdef'fery in the 'sh_eth' driver.
>> It doesn't yet get rid of all the #ifdef'fery but that's a matter of another
>> patchset. The last patch (it was almost in the middle of the series before),
>> contrariwise, adds one missing #ifdef...
>> [1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions
>> [2/8] sh_eth: use EDSR_ENALL to set EDSR
>> [3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions
>> [4/8] sh_eth: remove SH_ETH_HAS_TSU
>> [5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data'
>> [6/8] sh_eth: remove #ifdef around sh_eth_select_mii()
>> [7/8] sh_eth: consolidate sh_eth_reset()
>> [8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM
> All applied, thanks.
Thanks to you for quick reaction.
> I think you should have two sets of const netdev_ops to cover the two
> cases, instead of writing to a non-const netdev_ops. Could you send a
> follow-on patch which does that?
Sigh, I told Iwamatsu-san to do it, but he failed to respin the
patches. OK, I'll look into it later, when I have time.
> Thanks.
WBR, Sergei
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-06-07 12:24 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-06 19:39 [PATCH v5 0/8] sh_eth: deal with #ifdef'fery Sergei Shtylyov
2013-06-06 19:43 ` [PATCH v5 1/8] sh_eth: remove #ifdef around EDSR and GECMR bit definitions Sergei Shtylyov
2013-06-06 19:44 ` [PATCH v5 2/8] sh_eth: use EDSR_ENALL to set EDSR Sergei Shtylyov
2013-06-06 19:45 ` [PATCH v5 3/8] sh_eth: remove duplicate sh_eth_set_duplex() definitions Sergei Shtylyov
2013-06-06 19:48 ` [PATCH v5 4/8] sh_eth: remove SH_ETH_HAS_TSU Sergei Shtylyov
2013-06-06 19:49 ` [PATCH v5 5/8] sh_eth: add IRQ flags to 'struct sh_eth_cpu_data' Sergei Shtylyov
2013-06-06 19:50 ` [PATCH v5 6/8] sh_eth: remove #ifdef around sh_eth_select_mii() Sergei Shtylyov
2013-06-06 19:51 ` [PATCH v5 7/8] sh_eth: consolidate sh_eth_reset() Sergei Shtylyov
2013-06-06 19:52 ` [PATCH v5 8/8] sh_eth: enclose PM code into #ifdef CONFIG_PM Sergei Shtylyov
2013-06-06 23:05 ` [PATCH v5 0/8] sh_eth: deal with #ifdef'fery David Miller
2013-06-07 12:24 ` Sergei Shtylyov
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).