Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

+22 -26
+22 -26
drivers/net/via-velocity.c
··· 304 304 * device driver. Used for hotplug autoloading. 305 305 */ 306 306 307 - static struct pci_device_id velocity_id_table[] __devinitdata = { 308 - {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X, 309 - PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) chip_info_table}, 310 - {0, } 307 + static const struct pci_device_id velocity_id_table[] __devinitdata = { 308 + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) }, 309 + { } 311 310 }; 312 311 313 312 MODULE_DEVICE_TABLE(pci, velocity_id_table); ··· 685 686 static int first = 1; 686 687 struct net_device *dev; 687 688 int i; 688 - struct velocity_info_tbl *info = (struct velocity_info_tbl *) ent->driver_data; 689 + struct velocity_info_tbl *info = &chip_info_table[ent->driver_data]; 689 690 struct velocity_info *vptr; 690 691 struct mac_regs __iomem * regs; 691 692 int ret = -ENOMEM; 692 693 694 + /* FIXME: this driver, like almost all other ethernet drivers, 695 + * can support more than MAX_UNITS. 696 + */ 693 697 if (velocity_nics >= MAX_UNITS) { 694 - printk(KERN_NOTICE VELOCITY_NAME ": already found %d NICs.\n", 695 - velocity_nics); 698 + dev_printk(KERN_NOTICE, &pdev->dev, "already found %d NICs.\n", 699 + velocity_nics); 696 700 return -ENODEV; 697 701 } 698 702 699 703 dev = alloc_etherdev(sizeof(struct velocity_info)); 700 - 701 - if (dev == NULL) { 702 - printk(KERN_ERR VELOCITY_NAME ": allocate net device failed.\n"); 704 + if (!dev) { 705 + dev_printk(KERN_ERR, &pdev->dev, "allocate net device failed.\n"); 703 706 goto out; 704 707 } 705 708 ··· 732 731 733 732 ret = velocity_get_pci_info(vptr, pdev); 734 733 if (ret < 0) { 735 - printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n"); 734 + /* error message already printed */ 736 735 goto err_disable; 737 736 } 738 737 739 738 ret = pci_request_regions(pdev, VELOCITY_NAME); 740 739 if (ret < 0) { 741 - printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n"); 740 + dev_printk(KERN_ERR, &pdev->dev, "No PCI resources.\n"); 742 741 goto err_disable; 743 742 } 744 743 ··· 884 883 885 884 static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev) 886 885 { 887 - 888 - if(pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0) 886 + if (pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0) 889 887 return -EIO; 890 888 891 889 pci_set_master(pdev); ··· 892 892 vptr->ioaddr = pci_resource_start(pdev, 0); 893 893 vptr->memaddr = pci_resource_start(pdev, 1); 894 894 895 - if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) 896 - { 897 - printk(KERN_ERR "%s: region #0 is not an I/O resource, aborting.\n", 898 - pci_name(pdev)); 895 + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) { 896 + dev_printk(KERN_ERR, &pdev->dev, 897 + "region #0 is not an I/O resource, aborting.\n"); 899 898 return -EINVAL; 900 899 } 901 900 902 - if((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) 903 - { 904 - printk(KERN_ERR "%s: region #1 is an I/O resource, aborting.\n", 905 - pci_name(pdev)); 901 + if ((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) { 902 + dev_printk(KERN_ERR, &pdev->dev, 903 + "region #1 is an I/O resource, aborting.\n"); 906 904 return -EINVAL; 907 905 } 908 906 909 - if(pci_resource_len(pdev, 1) < 256) 910 - { 911 - printk(KERN_ERR "%s: region #1 is too small.\n", 912 - pci_name(pdev)); 907 + if (pci_resource_len(pdev, 1) < 256) { 908 + dev_printk(KERN_ERR, &pdev->dev, "region #1 is too small.\n"); 913 909 return -EINVAL; 914 910 } 915 911 vptr->pdev = pdev;