patch-2.4.23 linux-2.4.23/drivers/net/ne2k-pci.c
Next file: linux-2.4.23/drivers/net/net_init.c
Previous file: linux-2.4.23/drivers/net/natsemi.c
Back to the patch index
Back to the overall index
- Lines: 162
- Date:
2003-11-28 10:26:20.000000000 -0800
- Orig file:
linux-2.4.22/drivers/net/ne2k-pci.c
- Orig date:
2003-08-25 04:44:42.000000000 -0700
diff -urN linux-2.4.22/drivers/net/ne2k-pci.c linux-2.4.23/drivers/net/ne2k-pci.c
@@ -50,15 +50,16 @@
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/init.h>
+#include <linux/interrupt.h>
#include <linux/ethtool.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
#include "8390.h"
/* These identify the driver base version and may not be removed. */
@@ -136,7 +137,7 @@
};
-static struct pci_device_id ne2k_pci_tbl[] __devinitdata = {
+static struct pci_device_id ne2k_pci_tbl[] = {
{ 0x10ec, 0x8029, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RealTek_RTL_8029 },
{ 0x1050, 0x0940, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_89C940 },
{ 0x11f6, 0x1401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Compex_RL2000 },
@@ -174,7 +175,7 @@
struct sk_buff *skb, int ring_offset);
static void ne2k_pci_block_output(struct net_device *dev, const int count,
const unsigned char *buf, const int start_page);
-static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static struct ethtool_ops ne2k_pci_ethtool_ops;
@@ -259,7 +260,8 @@
}
}
- dev = alloc_etherdev(0);
+ /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
+ dev = alloc_ei_netdev();
if (!dev) {
printk (KERN_ERR PFX "cannot allocate ethernet device\n");
goto err_out_free_res;
@@ -330,13 +332,6 @@
dev->base_addr = ioaddr;
pci_set_drvdata(pdev, dev);
- /* Allocate dev->priv and fill in 8390 specific dev fields. */
- if (ethdev_init(dev)) {
- printk (KERN_ERR "ne2kpci(%s): unable to get memory for dev->priv.\n",
- pdev->slot_name);
- goto err_out_free_netdev;
- }
-
ei_status.name = pci_clone_list[chip_idx].name;
ei_status.tx_start_page = start_page;
ei_status.stop_page = stop_page;
@@ -360,12 +355,12 @@
ei_status.priv = (unsigned long) pdev;
dev->open = &ne2k_pci_open;
dev->stop = &ne2k_pci_close;
- dev->do_ioctl = &netdev_ioctl;
+ dev->ethtool_ops = &ne2k_pci_ethtool_ops;
NS8390_init(dev, 0);
i = register_netdev(dev);
if (i)
- goto err_out_free_8390;
+ goto err_out_free_netdev;
printk("%s: %s found at %#lx, IRQ %d, ",
dev->name, pci_clone_list[chip_idx].name, ioaddr, dev->irq);
@@ -376,8 +371,6 @@
return 0;
-err_out_free_8390:
- kfree(dev->priv);
err_out_free_netdev:
kfree (dev);
err_out_free_res:
@@ -590,41 +583,23 @@
return;
}
-static int netdev_ethtool_ioctl(struct net_device *dev, void *useraddr)
+static void ne2k_pci_get_drvinfo(struct net_device *dev,
+ struct ethtool_drvinfo *info)
{
struct ei_device *ei = dev->priv;
struct pci_dev *pci_dev = (struct pci_dev *) ei->priv;
- u32 ethcmd;
-
- if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
- return -EFAULT;
-
- switch (ethcmd) {
- case ETHTOOL_GDRVINFO: {
- struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
- strcpy(info.driver, DRV_NAME);
- strcpy(info.version, DRV_VERSION);
- strcpy(info.bus_info, pci_dev->slot_name);
- if (copy_to_user(useraddr, &info, sizeof(info)))
- return -EFAULT;
- return 0;
- }
-
- }
-
- return -EOPNOTSUPP;
-}
-
-static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
- switch(cmd) {
- case SIOCETHTOOL:
- return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
- default:
- return -EOPNOTSUPP;
- }
+
+ strcpy(info->driver, DRV_NAME);
+ strcpy(info->version, DRV_VERSION);
+ strcpy(info->bus_info, pci_name(pci_dev));
}
+static struct ethtool_ops ne2k_pci_ethtool_ops = {
+ .get_drvinfo = ne2k_pci_get_drvinfo,
+ .get_tx_csum = ethtool_op_get_tx_csum,
+ .get_sg = ethtool_op_get_sg,
+};
+
static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
{
struct net_device *dev = pci_get_drvdata(pdev);
@@ -634,17 +609,17 @@
unregister_netdev(dev);
release_region(dev->base_addr, NE_IO_EXTENT);
- kfree(dev->priv);
kfree(dev);
+ pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
}
static struct pci_driver ne2k_driver = {
- name: DRV_NAME,
- probe: ne2k_pci_init_one,
- remove: __devexit_p(ne2k_pci_remove_one),
- id_table: ne2k_pci_tbl,
+ .name = DRV_NAME,
+ .probe = ne2k_pci_init_one,
+ .remove = __devexit_p(ne2k_pci_remove_one),
+ .id_table = ne2k_pci_tbl,
};
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)