diff options
author | Hauke Mehrtens <hauke@openwrt.org> | 2009-11-28 22:09:18 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@openwrt.org> | 2009-11-28 22:09:18 +0000 |
commit | d4f45a44bd71cd5845b53a33097b0ad8d8a5c474 (patch) | |
tree | 484f4390c021833927dc8a75cce8bbb850f7abc2 /target/linux/amazon | |
parent | 0b5ddaebfff1466d7257ece15319ff9cab0e3193 (diff) | |
download | upstream-d4f45a44bd71cd5845b53a33097b0ad8d8a5c474.tar.gz upstream-d4f45a44bd71cd5845b53a33097b0ad8d8a5c474.tar.bz2 upstream-d4f45a44bd71cd5845b53a33097b0ad8d8a5c474.zip |
[amazon] Some general changes for amazon drivers.
This is mostly needed for kernel 2.6.30 support.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@18588 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/amazon')
4 files changed, 43 insertions, 42 deletions
diff --git a/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c b/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c index 3c58d2fea8..e06203d5b1 100644 --- a/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c +++ b/target/linux/amazon/files/drivers/char/watchdog/amazon_wdt.c @@ -222,7 +222,7 @@ int __init amazon_wdt_init_module(void) #endif amazon_wdt_isopen=0; - printk(KERN_INFO DRV_NAME "driver loaded but inactive"); + printk(KERN_INFO DRV_NAME "driver loaded but inactive\n"); return 0; } @@ -233,7 +233,7 @@ void amazon_wdt_cleanup_module(void) remove_proc_entry("wdt_register", amazon_wdt_dir); remove_proc_entry("amazon_wdt", NULL); #endif - printk(KERN_INFO DRV_NAME "unregistered"); + printk(KERN_INFO DRV_NAME "unregistered\n"); return; } diff --git a/target/linux/amazon/files/drivers/net/amazon_sw.c b/target/linux/amazon/files/drivers/net/amazon_sw.c index d19db6e36d..14d3a85079 100644 --- a/target/linux/amazon/files/drivers/net/amazon_sw.c +++ b/target/linux/amazon/files/drivers/net/amazon_sw.c @@ -105,10 +105,7 @@ module_param(timeout, int, 0); int switch_init(struct net_device *dev); void switch_tx_timeout(struct net_device *dev); -struct net_device switch_devs[2] = { - {init:switch_init,}, - {init:switch_init,} -}; +static struct net_device *switch_devs[2]; int add_mac_table_entry(u64 entry_value) { @@ -274,7 +271,7 @@ __setup("ethaddr=", ethaddr_setup); static void open_rx_dma(struct net_device *dev) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); struct dma_device_info *dma_dev = priv->dma_device; int i; @@ -286,7 +283,7 @@ static void open_rx_dma(struct net_device *dev) #ifdef CONFIG_NET_HW_FLOWCONTROL static void close_rx_dma(struct net_device *dev) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); struct dma_device_info *dma_dev = priv->dma_device; int i; @@ -306,7 +303,7 @@ void amazon_xon(struct net_device *dev) int switch_open(struct net_device *dev) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); if (!strcmp(dev->name, "eth1")) { priv->mdio_phy_addr = PHY0_ADDR; } @@ -325,7 +322,7 @@ int switch_open(struct net_device *dev) int switch_release(struct net_device *dev) { int i; - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); struct dma_device_info *dma_dev = priv->dma_device; for (i = 0; i < dma_dev->num_tx_chan; i++) @@ -348,7 +345,7 @@ int switch_release(struct net_device *dev) void switch_rx(struct net_device *dev, int len, struct sk_buff *skb) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); #ifdef CONFIG_NET_HW_FLOWCONTROL int mit_sel = 0; #endif @@ -381,7 +378,7 @@ void switch_rx(struct net_device *dev, int len, struct sk_buff *skb) int asmlinkage switch_hw_tx(char *buf, int len, struct net_device *dev) { - struct switch_priv *priv = dev->priv; + struct switch_priv *priv = netdev_priv(dev); struct dma_device_info *dma_dev = priv->dma_device; dma_dev->current_tx_chan = 0; @@ -392,7 +389,7 @@ int asmlinkage switch_tx(struct sk_buff *skb, struct net_device *dev) { int len; char *data; - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; data = skb->data; @@ -411,7 +408,7 @@ int asmlinkage switch_tx(struct sk_buff *skb, struct net_device *dev) void switch_tx_timeout(struct net_device *dev) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); priv->stats.tx_errors++; netif_wake_queue(dev); return; @@ -419,7 +416,7 @@ void switch_tx_timeout(struct net_device *dev) void negotiate(struct net_device *dev) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); unsigned short data = get_mdio_reg(priv->mdio_phy_addr, MDIO_ADVERTISMENT_REG); data &= ~(MDIO_ADVERT_100_HD | MDIO_ADVERT_100_FD | MDIO_ADVERT_10_FD | MDIO_ADVERT_10_HD); @@ -470,7 +467,7 @@ void negotiate(struct net_device *dev) void set_duplex(struct net_device *dev, enum duplex new_duplex) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); if (new_duplex != priv->current_duplex) { priv->current_duplex = new_duplex; negotiate(dev); @@ -479,14 +476,14 @@ void set_duplex(struct net_device *dev, enum duplex new_duplex) void set_speed(struct net_device *dev, unsigned long speed) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); priv->current_speed_selection = speed; negotiate(dev); } static int switch_ethtool_ioctl(struct net_device *dev, struct ifreq *ifr) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); struct ethtool_cmd ecmd; if (copy_from_user(&ecmd, ifr->ifr_data, sizeof(ecmd))) @@ -642,7 +639,7 @@ int switch_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) struct net_device_stats *switch_stats(struct net_device *dev) { - struct switch_priv *priv = (struct switch_priv *) dev->priv; + struct switch_priv *priv = (struct switch_priv *) netdev_priv(dev); return &priv->stats; } @@ -692,7 +689,7 @@ int dma_intr_handler(struct dma_device_info *dma_dev, int status) { struct net_device *dev; - dev = switch_devs + (u32) dma_dev->priv; + dev = dma_dev->priv; switch (status) { case RCV_INT: switch_hw_receive(dev, dma_dev); @@ -735,19 +732,18 @@ int dma_buffer_free(u8 * dataptr, void *opt) return OK; } -int init_dma_device(_dma_device_info * dma_dev) +int init_dma_device(_dma_device_info * dma_dev, struct net_device *dev) { int i; int num_tx_chan, num_rx_chan; if (strcmp(dma_dev->device_name, "switch1") == 0) { num_tx_chan = 1; num_rx_chan = 2; - dma_dev->priv = (void *) 0; } else { num_tx_chan = 1; num_rx_chan = 2; - dma_dev->priv = (void *) 1; } + dma_dev->priv = dev; dma_dev->weight = 1; dma_dev->num_tx_chan = num_tx_chan; @@ -799,21 +795,15 @@ int switch_init(struct net_device *dev) dev->tx_timeout = switch_tx_timeout; dev->watchdog_timeo = timeout; - SET_MODULE_OWNER(dev); - - dev->priv = kmalloc(sizeof(struct switch_priv), GFP_KERNEL); - if (dev->priv == NULL) - return -ENOMEM; - memset(dev->priv, 0, sizeof(struct switch_priv)); - priv = dev->priv; + priv = netdev_priv(dev); priv->dma_device = (struct dma_device_info *) kmalloc(sizeof(struct dma_device_info), GFP_KERNEL); - if ((dev - switch_devs) == 0) { + if (priv->num == 0) { sprintf(priv->dma_device->device_name, "switch1"); - } else if ((dev - switch_devs) == 1) { + } else if (priv->num == 1) { sprintf(priv->dma_device->device_name, "switch2"); } printk("\"%s\"\n", priv->dma_device->device_name); - init_dma_device(priv->dma_device); + init_dma_device(priv->dma_device, dev); result = dma_device_register(priv->dma_device); /* read the mac address from the mac table and put them into the mac table. */ @@ -827,12 +817,12 @@ int switch_init(struct net_device *dev) dev->dev_addr[2] = 0xda; dev->dev_addr[3] = 0x86; dev->dev_addr[4] = 0x23; - dev->dev_addr[5] = 0x74 + (unsigned char) (dev - switch_devs); + dev->dev_addr[5] = 0x74 + (unsigned char) priv->num; } else { for (i = 0; i < 6; i++) { dev->dev_addr[i] = my_ethaddr[i]; } - dev->dev_addr[5] += +(unsigned char) (dev - switch_devs); + dev->dev_addr[5] += +(unsigned char) priv->num; } return OK; } @@ -840,12 +830,16 @@ int switch_init(struct net_device *dev) int switch_init_module(void) { int i = 0, result, device_present = 0; + struct switch_priv *priv; for (i = 0; i < AMAZON_SW_INT_NO; i++) { - sprintf(switch_devs[i].name, "eth%d", i); - - if ((result = register_netdev(switch_devs + i))) - printk("error %i registering device \"%s\"\n", result, switch_devs[i].name); + switch_devs[i] = alloc_etherdev(sizeof(struct switch_priv)); + switch_devs[i]->init = switch_init; + strcpy(switch_devs[i]->name, "eth%d"); + priv = (struct switch_priv *) netdev_priv(switch_devs[i]); + priv->num = i; + if ((result = register_netdev(switch_devs[i]))) + printk("error %i registering device \"%s\"\n", result, switch_devs[i]->name); else device_present++; } @@ -858,13 +852,13 @@ void switch_cleanup(void) int i; struct switch_priv *priv; for (i = 0; i < AMAZON_SW_INT_NO; i++) { - priv = switch_devs[i].priv; + priv = netdev_priv(switch_devs[i]); if (priv->dma_device) { dma_device_unregister(priv->dma_device); kfree(priv->dma_device); } - kfree(switch_devs[i].priv); - unregister_netdev(switch_devs + i); + kfree(netdev_priv(switch_devs[i])); + unregister_netdev(switch_devs[i]); } return; } diff --git a/target/linux/amazon/files/drivers/serial/amazon_asc.c b/target/linux/amazon/files/drivers/serial/amazon_asc.c index 7c17cb0f4a..6297549458 100644 --- a/target/linux/amazon/files/drivers/serial/amazon_asc.c +++ b/target/linux/amazon/files/drivers/serial/amazon_asc.c @@ -102,10 +102,16 @@ static void amazonasc_enable_ms(struct uart_port *port) return; } +#include <linux/version.h> + static void amazonasc_rx_chars(struct uart_port *port) { +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26)) + struct tty_struct *tty = port->info->port.tty; +#else struct tty_struct *tty = port->info->tty; +#endif unsigned int ch = 0, rsr = 0, fifocnt; fifocnt = amazon_readl(AMAZON_ASC_FSTAT) & ASCFSTAT_RXFFLMASK; diff --git a/target/linux/amazon/files/include/asm-mips/amazon/amazon_sw.h b/target/linux/amazon/files/include/asm-mips/amazon/amazon_sw.h index 3b73b53892..13273813a8 100644 --- a/target/linux/amazon/files/include/asm-mips/amazon/amazon_sw.h +++ b/target/linux/amazon/files/include/asm-mips/amazon/amazon_sw.h @@ -166,6 +166,7 @@ struct switch_priv { int rx_queue_len; int full_duplex; enum duplex current_duplex; + int num; }; #endif //AMAZON_SW_H |