Re: [PATCH 1/2] Blackfin EMAC Driver: code cleanup

Previous thread: none

Next thread: [PATCH 1/1] [INPUT/KEYBOARD] Blackfin BF54x: Add infrastructure for keypad wakeups by Bryan Wu on Thursday, April 24, 2008 - 11:55 pm. (3 messages)
To: <jeff@...>, <netdev@...>, <linux-kernel@...>
Date: Thursday, April 24, 2008 - 11:53 pm

--

To: <jeff@...>, <netdev@...>, <linux-kernel@...>
Cc: Bryan Wu <cooloney@...>
Date: Thursday, April 24, 2008 - 11:53 pm

Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
drivers/net/bfin_mac.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index fdd361c..8762b96 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -27,6 +27,7 @@
#include <linux/phy.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
+#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/platform_device.h>

@@ -453,6 +454,51 @@ static int mii_probe(struct net_device *dev)
return 0;
}

+/*
+ * Ethtool support
+ */
+
+static int
+bfin_mac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ struct bfin_mac_local *lp = netdev_priv(dev);
+
+ if (lp->phydev)
+ return phy_ethtool_gset(lp->phydev, cmd);
+
+ return -EINVAL;
+}
+
+static int
+bfin_mac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ struct bfin_mac_local *lp = netdev_priv(dev);
+
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+
+ if (lp->phydev)
+ return phy_ethtool_sset(lp->phydev, cmd);
+
+ return -EINVAL;
+}
+
+static void bfin_mac_ethtool_getdrvinfo(struct net_device *dev,
+ struct ethtool_drvinfo *info)
+{
+ strcpy(info->driver, DRV_NAME);
+ strcpy(info->version, DRV_VERSION);
+ strcpy(info->fw_version, "N/A");
+ strcpy(info->bus_info, dev->dev.bus_id);
+}
+
+static struct ethtool_ops bfin_mac_ethtool_ops = {
+ .get_settings = bfin_mac_ethtool_getsettings,
+ .set_settings = bfin_mac_ethtool_setsettings,
+ .get_link = ethtool_op_get_link,
+ .get_drvinfo = bfin_mac_ethtool_getdrvinfo,
+};
+
/**************************************************************************/
void setup_system_regs(struct net_device *dev)
{
@@ -996,6 +1042,7 @@ static int __init bfin_mac_probe(struct platform_device *pdev)
#ifdef CONFIG_NET_POLL_CONTROLLER
ndev-&gt...

To: <jeff@...>, <netdev@...>, <linux-kernel@...>
Cc: Bryan Wu <cooloney@...>
Date: Thursday, April 24, 2008 - 11:53 pm

- replace specific "bf537" function or data structure name to "bfin_mac"
- cleanup bfin_mac_probe with error checking
- punt set_pin_mux function, call peripheral request/free list functions directly

Signed-off-by: Bryan Wu <cooloney@kernel.org>
---
drivers/net/bfin_mac.c | 249 ++++++++++++++++++++++++------------------------
drivers/net/bfin_mac.h | 2 +-
2 files changed, 124 insertions(+), 127 deletions(-)

diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 717dcc1..fdd361c 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -42,7 +42,7 @@
#define DRV_NAME "bfin_mac"
#define DRV_VERSION "1.1"
#define DRV_AUTHOR "Bryan Wu, Luke Yang"
-#define DRV_DESC "Blackfin BF53[67] BF527 on-chip Ethernet MAC driver"
+#define DRV_DESC "Blackfin on-chip Ethernet MAC driver"

MODULE_AUTHOR(DRV_AUTHOR);
MODULE_LICENSE("GPL");
@@ -72,8 +72,14 @@ static struct net_dma_desc_tx *current_tx_ptr;
static struct net_dma_desc_tx *tx_desc;
static struct net_dma_desc_rx *rx_desc;

-static void bf537mac_disable(void);
-static void bf537mac_enable(void);
+#if defined(CONFIG_BFIN_MAC_RMII)
+static u16 pin_req[] = P_RMII0;
+#else
+static u16 pin_req[] = P_MII0;
+#endif
+
+static void bfin_mac_disable(void);
+static void bfin_mac_enable(void);

static void desc_list_free(void)
{
@@ -242,27 +248,6 @@ init_error:

/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/

-/* Set FER regs to MUX in Ethernet pins */
-static int setup_pin_mux(int action)
-{
-#if defined(CONFIG_BFIN_MAC_RMII)
- u16 pin_req[] = P_RMII0;
-#else
- u16 pin_req[] = P_MII0;
-#endif
-
- if (action) {
- if (peripheral_request_list(pin_req, DRV_NAME)) {
- printk(KERN_ERR DRV_NAME
- ": Requesting Peripherals failed\n");
- return -EFAULT;
- }
- } else
- peripheral_free_list(pin_req);
-
- return 0;
-}
-
/*
* MII operations
*/
@@ -321,9 +306,9 @@ static int mdiobus_reset(struct mii_bus *bus)
return 0;
}

-st...

To: Bryan Wu <cooloney@...>
Cc: <netdev@...>, <linux-kernel@...>
Date: Tuesday, April 29, 2008 - 1:59 am

applied 1-2

--

Previous thread: none

Next thread: [PATCH 1/1] [INPUT/KEYBOARD] Blackfin BF54x: Add infrastructure for keypad wakeups by Bryan Wu on Thursday, April 24, 2008 - 11:55 pm. (3 messages)