git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
net
/
arm
/
at91_ether.c
diff --git
a/drivers/net/arm/at91_ether.c
b/drivers/net/arm/at91_ether.c
index
85493b7
..
fada15d
100644
(file)
--- a/
drivers/net/arm/at91_ether.c
+++ b/
drivers/net/arm/at91_ether.c
@@
-41,9
+41,6
@@
#define DRV_NAME "at91_ether"
#define DRV_VERSION "1.0"
#define DRV_NAME "at91_ether"
#define DRV_VERSION "1.0"
-static struct net_device *at91_dev;
-
-static struct timer_list check_timer;
#define LINK_POLL_INTERVAL (HZ)
/* ..................................................................... */
#define LINK_POLL_INTERVAL (HZ)
/* ..................................................................... */
@@
-146,7
+143,7
@@
static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
*/
static void update_linkspeed(struct net_device *dev, int silent)
{
*/
static void update_linkspeed(struct net_device *dev, int silent)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned int bmsr, bmcr, lpa, mac_cfg;
unsigned int speed, duplex;
unsigned int bmsr, bmcr, lpa, mac_cfg;
unsigned int speed, duplex;
@@
-196,10
+193,10
@@
static void update_linkspeed(struct net_device *dev, int silent)
/*
* Handle interrupts from the PHY
*/
/*
* Handle interrupts from the PHY
*/
-static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id
, struct pt_regs *regs
)
+static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
{
struct net_device *dev = (struct net_device *) dev_id;
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned int phy;
/*
unsigned int phy;
/*
@@
-242,7
+239,7
@@
done:
*/
static void enable_phyirq(struct net_device *dev)
{
*/
static void enable_phyirq(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned int dsintr, irq_number;
int status;
unsigned int dsintr, irq_number;
int status;
@@
-252,8
+249,7
@@
static void enable_phyirq(struct net_device *dev)
* PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
* or board does not have it connected.
*/
* PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
* or board does not have it connected.
*/
- check_timer.expires = jiffies + LINK_POLL_INTERVAL;
- add_timer(&check_timer);
+ mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
return;
}
return;
}
@@
-294,13
+290,13
@@
static void enable_phyirq(struct net_device *dev)
*/
static void disable_phyirq(struct net_device *dev)
{
*/
static void disable_phyirq(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned int dsintr;
unsigned int irq_number;
irq_number = lp->board_data.phy_irq_pin;
if (!irq_number) {
unsigned int dsintr;
unsigned int irq_number;
irq_number = lp->board_data.phy_irq_pin;
if (!irq_number) {
- del_timer_sync(&check_timer);
+ del_timer_sync(&
lp->
check_timer);
return;
}
return;
}
@@
-340,7
+336,7
@@
static void disable_phyirq(struct net_device *dev)
#if 0
static void reset_phy(struct net_device *dev)
{
#if 0
static void reset_phy(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned int bmcr;
spin_lock_irq(&lp->lock);
unsigned int bmcr;
spin_lock_irq(&lp->lock);
@@
-362,13
+358,13
@@
static void reset_phy(struct net_device *dev)
static void at91ether_check_link(unsigned long dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
static void at91ether_check_link(unsigned long dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
+ struct at91_private *lp = netdev_priv(dev);
enable_mdi();
update_linkspeed(dev, 1);
disable_mdi();
enable_mdi();
update_linkspeed(dev, 1);
disable_mdi();
- check_timer.expires = jiffies + LINK_POLL_INTERVAL;
- add_timer(&check_timer);
+ mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
}
/* ......................... ADDRESS MANAGEMENT ........................ */
}
/* ......................... ADDRESS MANAGEMENT ........................ */
@@
-590,7
+586,7
@@
static void mdio_write(struct net_device *dev, int phy_id, int location, int val
static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
int ret;
spin_lock_irq(&lp->lock);
int ret;
spin_lock_irq(&lp->lock);
@@
-611,7
+607,7
@@
static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm
static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
int ret;
spin_lock_irq(&lp->lock);
int ret;
spin_lock_irq(&lp->lock);
@@
-627,7
+623,7
@@
static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm
static int at91ether_nwayreset(struct net_device *dev)
{
static int at91ether_nwayreset(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
int ret;
spin_lock_irq(&lp->lock);
int ret;
spin_lock_irq(&lp->lock);
@@
-648,7
+644,7
@@
static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info));
}
strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info));
}
-static struct ethtool_ops at91ether_ethtool_ops = {
+static
const
struct ethtool_ops at91ether_ethtool_ops = {
.get_settings = at91ether_get_settings,
.set_settings = at91ether_set_settings,
.get_drvinfo = at91ether_get_drvinfo,
.get_settings = at91ether_get_settings,
.set_settings = at91ether_set_settings,
.get_drvinfo = at91ether_get_drvinfo,
@@
-658,7
+654,7
@@
static struct ethtool_ops at91ether_ethtool_ops = {
static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
int res;
if (!netif_running(dev))
int res;
if (!netif_running(dev))
@@
-680,7
+676,7
@@
static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
*/
static void at91ether_start(struct net_device *dev)
{
*/
static void at91ether_start(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
struct recv_desc_bufs *dlist, *dlist_phys;
int i;
unsigned long ctl;
struct recv_desc_bufs *dlist, *dlist_phys;
int i;
unsigned long ctl;
@@
-712,7
+708,7
@@
static void at91ether_start(struct net_device *dev)
*/
static int at91ether_open(struct net_device *dev)
{
*/
static int at91ether_open(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned long ctl;
if (!is_valid_ether_addr(dev->dev_addr))
unsigned long ctl;
if (!is_valid_ether_addr(dev->dev_addr))
@@
-752,7
+748,7
@@
static int at91ether_open(struct net_device *dev)
*/
static int at91ether_close(struct net_device *dev)
{
*/
static int at91ether_close(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned long ctl;
/* Disable Receiver and Transmitter */
unsigned long ctl;
/* Disable Receiver and Transmitter */
@@
-779,7
+775,7
@@
static int at91ether_close(struct net_device *dev)
*/
static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
{
*/
static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
netif_stop_queue(dev);
if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
netif_stop_queue(dev);
@@
-811,7
+807,7
@@
static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
*/
static struct net_device_stats *at91ether_stats(struct net_device *dev)
{
*/
static struct net_device_stats *at91ether_stats(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
int ale, lenerr, seqe, lcol, ecol;
if (netif_running(dev)) {
int ale, lenerr, seqe, lcol, ecol;
if (netif_running(dev)) {
@@
-847,7
+843,7
@@
static struct net_device_stats *at91ether_stats(struct net_device *dev)
*/
static void at91ether_rx(struct net_device *dev)
{
*/
static void at91ether_rx(struct net_device *dev)
{
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
struct recv_desc_bufs *dlist;
unsigned char *p_recv;
struct sk_buff *skb;
struct recv_desc_bufs *dlist;
unsigned char *p_recv;
struct sk_buff *skb;
@@
-857,14
+853,13
@@
static void at91ether_rx(struct net_device *dev)
while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
p_recv = dlist->recv_buf[lp->rxBuffIndex];
pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
p_recv = dlist->recv_buf[lp->rxBuffIndex];
pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
- skb =
alloc_skb(pktlen + 2, GFP_ATOMIC
);
+ skb =
dev_alloc_skb(pktlen + 2
);
if (skb != NULL) {
skb_reserve(skb, 2);
memcpy(skb_put(skb, pktlen), p_recv, pktlen);
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
if (skb != NULL) {
skb_reserve(skb, 2);
memcpy(skb_put(skb, pktlen), p_recv, pktlen);
skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
- skb->len = pktlen;
dev->last_rx = jiffies;
lp->stats.rx_bytes += pktlen;
netif_rx(skb);
dev->last_rx = jiffies;
lp->stats.rx_bytes += pktlen;
netif_rx(skb);
@@
-888,10
+883,10
@@
static void at91ether_rx(struct net_device *dev)
/*
* MAC interrupt handler
*/
/*
* MAC interrupt handler
*/
-static irqreturn_t at91ether_interrupt(int irq, void *dev_id
, struct pt_regs *regs
)
+static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
{
struct net_device *dev = (struct net_device *) dev_id;
- struct at91_private *lp =
(struct at91_private *) dev->priv
;
+ struct at91_private *lp =
netdev_priv(dev)
;
unsigned long intstatus, ctl;
/* MAC Interrupt Status register indicates what interrupts are pending.
unsigned long intstatus, ctl;
/* MAC Interrupt Status register indicates what interrupts are pending.
@@
-927,6
+922,17
@@
static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re
return IRQ_HANDLED;
}
return IRQ_HANDLED;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void at91ether_poll_controller(struct net_device *dev)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ at91ether_interrupt(dev->irq, dev);
+ local_irq_restore(flags);
+}
+#endif
+
/*
* Initialize the ethernet interface
*/
/*
* Initialize the ethernet interface
*/
@@
-939,15
+945,12
@@
static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
unsigned int val;
int res;
unsigned int val;
int res;
- if (at91_dev) /* already initialized */
- return 0;
-
dev = alloc_etherdev(sizeof(struct at91_private));
if (!dev)
return -ENOMEM;
dev->base_addr = AT91_VA_BASE_EMAC;
dev = alloc_etherdev(sizeof(struct at91_private));
if (!dev)
return -ENOMEM;
dev->base_addr = AT91_VA_BASE_EMAC;
- dev->irq = AT91_ID_EMAC;
+ dev->irq = AT91
RM9200
_ID_EMAC;
SET_MODULE_OWNER(dev);
/* Install the interrupt handler */
SET_MODULE_OWNER(dev);
/* Install the interrupt handler */
@@
-957,7
+960,7
@@
static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
}
/* Allocate memory for DMA Receive descriptors */
}
/* Allocate memory for DMA Receive descriptors */
- lp =
(struct at91_private *)dev->priv
;
+ lp =
netdev_priv(dev)
;
lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
if (lp->dlist == NULL) {
free_irq(dev->irq, dev);
lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
if (lp->dlist == NULL) {
free_irq(dev->irq, dev);
@@
-979,6
+982,9
@@
static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
dev->set_mac_address = set_mac_address;
dev->ethtool_ops = &at91ether_ethtool_ops;
dev->do_ioctl = at91ether_ioctl;
dev->set_mac_address = set_mac_address;
dev->ethtool_ops = &at91ether_ethtool_ops;
dev->do_ioctl = at91ether_ioctl;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ dev->poll_controller = at91ether_poll_controller;
+#endif
SET_NETDEV_DEV(dev, &pdev->dev);
SET_NETDEV_DEV(dev, &pdev->dev);
@@
-1024,7
+1030,6
@@
static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
return res;
}
dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
return res;
}
- at91_dev = dev;
/* Determine current link speed */
spin_lock_irq(&lp->lock);
/* Determine current link speed */
spin_lock_irq(&lp->lock);
@@
-1036,9
+1041,9
@@
static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
/* If board has no PHY IRQ, use a timer to poll the PHY */
if (!lp->board_data.phy_irq_pin) {
/* If board has no PHY IRQ, use a timer to poll the PHY */
if (!lp->board_data.phy_irq_pin) {
- init_timer(&check_timer);
- check_timer.data = (unsigned long)dev;
- check_timer.function = at91ether_check_link;
+ init_timer(&
lp->
check_timer);
+
lp->
check_timer.data = (unsigned long)dev;
+
lp->
check_timer.function = at91ether_check_link;
}
/* Display ethernet banner */
}
/* Display ethernet banner */
@@
-1115,15
+1120,16
@@
static int __init at91ether_probe(struct platform_device *pdev)
static int __devexit at91ether_remove(struct platform_device *pdev)
{
static int __devexit at91ether_remove(struct platform_device *pdev)
{
- struct at91_private *lp = (struct at91_private *) at91_dev->priv;
+ struct net_device *dev = platform_get_drvdata(pdev);
+ struct at91_private *lp = netdev_priv(dev);
- unregister_netdev(
at91_
dev);
- free_irq(
at91_dev->irq, at91_
dev);
+ unregister_netdev(dev);
+ free_irq(
dev->irq,
dev);
dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
clk_put(lp->ether_clk);
dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
clk_put(lp->ether_clk);
-
free_netdev(at91_dev
);
-
at91_dev = NULL
;
+
platform_set_drvdata(pdev, NULL
);
+
free_netdev(dev)
;
return 0;
}
return 0;
}
@@
-1131,8
+1137,8
@@
static int __devexit at91ether_remove(struct platform_device *pdev)
static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
{
static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
{
- struct at91_private *lp = (struct at91_private *) at91_dev->priv;
struct net_device *net_dev = platform_get_drvdata(pdev);
struct net_device *net_dev = platform_get_drvdata(pdev);
+ struct at91_private *lp = netdev_priv(net_dev);
int phy_irq = lp->board_data.phy_irq_pin;
if (netif_running(net_dev)) {
int phy_irq = lp->board_data.phy_irq_pin;
if (netif_running(net_dev)) {
@@
-1149,8
+1155,8
@@
static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
static int at91ether_resume(struct platform_device *pdev)
{
static int at91ether_resume(struct platform_device *pdev)
{
- struct at91_private *lp = (struct at91_private *) at91_dev->priv;
struct net_device *net_dev = platform_get_drvdata(pdev);
struct net_device *net_dev = platform_get_drvdata(pdev);
+ struct at91_private *lp = netdev_priv(net_dev);
int phy_irq = lp->board_data.phy_irq_pin;
if (netif_running(net_dev)) {
int phy_irq = lp->board_data.phy_irq_pin;
if (netif_running(net_dev)) {