From: Matthias Kaehlcke <matthias@kaehlcke.net>
To: barebox@lists.infradead.org
Subject: [PATCH] ep93xx eth driver: Reorder functions to eliminate need for prototypes
Date: Mon, 1 Feb 2010 22:17:09 +0100 [thread overview]
Message-ID: <20100201211709.GO8053@darwin> (raw)
In-Reply-To: <339372749e251d51e46eedacfabaf293b59ca9f7.1265058811.git.matthias@kaehlcke.net>
ep93xx eth driver: Define ep93xx_eth_send_packet() and ep93xx_eth_rcv_packet()
before ep93xx_eth_probe(), and eliminate their prototype declarations
Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
---
drivers/net/ep93xx.c | 238 ++++++++++++++++++++++++-------------------------
1 files changed, 117 insertions(+), 121 deletions(-)
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index ac5d6fd..a63eac1 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -40,10 +40,6 @@
#include <mach/ep93xx-regs.h>
#include "ep93xx.h"
-static int ep93xx_eth_send_packet(struct eth_device *edev,
- void *packet, int length);
-static int ep93xx_eth_rcv_packet(struct eth_device *edev);
-
static int ep93xx_phy_read(struct miiphy_device *mdev, uint8_t phy_addr,
uint8_t phy_reg, uint16_t *value);
static int ep93xx_phy_write(struct miiphy_device *mdev, uint8_t phy_addr,
@@ -318,123 +314,6 @@ static void ep93xx_eth_halt(struct eth_device *edev)
pr_debug("-ep93xx_eth_halt\n");
}
-static int ep93xx_eth_get_ethaddr(struct eth_device *edev,
- unsigned char *mac_addr)
-{
- struct mac_regs *regs = ep93xx_get_regs(edev);
- uint32_t value;
-
- value = readl(®s->indad);
- mac_addr[0] = value & 0xFF;
- mac_addr[1] = (value >> 8) & 0xFF;
- mac_addr[2] = (value >> 16) & 0xFF;
- mac_addr[3] = (value >> 24) & 0xFF;
-
- value = readl(®s->indad_upper);
- mac_addr[4] = value & 0xFF;
- mac_addr[5] = (value >> 8) & 0xFF;
-
- return 0;
-}
-
-static int ep93xx_eth_set_ethaddr(struct eth_device *edev,
- unsigned char *mac_addr)
-{
- struct mac_regs *regs = ep93xx_get_regs(edev);
-
- writel(AFP_IAPRIMARY, ®s->afp);
-
- writel(mac_addr[0] | (mac_addr[1] << 8) |
- (mac_addr[2] << 16) | (mac_addr[3] << 24),
- ®s->indad);
- writel(mac_addr[4] | (mac_addr[5] << 8), ®s->indad_upper);
-
- return 0;
-}
-
-static int ep93xx_eth_probe(struct device_d *dev)
-{
- struct eth_device *edev;
- struct ep93xx_eth_priv *priv;
- int ret = -1;
-
- pr_debug("ep93xx_eth_probe()\n");
-
- edev = xzalloc(sizeof(struct eth_device) +
- sizeof(struct ep93xx_eth_priv));
- dev->type_data = edev;
- edev->priv = (struct ep93xx_eth_priv *)(edev + 1);
-
- priv = edev->priv;
- priv->regs = (struct mac_regs *)MAC_BASE;
-
- edev->init = ep93xx_eth_init_dev;
- edev->open = ep93xx_eth_open;
- edev->send = ep93xx_eth_send_packet;
- edev->recv = ep93xx_eth_rcv_packet;
- edev->halt = ep93xx_eth_halt;
- edev->get_ethaddr = ep93xx_eth_get_ethaddr;
- edev->set_ethaddr = ep93xx_eth_set_ethaddr;
-
- priv->miiphy.read = ep93xx_phy_read;
- priv->miiphy.write = ep93xx_phy_write;
- priv->miiphy.address = 0;
- priv->miiphy.flags = 0;
-
- priv->tx_dq.base = calloc(NUMTXDESC,
- sizeof(struct tx_descriptor));
- if (priv->tx_dq.base == NULL) {
- pr_err("calloc() failed: tx_dq.base");
- goto eth_probe_failed_0;
- }
-
- priv->tx_sq.base = calloc(NUMTXDESC,
- sizeof(struct tx_status));
- if (priv->tx_sq.base == NULL) {
- pr_err("calloc() failed: tx_sq.base");
- goto eth_probe_failed_1;
- }
-
- priv->rx_dq.base = calloc(NUMRXDESC,
- sizeof(struct rx_descriptor));
- if (priv->rx_dq.base == NULL) {
- pr_err("calloc() failed: rx_dq.base");
- goto eth_probe_failed_2;
- }
-
- priv->rx_sq.base = calloc(NUMRXDESC,
- sizeof(struct rx_status));
- if (priv->rx_sq.base == NULL) {
- pr_err("calloc() failed: rx_sq.base");
- goto eth_probe_failed_3;
- }
-
- miiphy_register(&priv->miiphy);
- eth_register(edev);
-
- ret = 0;
-
- goto eth_probe_done;
-
-eth_probe_failed_3:
- free(priv->rx_dq.base);
- /* Fall through */
-
-eth_probe_failed_2:
- free(priv->tx_sq.base);
- /* Fall through */
-
-eth_probe_failed_1:
- free(priv->tx_dq.base);
- /* Fall through */
-
-eth_probe_failed_0:
- /* Fall through */
-
-eth_probe_done:
- return ret;
-}
-
/**
* Copy a frame of data from the MAC into the protocol layer for further
* processing.
@@ -560,6 +439,123 @@ eth_send_failed_0:
return ret;
}
+static int ep93xx_eth_get_ethaddr(struct eth_device *edev,
+ unsigned char *mac_addr)
+{
+ struct mac_regs *regs = ep93xx_get_regs(edev);
+ uint32_t value;
+
+ value = readl(®s->indad);
+ mac_addr[0] = value & 0xFF;
+ mac_addr[1] = (value >> 8) & 0xFF;
+ mac_addr[2] = (value >> 16) & 0xFF;
+ mac_addr[3] = (value >> 24) & 0xFF;
+
+ value = readl(®s->indad_upper);
+ mac_addr[4] = value & 0xFF;
+ mac_addr[5] = (value >> 8) & 0xFF;
+
+ return 0;
+}
+
+static int ep93xx_eth_set_ethaddr(struct eth_device *edev,
+ unsigned char *mac_addr)
+{
+ struct mac_regs *regs = ep93xx_get_regs(edev);
+
+ writel(AFP_IAPRIMARY, ®s->afp);
+
+ writel(mac_addr[0] | (mac_addr[1] << 8) |
+ (mac_addr[2] << 16) | (mac_addr[3] << 24),
+ ®s->indad);
+ writel(mac_addr[4] | (mac_addr[5] << 8), ®s->indad_upper);
+
+ return 0;
+}
+
+static int ep93xx_eth_probe(struct device_d *dev)
+{
+ struct eth_device *edev;
+ struct ep93xx_eth_priv *priv;
+ int ret = -1;
+
+ pr_debug("ep93xx_eth_probe()\n");
+
+ edev = xzalloc(sizeof(struct eth_device) +
+ sizeof(struct ep93xx_eth_priv));
+ dev->type_data = edev;
+ edev->priv = (struct ep93xx_eth_priv *)(edev + 1);
+
+ priv = edev->priv;
+ priv->regs = (struct mac_regs *)MAC_BASE;
+
+ edev->init = ep93xx_eth_init_dev;
+ edev->open = ep93xx_eth_open;
+ edev->send = ep93xx_eth_send_packet;
+ edev->recv = ep93xx_eth_rcv_packet;
+ edev->halt = ep93xx_eth_halt;
+ edev->get_ethaddr = ep93xx_eth_get_ethaddr;
+ edev->set_ethaddr = ep93xx_eth_set_ethaddr;
+
+ priv->miiphy.read = ep93xx_phy_read;
+ priv->miiphy.write = ep93xx_phy_write;
+ priv->miiphy.address = 0;
+ priv->miiphy.flags = 0;
+
+ priv->tx_dq.base = calloc(NUMTXDESC,
+ sizeof(struct tx_descriptor));
+ if (priv->tx_dq.base == NULL) {
+ pr_err("calloc() failed: tx_dq.base");
+ goto eth_probe_failed_0;
+ }
+
+ priv->tx_sq.base = calloc(NUMTXDESC,
+ sizeof(struct tx_status));
+ if (priv->tx_sq.base == NULL) {
+ pr_err("calloc() failed: tx_sq.base");
+ goto eth_probe_failed_1;
+ }
+
+ priv->rx_dq.base = calloc(NUMRXDESC,
+ sizeof(struct rx_descriptor));
+ if (priv->rx_dq.base == NULL) {
+ pr_err("calloc() failed: rx_dq.base");
+ goto eth_probe_failed_2;
+ }
+
+ priv->rx_sq.base = calloc(NUMRXDESC,
+ sizeof(struct rx_status));
+ if (priv->rx_sq.base == NULL) {
+ pr_err("calloc() failed: rx_sq.base");
+ goto eth_probe_failed_3;
+ }
+
+ miiphy_register(&priv->miiphy);
+ eth_register(edev);
+
+ ret = 0;
+
+ goto eth_probe_done;
+
+eth_probe_failed_3:
+ free(priv->rx_dq.base);
+ /* Fall through */
+
+eth_probe_failed_2:
+ free(priv->tx_sq.base);
+ /* Fall through */
+
+eth_probe_failed_1:
+ free(priv->tx_dq.base);
+ /* Fall through */
+
+eth_probe_failed_0:
+ /* Fall through */
+
+eth_probe_done:
+ return ret;
+}
+
/* -----------------------------------------------------------------------------
* EP93xx ethernet MII functionality.
*/
--
1.6.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next parent reply other threads:[~2010-02-01 21:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <339372749e251d51e46eedacfabaf293b59ca9f7.1265058811.git.matthias@kaehlcke.net>
2010-02-01 21:17 ` Matthias Kaehlcke [this message]
2010-02-02 7:37 ` [PATCH] ep93xx eth driver: Reorder functions to eliminate need for prototypes 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=20100201211709.GO8053@darwin \
--to=matthias@kaehlcke.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.