tree-wide: fix assorted typos all over the place
[safe/jmp/linux-2.6] / drivers / net / sis900.c
index 9a363dc..9d94a14 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/kernel.h>
+#include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/timer.h>
 #include <linux/errno.h>
@@ -80,8 +81,8 @@
 #define SIS900_MODULE_NAME "sis900"
 #define SIS900_DRV_VERSION "v1.08.10 Apr. 2 2006"
 
-static char version[] __devinitdata =
-KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n";
+static const char version[] __devinitconst =
+       KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n";
 
 static int max_interrupt_work = 40;
 static int multicast_filter_limit = 128;
@@ -214,7 +215,8 @@ static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_p
 static void sis900_tx_timeout(struct net_device *net_dev);
 static void sis900_init_tx_ring(struct net_device *net_dev);
 static void sis900_init_rx_ring(struct net_device *net_dev);
-static int sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev);
+static netdev_tx_t sis900_start_xmit(struct sk_buff *skb,
+                                    struct net_device *net_dev);
 static int sis900_rx(struct net_device *net_dev);
 static void sis900_finish_xmit (struct net_device *net_dev);
 static irqreturn_t sis900_interrupt(int irq, void *dev_instance);
@@ -381,6 +383,22 @@ static int __devinit sis96x_get_mac_addr(struct pci_dev * pci_dev,
        return 0;
 }
 
+static const struct net_device_ops sis900_netdev_ops = {
+       .ndo_open                = sis900_open,
+       .ndo_stop               = sis900_close,
+       .ndo_start_xmit         = sis900_start_xmit,
+       .ndo_set_config         = sis900_set_config,
+       .ndo_set_multicast_list = set_rx_mode,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_do_ioctl           = mii_ioctl,
+       .ndo_tx_timeout         = sis900_tx_timeout,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+        .ndo_poll_controller   = sis900_poll,
+#endif
+};
+
 /**
  *     sis900_probe - Probe for sis900 device
  *     @pci_dev: the sis900 pci device
@@ -416,7 +434,7 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
        ret = pci_enable_device(pci_dev);
        if(ret) return ret;
 
-       i = pci_set_dma_mask(pci_dev, DMA_32BIT_MASK);
+       i = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
        if(i){
                printk(KERN_ERR "sis900.c: architecture does not support "
                        "32bit PCI busmaster DMA\n");
@@ -461,20 +479,10 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
        sis_priv->rx_ring_dma = ring_dma;
 
        /* The SiS900-specific entries in the device structure. */
-       net_dev->open = &sis900_open;
-       net_dev->hard_start_xmit = &sis900_start_xmit;
-       net_dev->stop = &sis900_close;
-       net_dev->set_config = &sis900_set_config;
-       net_dev->set_multicast_list = &set_rx_mode;
-       net_dev->do_ioctl = &mii_ioctl;
-       net_dev->tx_timeout = sis900_tx_timeout;
+       net_dev->netdev_ops = &sis900_netdev_ops;
        net_dev->watchdog_timeo = TX_TIMEOUT;
        net_dev->ethtool_ops = &sis900_ethtool_ops;
 
-#ifdef CONFIG_NET_POLL_CONTROLLER
-        net_dev->poll_controller = &sis900_poll;
-#endif
-
        if (sis900_debug > 0)
                sis_priv->msg_enable = sis900_debug;
        else
@@ -503,10 +511,10 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
        else
                ret = sis900_get_mac_addr(pci_dev, net_dev);
 
-       if (ret == 0) {
-               printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name);
-               ret = -ENODEV;
-               goto err_unmap_rx;
+       if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) {
+               random_ether_addr(net_dev->dev_addr);
+               printk(KERN_WARNING "%s: Unreadable or invalid MAC address,"
+                               "using random generated one\n", dev_name);
        }
 
        /* 630ET : set the mii access mode as software-mode */
@@ -1276,7 +1284,7 @@ static void sis900_timer(unsigned long data)
        u16 status;
 
        if (!sis_priv->autong_complete){
-               int speed, duplex = 0;
+               int uninitialized_var(speed), duplex = 0;
 
                sis900_read_mode(net_dev, &speed, &duplex);
                if (duplex){
@@ -1565,7 +1573,7 @@ static void sis900_tx_timeout(struct net_device *net_dev)
  *     tell upper layer if the buffer is full
  */
 
-static int
+static netdev_tx_t
 sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
 {
        struct sis900_private *sis_priv = netdev_priv(net_dev);
@@ -1578,7 +1586,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
        /* Don't transmit data before the complete of auto-negotiation */
        if(!sis_priv->autong_complete){
                netif_stop_queue(net_dev);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
 
        spin_lock_irqsave(&sis_priv->lock, flags);
@@ -1622,14 +1630,13 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
                       "to slot %d.\n",
                       net_dev->name, skb->data, (int)skb->len, entry);
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /**
  *     sis900_interrupt - sis900 interrupt handler
  *     @irq: the irq number
  *     @dev_instance: the client data object
- *     @regs: snapshot of processor context
  *
  *     The interrupt handler does all of the Rx thread work,
  *     and cleans up after the Tx thread
@@ -1753,7 +1760,7 @@ static int sis900_rx(struct net_device *net_dev)
                                sis_priv->rx_ring[entry].bufptr, RX_BUF_SIZE,
                                PCI_DMA_FROMDEVICE);
 
-                       /* refill the Rx buffer, what if there is not enought
+                       /* refill the Rx buffer, what if there is not enough
                         * memory for new socket buffer ?? */
                        if ((skb = dev_alloc_skb(RX_BUF_SIZE)) == NULL) {
                                /*
@@ -1768,7 +1775,7 @@ static int sis900_rx(struct net_device *net_dev)
                        }
 
                        /* This situation should never happen, but due to
-                          some unknow bugs, it is possible that
+                          some unknown bugs, it is possible that
                           we are working on NULL sk_buff :-( */
                        if (sis_priv->rx_skbuff[entry] == NULL) {
                                if (netif_msg_rx_err(sis_priv))
@@ -2122,8 +2129,6 @@ static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
                return 0;
 
        case SIOCSMIIREG:               /* Write MII PHY register. */
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
                mdio_write(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
                return 0;
        default: