diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-06-27 09:20:08 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-07-05 13:40:50 -0400 |
commit | e54f48933f414fa447c26d16524a4c9a8e2facc6 (patch) | |
tree | 0e1a89263c66fa3669f70cf3e74cc0448482a28f /drivers | |
parent | 46009c8bcd5d7c9fcbfc17d0455a471bea5be4d4 (diff) |
[netdrvr] via-velocity: misc. cleanups
- const-ify pci_device_id table
- clean up pci_device_id table with PCI_DEVICE()
- don't store internal pointer in pci_device_id table,
use pci_device_id::driver_data as an integer index
- use dev_printk() for messages where eth%d prefix is unavailable
- formatting fixes
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/via-velocity.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index bbab3972ff86..019dcf2457b4 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c | |||
@@ -304,10 +304,9 @@ static struct velocity_info_tbl chip_info_table[] = { | |||
304 | * device driver. Used for hotplug autoloading. | 304 | * device driver. Used for hotplug autoloading. |
305 | */ | 305 | */ |
306 | 306 | ||
307 | static struct pci_device_id velocity_id_table[] __devinitdata = { | 307 | static const struct pci_device_id velocity_id_table[] __devinitdata = { |
308 | {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X, | 308 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) }, |
309 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) chip_info_table}, | 309 | { } |
310 | {0, } | ||
311 | }; | 310 | }; |
312 | 311 | ||
313 | MODULE_DEVICE_TABLE(pci, velocity_id_table); | 312 | MODULE_DEVICE_TABLE(pci, velocity_id_table); |
@@ -686,21 +685,23 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi | |||
686 | static int first = 1; | 685 | static int first = 1; |
687 | struct net_device *dev; | 686 | struct net_device *dev; |
688 | int i; | 687 | int i; |
689 | struct velocity_info_tbl *info = (struct velocity_info_tbl *) ent->driver_data; | 688 | struct velocity_info_tbl *info = &chip_info_table[ent->driver_data]; |
690 | struct velocity_info *vptr; | 689 | struct velocity_info *vptr; |
691 | struct mac_regs __iomem * regs; | 690 | struct mac_regs __iomem * regs; |
692 | int ret = -ENOMEM; | 691 | int ret = -ENOMEM; |
693 | 692 | ||
693 | /* FIXME: this driver, like almost all other ethernet drivers, | ||
694 | * can support more than MAX_UNITS. | ||
695 | */ | ||
694 | if (velocity_nics >= MAX_UNITS) { | 696 | if (velocity_nics >= MAX_UNITS) { |
695 | printk(KERN_NOTICE VELOCITY_NAME ": already found %d NICs.\n", | 697 | dev_printk(KERN_NOTICE, &pdev->dev, "already found %d NICs.\n", |
696 | velocity_nics); | 698 | velocity_nics); |
697 | return -ENODEV; | 699 | return -ENODEV; |
698 | } | 700 | } |
699 | 701 | ||
700 | dev = alloc_etherdev(sizeof(struct velocity_info)); | 702 | dev = alloc_etherdev(sizeof(struct velocity_info)); |
701 | 703 | if (!dev) { | |
702 | if (dev == NULL) { | 704 | dev_printk(KERN_ERR, &pdev->dev, "allocate net device failed.\n"); |
703 | printk(KERN_ERR VELOCITY_NAME ": allocate net device failed.\n"); | ||
704 | goto out; | 705 | goto out; |
705 | } | 706 | } |
706 | 707 | ||
@@ -731,13 +732,13 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi | |||
731 | 732 | ||
732 | ret = velocity_get_pci_info(vptr, pdev); | 733 | ret = velocity_get_pci_info(vptr, pdev); |
733 | if (ret < 0) { | 734 | if (ret < 0) { |
734 | printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n"); | 735 | /* error message already printed */ |
735 | goto err_disable; | 736 | goto err_disable; |
736 | } | 737 | } |
737 | 738 | ||
738 | ret = pci_request_regions(pdev, VELOCITY_NAME); | 739 | ret = pci_request_regions(pdev, VELOCITY_NAME); |
739 | if (ret < 0) { | 740 | if (ret < 0) { |
740 | printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n"); | 741 | dev_printk(KERN_ERR, &pdev->dev, "No PCI resources.\n"); |
741 | goto err_disable; | 742 | goto err_disable; |
742 | } | 743 | } |
743 | 744 | ||
@@ -883,8 +884,7 @@ static void __devinit velocity_init_info(struct pci_dev *pdev, struct velocity_i | |||
883 | 884 | ||
884 | static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev) | 885 | static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev) |
885 | { | 886 | { |
886 | 887 | if (pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0) | |
887 | if(pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0) | ||
888 | return -EIO; | 888 | return -EIO; |
889 | 889 | ||
890 | pci_set_master(pdev); | 890 | pci_set_master(pdev); |
@@ -892,24 +892,20 @@ static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pc | |||
892 | vptr->ioaddr = pci_resource_start(pdev, 0); | 892 | vptr->ioaddr = pci_resource_start(pdev, 0); |
893 | vptr->memaddr = pci_resource_start(pdev, 1); | 893 | vptr->memaddr = pci_resource_start(pdev, 1); |
894 | 894 | ||
895 | if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) | 895 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { |
896 | { | 896 | dev_printk(KERN_ERR, &pdev->dev, |
897 | printk(KERN_ERR "%s: region #0 is not an I/O resource, aborting.\n", | 897 | "region #0 is not an I/O resource, aborting.\n"); |
898 | pci_name(pdev)); | ||
899 | return -EINVAL; | 898 | return -EINVAL; |
900 | } | 899 | } |
901 | 900 | ||
902 | if((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) | 901 | if ((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) { |
903 | { | 902 | dev_printk(KERN_ERR, &pdev->dev, |
904 | printk(KERN_ERR "%s: region #1 is an I/O resource, aborting.\n", | 903 | "region #1 is an I/O resource, aborting.\n"); |
905 | pci_name(pdev)); | ||
906 | return -EINVAL; | 904 | return -EINVAL; |
907 | } | 905 | } |
908 | 906 | ||
909 | if(pci_resource_len(pdev, 1) < 256) | 907 | if (pci_resource_len(pdev, 1) < 256) { |
910 | { | 908 | dev_printk(KERN_ERR, &pdev->dev, "region #1 is too small.\n"); |
911 | printk(KERN_ERR "%s: region #1 is too small.\n", | ||
912 | pci_name(pdev)); | ||
913 | return -EINVAL; | 909 | return -EINVAL; |
914 | } | 910 | } |
915 | vptr->pdev = pdev; | 911 | vptr->pdev = pdev; |