Commit 307f6565 authored by Antoine Ténart's avatar Antoine Ténart Committed by David S. Miller

net: pxa168_eth: clean up

Clean up a bit the pxa168_eth driver before adding the device tree
support.
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@free-electrons.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4cb53f3f
...@@ -22,27 +22,29 @@ ...@@ -22,27 +22,29 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/dma-mapping.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/etherdevice.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/platform_device.h> #include <linux/in.h>
#include <linux/module.h> #include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/ip.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/workqueue.h> #include <linux/module.h>
#include <linux/clk.h> #include <linux/of.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/io.h> #include <linux/platform_device.h>
#include <linux/interrupt.h> #include <linux/pxa168_eth.h>
#include <linux/tcp.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/udp.h>
#include <linux/workqueue.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <linux/pxa168_eth.h>
#define DRIVER_NAME "pxa168-eth" #define DRIVER_NAME "pxa168-eth"
#define DRIVER_VERSION "0.3" #define DRIVER_VERSION "0.3"
...@@ -296,7 +298,7 @@ static void abort_dma(struct pxa168_eth_private *pep) ...@@ -296,7 +298,7 @@ static void abort_dma(struct pxa168_eth_private *pep)
} while (max_retries-- > 0 && delay <= 0); } while (max_retries-- > 0 && delay <= 0);
if (max_retries <= 0) if (max_retries <= 0)
printk(KERN_ERR "%s : DMA Stuck\n", __func__); netdev_err(pep->dev, "%s : DMA Stuck\n", __func__);
} }
static int ethernet_phy_get(struct pxa168_eth_private *pep) static int ethernet_phy_get(struct pxa168_eth_private *pep)
...@@ -507,9 +509,10 @@ static int add_del_hash_entry(struct pxa168_eth_private *pep, ...@@ -507,9 +509,10 @@ static int add_del_hash_entry(struct pxa168_eth_private *pep,
if (i == HOP_NUMBER) { if (i == HOP_NUMBER) {
if (!del) { if (!del) {
printk(KERN_INFO "%s: table section is full, need to " netdev_info(pep->dev,
"move to 16kB implementation?\n", "%s: table section is full, need to "
__FILE__); "move to 16kB implementation?\n",
__FILE__);
return -ENOSPC; return -ENOSPC;
} else } else
return 0; return 0;
...@@ -726,7 +729,7 @@ static int txq_reclaim(struct net_device *dev, int force) ...@@ -726,7 +729,7 @@ static int txq_reclaim(struct net_device *dev, int force)
if (cmd_sts & TX_ERROR) { if (cmd_sts & TX_ERROR) {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR "%s: Error in TX\n", dev->name); netdev_err(dev, "Error in TX\n");
dev->stats.tx_errors++; dev->stats.tx_errors++;
} }
dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE); dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE);
...@@ -743,8 +746,7 @@ static void pxa168_eth_tx_timeout(struct net_device *dev) ...@@ -743,8 +746,7 @@ static void pxa168_eth_tx_timeout(struct net_device *dev)
{ {
struct pxa168_eth_private *pep = netdev_priv(dev); struct pxa168_eth_private *pep = netdev_priv(dev);
printk(KERN_INFO "%s: TX timeout desc_count %d\n", netdev_info(dev, "TX timeout desc_count %d\n", pep->tx_desc_count);
dev->name, pep->tx_desc_count);
schedule_work(&pep->tx_timeout_task); schedule_work(&pep->tx_timeout_task);
} }
...@@ -814,9 +816,8 @@ static int rxq_process(struct net_device *dev, int budget) ...@@ -814,9 +816,8 @@ static int rxq_process(struct net_device *dev, int budget)
if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) != if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) !=
(RX_FIRST_DESC | RX_LAST_DESC)) { (RX_FIRST_DESC | RX_LAST_DESC)) {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR netdev_err(dev,
"%s: Rx pkt on multiple desc\n", "Rx pkt on multiple desc\n");
dev->name);
} }
if (cmd_sts & RX_ERROR) if (cmd_sts & RX_ERROR)
stats->rx_errors++; stats->rx_errors++;
...@@ -871,7 +872,7 @@ static void handle_link_event(struct pxa168_eth_private *pep) ...@@ -871,7 +872,7 @@ static void handle_link_event(struct pxa168_eth_private *pep)
port_status = rdl(pep, PORT_STATUS); port_status = rdl(pep, PORT_STATUS);
if (!(port_status & LINK_UP)) { if (!(port_status & LINK_UP)) {
if (netif_carrier_ok(dev)) { if (netif_carrier_ok(dev)) {
printk(KERN_INFO "%s: link down\n", dev->name); netdev_info(dev, "link down\n");
netif_carrier_off(dev); netif_carrier_off(dev);
txq_reclaim(dev, 1); txq_reclaim(dev, 1);
} }
...@@ -884,9 +885,8 @@ static void handle_link_event(struct pxa168_eth_private *pep) ...@@ -884,9 +885,8 @@ static void handle_link_event(struct pxa168_eth_private *pep)
duplex = (port_status & FULL_DUPLEX) ? 1 : 0; duplex = (port_status & FULL_DUPLEX) ? 1 : 0;
fc = (port_status & FLOW_CONTROL_ENABLED) ? 1 : 0; fc = (port_status & FLOW_CONTROL_ENABLED) ? 1 : 0;
printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, " netdev_info(dev, "link up, %d Mb/s, %s duplex, flow control %sabled\n",
"flow control %sabled\n", dev->name, speed, duplex ? "full" : "half", fc ? "en" : "dis");
speed, duplex ? "full" : "half", fc ? "en" : "dis");
if (!netif_carrier_ok(dev)) if (!netif_carrier_ok(dev))
netif_carrier_on(dev); netif_carrier_on(dev);
} }
...@@ -1039,9 +1039,8 @@ static void rxq_deinit(struct net_device *dev) ...@@ -1039,9 +1039,8 @@ static void rxq_deinit(struct net_device *dev)
} }
} }
if (pep->rx_desc_count) if (pep->rx_desc_count)
printk(KERN_ERR netdev_err(dev, "Error in freeing Rx Ring. %d skb's still\n",
"Error in freeing Rx Ring. %d skb's still\n", pep->rx_desc_count);
pep->rx_desc_count);
/* Free RX ring */ /* Free RX ring */
if (pep->p_rx_desc_area) if (pep->p_rx_desc_area)
dma_free_coherent(pep->dev->dev.parent, pep->rx_desc_area_size, dma_free_coherent(pep->dev->dev.parent, pep->rx_desc_area_size,
...@@ -1280,15 +1279,15 @@ static int pxa168_smi_read(struct mii_bus *bus, int phy_addr, int regnum) ...@@ -1280,15 +1279,15 @@ static int pxa168_smi_read(struct mii_bus *bus, int phy_addr, int regnum)
int val; int val;
if (smi_wait_ready(pep)) { if (smi_wait_ready(pep)) {
printk(KERN_WARNING "pxa168_eth: SMI bus busy timeout\n"); netdev_warn(pep->dev, "pxa168_eth: SMI bus busy timeout\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
wrl(pep, SMI, (phy_addr << 16) | (regnum << 21) | SMI_OP_R); wrl(pep, SMI, (phy_addr << 16) | (regnum << 21) | SMI_OP_R);
/* now wait for the data to be valid */ /* now wait for the data to be valid */
for (i = 0; !((val = rdl(pep, SMI)) & SMI_R_VALID); i++) { for (i = 0; !((val = rdl(pep, SMI)) & SMI_R_VALID); i++) {
if (i == PHY_WAIT_ITERATIONS) { if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_WARNING netdev_warn(pep->dev,
"pxa168_eth: SMI bus read not valid\n"); "pxa168_eth: SMI bus read not valid\n");
return -ENODEV; return -ENODEV;
} }
msleep(10); msleep(10);
...@@ -1303,7 +1302,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum, ...@@ -1303,7 +1302,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum,
struct pxa168_eth_private *pep = bus->priv; struct pxa168_eth_private *pep = bus->priv;
if (smi_wait_ready(pep)) { if (smi_wait_ready(pep)) {
printk(KERN_WARNING "pxa168_eth: SMI bus busy timeout\n"); netdev_warn(pep->dev, "pxa168_eth: SMI bus busy timeout\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -1311,7 +1310,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum, ...@@ -1311,7 +1310,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum,
SMI_OP_W | (value & 0xffff)); SMI_OP_W | (value & 0xffff));
if (smi_wait_ready(pep)) { if (smi_wait_ready(pep)) {
printk(KERN_ERR "pxa168_eth: SMI bus busy timeout\n"); netdev_err(pep->dev, "pxa168_eth: SMI bus busy timeout\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -1425,23 +1424,23 @@ static void pxa168_get_drvinfo(struct net_device *dev, ...@@ -1425,23 +1424,23 @@ static void pxa168_get_drvinfo(struct net_device *dev,
} }
static const struct ethtool_ops pxa168_ethtool_ops = { static const struct ethtool_ops pxa168_ethtool_ops = {
.get_settings = pxa168_get_settings, .get_settings = pxa168_get_settings,
.set_settings = pxa168_set_settings, .set_settings = pxa168_set_settings,
.get_drvinfo = pxa168_get_drvinfo, .get_drvinfo = pxa168_get_drvinfo,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_ts_info = ethtool_op_get_ts_info, .get_ts_info = ethtool_op_get_ts_info,
}; };
static const struct net_device_ops pxa168_eth_netdev_ops = { static const struct net_device_ops pxa168_eth_netdev_ops = {
.ndo_open = pxa168_eth_open, .ndo_open = pxa168_eth_open,
.ndo_stop = pxa168_eth_stop, .ndo_stop = pxa168_eth_stop,
.ndo_start_xmit = pxa168_eth_start_xmit, .ndo_start_xmit = pxa168_eth_start_xmit,
.ndo_set_rx_mode = pxa168_eth_set_rx_mode, .ndo_set_rx_mode = pxa168_eth_set_rx_mode,
.ndo_set_mac_address = pxa168_eth_set_mac_address, .ndo_set_mac_address = pxa168_eth_set_mac_address,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_do_ioctl = pxa168_eth_do_ioctl, .ndo_do_ioctl = pxa168_eth_do_ioctl,
.ndo_change_mtu = pxa168_eth_change_mtu, .ndo_change_mtu = pxa168_eth_change_mtu,
.ndo_tx_timeout = pxa168_eth_tx_timeout, .ndo_tx_timeout = pxa168_eth_tx_timeout,
}; };
static int pxa168_eth_probe(struct platform_device *pdev) static int pxa168_eth_probe(struct platform_device *pdev)
...@@ -1456,8 +1455,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) ...@@ -1456,8 +1455,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
clk = clk_get(&pdev->dev, "MFUCLK"); clk = clk_get(&pdev->dev, "MFUCLK");
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
printk(KERN_ERR "%s: Fast Ethernet failed to get clock\n", dev_err(&pdev->dev, "Fast Ethernet failed to get clock\n");
DRIVER_NAME);
return -ENODEV; return -ENODEV;
} }
clk_enable(clk); clk_enable(clk);
...@@ -1492,7 +1490,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) ...@@ -1492,7 +1490,7 @@ static int pxa168_eth_probe(struct platform_device *pdev)
INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task); INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task);
printk(KERN_INFO "%s:Using random mac address\n", DRIVER_NAME); dev_info(&pdev->dev, "Using random mac address\n");
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
pep->pd = dev_get_platdata(&pdev->dev); pep->pd = dev_get_platdata(&pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment