From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 09/17] net: cpsw: drop for_each_slave
Date: Fri, 22 Nov 2013 15:48:53 +0100 [thread overview]
Message-ID: <1385131741-28280-10-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1385131741-28280-1-git-send-email-s.hauer@pengutronix.de>
We currently only use one slave, so drop for_each_slave and hardcode
slave[0] until we pass the proper context to the functions that makes
this hack unnecessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/cpsw.c | 40 ++++++++++++++--------------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index d969654..fcb1f66 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -226,12 +226,6 @@ struct cpsw_priv {
struct cpdma_chan rx_chan, tx_chan;
struct cpsw_slave *slaves;
-#define for_each_slave(priv, func, arg...) \
- do { \
- int idx; \
- for (idx = 0; idx < (priv)->num_slaves; idx++) \
- (func)((priv)->slaves + idx, ##arg); \
- } while (0)
};
static int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
@@ -540,16 +534,6 @@ static inline void soft_reset(struct cpsw_priv *priv, void *reg)
((mac)[2] << 16) | ((mac)[3] << 24))
#define mac_lo(mac) (((mac)[4] << 0) | ((mac)[5] << 8))
-static void cpsw_set_slave_mac(struct cpsw_slave *slave,
- struct cpsw_priv *priv,
- unsigned char *mac)
-{
- dev_dbg(priv->dev, "* %s\n", __func__);
-
- writel(mac_hi(mac), &slave->regs->sa_hi);
- writel(mac_lo(mac), &slave->regs->sa_lo);
-}
-
static int cpsw_get_hwaddr(struct eth_device *edev, unsigned char *mac)
{
struct cpsw_priv *priv = edev->priv;
@@ -562,12 +546,14 @@ static int cpsw_get_hwaddr(struct eth_device *edev, unsigned char *mac)
static int cpsw_set_hwaddr(struct eth_device *edev, unsigned char *mac)
{
struct cpsw_priv *priv = edev->priv;
+ struct cpsw_slave *slave = &priv->slaves[0];
dev_dbg(priv->dev, "* %s\n", __func__);
memcpy(&priv->mac_addr, mac, sizeof(priv->mac_addr));
- for_each_slave(priv, cpsw_set_slave_mac, priv, mac);
+ writel(mac_hi(mac), &slave->regs->sa_hi);
+ writel(mac_lo(mac), &slave->regs->sa_lo);
return 0;
}
@@ -615,22 +601,25 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
slave->mac_control = mac_control;
}
-static int cpsw_update_link(struct cpsw_priv *priv)
+static int cpsw_update_link(struct cpsw_slave *slave, struct cpsw_priv *priv)
{
int link = 0;
dev_dbg(priv->dev, "* %s\n", __func__);
- for_each_slave(priv, cpsw_slave_update_link, priv, &link);
+ cpsw_slave_update_link(slave, priv, &link);
+
return link;
}
-static void cpsw_adjust_link(struct eth_device *edev) {
+static void cpsw_adjust_link(struct eth_device *edev)
+{
struct cpsw_priv *priv = edev->priv;
+ struct cpsw_slave *slave = &priv->slaves[0];
dev_dbg(priv->dev, "* %s\n", __func__);
- cpsw_update_link(priv);
+ cpsw_update_link(slave, priv);
}
static inline u32 cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num)
@@ -803,9 +792,8 @@ static int cpsw_open(struct eth_device *edev)
ALE_SECURE);
cpsw_ale_add_mcast(priv, ethbdaddr, 1 << priv->host_port);
- for_each_slave(priv, cpsw_slave_init, priv);
-
- cpsw_update_link(priv);
+ cpsw_slave_init(&priv->slaves[0], priv);
+ cpsw_update_link(&priv->slaves[0], priv);
/* init descriptor pool */
for (i = 0; i < NUM_DESCS; i++) {
@@ -1044,7 +1032,7 @@ int cpsw_probe(struct device_d *dev)
priv->data = *data;
priv->num_slaves = data->num_slaves;
priv->slaves = xzalloc(sizeof(struct cpsw_slave) * priv->num_slaves);
- for_each_slave(priv, cpsw_slave_init_data, idx, priv);
+ cpsw_slave_init_data(&priv->slaves[0], 0, priv);
}
priv->channels = 8;
@@ -1118,7 +1106,7 @@ int cpsw_probe(struct device_d *dev)
mdiobus_register(&priv->miibus);
- for_each_slave(priv, cpsw_slave_setup, idx, priv);
+ cpsw_slave_setup(&priv->slaves[0], 0, priv);
return 0;
}
--
1.8.4.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-11-22 14:49 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 14:48 Add devicetree support to OMAP drivers Sascha Hauer
2013-11-22 14:48 ` [PATCH 01/17] serial: ns16550: Add device ids for omap Sascha Hauer
2013-11-22 14:48 ` [PATCH 02/17] pinctrl: Add pinctrl-single driver Sascha Hauer
2013-11-22 14:48 ` [PATCH 03/17] spi: omap: encode register offset into device_id Sascha Hauer
2013-11-22 14:48 ` [PATCH 04/17] spi: omap: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 05/17] i2c: omap: Add devicetree support Sascha Hauer
2013-11-22 14:48 ` [PATCH 06/17] net: cpsw: inline slave_data Sascha Hauer
2013-11-22 14:48 ` [PATCH 07/17] cpsw: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 08/17] net: cpsw: move eth_device into slave Sascha Hauer
2013-11-22 14:48 ` Sascha Hauer [this message]
2013-11-22 14:48 ` [PATCH 10/17] net: cpsw: attach slave to edev->priv Sascha Hauer
2013-11-22 14:48 ` [PATCH 11/17] net: cpsw: straighten error path Sascha Hauer
2013-11-22 14:48 ` [PATCH 12/17] gpio: omap: move to drivers/gpio/ Sascha Hauer
2013-11-22 14:48 ` [PATCH 13/17] omap: gpmc: some refactoring Sascha Hauer
2013-11-22 14:48 ` [PATCH 14/17] gpio: omap: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 15/17] mtd: omap gpmc: Use dev_add_param_enum Sascha Hauer
2013-11-22 14:49 ` [PATCH 16/17] bus: Add omap gpmc driver Sascha Hauer
2013-11-22 14:49 ` [PATCH 17/17] mmc: omap: Add devicetree support Sascha Hauer
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=1385131741-28280-10-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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