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

[ARM] Convert EBSA110 network driver to a platform driver

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Russell King and committed by
Russell King
37bb30e8 1be7228d

+57 -12
+25 -1
arch/arm/mach-ebsa110/core.c
··· 251 251 }, 252 252 }; 253 253 254 + static struct resource am79c961_resources[] = { 255 + { 256 + .start = 0x220, 257 + .end = 0x238, 258 + .flags = IORESOURCE_IO, 259 + }, { 260 + .start = IRQ_EBSA110_ETHERNET, 261 + .end = IRQ_EBSA110_ETHERNET, 262 + .flags = IORESOURCE_IRQ, 263 + }, 264 + }; 265 + 266 + static struct platform_device am79c961_device = { 267 + .name = "am79c961", 268 + .id = -1, 269 + .num_resources = ARRAY_SIZE(am79c961_resources), 270 + .resource = am79c961_resources, 271 + }; 272 + 273 + static struct platform_device *ebsa110_devices[] = { 274 + &serial_device, 275 + &am79c961_device, 276 + }; 277 + 254 278 static int __init ebsa110_init(void) 255 279 { 256 - return platform_device_register(&serial_device); 280 + return platform_add_devices(ebsa110_devices, ARRAY_SIZE(ebsa110_devices)); 257 281 } 258 282 259 283 arch_initcall(ebsa110_init);
+32 -9
drivers/net/arm/am79c961a.c
··· 26 26 #include <linux/init.h> 27 27 #include <linux/crc32.h> 28 28 #include <linux/bitops.h> 29 + #include <linux/platform_device.h> 29 30 30 - #include <asm/system.h> 31 - #include <asm/irq.h> 32 31 #include <asm/hardware.h> 33 32 #include <asm/io.h> 33 + #include <asm/system.h> 34 34 35 35 #define TX_BUFFERS 15 36 36 #define RX_BUFFERS 25 ··· 280 280 lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; 281 281 carrier = netif_carrier_ok(dev); 282 282 283 - if (lnkstat && !carrier) 283 + if (lnkstat && !carrier) { 284 284 netif_carrier_on(dev); 285 - else if (!lnkstat && carrier) 285 + printk("%s: link up\n", dev->name); 286 + } else if (!lnkstat && carrier) { 286 287 netif_carrier_off(dev); 288 + printk("%s: link down\n", dev->name); 289 + } 287 290 288 291 mod_timer(&priv->timer, jiffies + msecs_to_jiffies(500)); 289 292 } ··· 668 665 printk(KERN_INFO "%s", version); 669 666 } 670 667 671 - static int __init am79c961_init(void) 668 + static int __init am79c961_probe(struct device *_dev) 672 669 { 670 + struct platform_device *pdev = to_platform_device(_dev); 671 + struct resource *res; 673 672 struct net_device *dev; 674 673 struct dev_priv *priv; 675 674 int i, ret; 675 + 676 + res = platform_get_resource(pdev, IORESOURCE_IO, 0); 677 + if (!res) 678 + return -ENODEV; 676 679 677 680 dev = alloc_etherdev(sizeof(struct dev_priv)); 678 681 ret = -ENOMEM; 679 682 if (!dev) 680 683 goto out; 684 + 685 + SET_NETDEV_DEV(dev, &pdev->dev); 681 686 682 687 priv = netdev_priv(dev); 683 688 ··· 694 683 * The PNP initialisation should have been 695 684 * done by the ether bootp loader. 696 685 */ 697 - dev->base_addr = 0x220; 698 - dev->irq = IRQ_EBSA110_ETHERNET; 686 + dev->base_addr = res->start; 687 + dev->irq = platform_get_irq(pdev, 0); 699 688 700 689 ret = -ENODEV; 701 690 if (!request_region(dev->base_addr, 0x18, dev->name)) ··· 716 705 inb(dev->base_addr + 4) != 0x2b) 717 706 goto release; 718 707 719 - am79c961_banner(); 720 - 721 708 for (i = 0; i < 6; i++) 722 709 dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff; 710 + 711 + am79c961_banner(); 723 712 724 713 spin_lock_init(&priv->chip_lock); 725 714 init_timer(&priv->timer); ··· 743 732 if (ret == 0) { 744 733 printk(KERN_INFO "%s: ether address ", dev->name); 745 734 735 + /* Retrive and print the ethernet address. */ 746 736 for (i = 0; i < 6; i++) 747 737 printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]); 748 738 ··· 756 744 free_netdev(dev); 757 745 out: 758 746 return ret; 747 + } 748 + 749 + static struct device_driver am79c961_driver = { 750 + .name = "am79c961", 751 + .bus = &platform_bus_type, 752 + .probe = am79c961_probe, 753 + }; 754 + 755 + static int __init am79c961_init(void) 756 + { 757 + return driver_register(&am79c961_driver); 759 758 } 760 759 761 760 __initcall(am79c961_init);
-2
drivers/net/arm/am79c961a.h
··· 143 143 struct timer_list timer; 144 144 }; 145 145 146 - extern int am79c961_probe (struct net_device *dev); 147 - 148 146 #endif