aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/sb1250-mac.c120
1 files changed, 1 insertions, 119 deletions
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 6ed92d62af22..ba4770a6c2e4 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -332,7 +332,6 @@ static int sbmac_mii_write(struct mii_bus *bus, int phyaddr, int regidx,
332 ********************************************************************* */ 332 ********************************************************************* */
333 333
334static char sbmac_string[] = "sb1250-mac"; 334static char sbmac_string[] = "sb1250-mac";
335static char sbmac_pretty[] = "SB1250 MAC";
336 335
337static char sbmac_mdio_string[] = "sb1250-mac-mdio"; 336static char sbmac_mdio_string[] = "sb1250-mac-mdio";
338 337
@@ -2670,114 +2669,6 @@ static int __exit sbmac_remove(struct platform_device *pldev)
2670 return 0; 2669 return 0;
2671} 2670}
2672 2671
2673
2674static struct platform_device **sbmac_pldev;
2675static int sbmac_max_units;
2676
2677static int __init sbmac_platform_probe_one(int idx)
2678{
2679 struct platform_device *pldev;
2680 struct {
2681 struct resource r;
2682 char name[strlen(sbmac_pretty) + 4];
2683 } *res;
2684 int err;
2685
2686 res = kzalloc(sizeof(*res), GFP_KERNEL);
2687 if (!res) {
2688 printk(KERN_ERR "%s.%d: unable to allocate memory\n",
2689 sbmac_string, idx);
2690 err = -ENOMEM;
2691 goto out_err;
2692 }
2693
2694 /*
2695 * This is the base address of the MAC.
2696 */
2697 snprintf(res->name, sizeof(res->name), "%s %d", sbmac_pretty, idx);
2698 res->r.name = res->name;
2699 res->r.flags = IORESOURCE_MEM;
2700 res->r.start = A_MAC_CHANNEL_BASE(idx);
2701 res->r.end = A_MAC_CHANNEL_BASE(idx + 1) - 1;
2702
2703 pldev = platform_device_register_simple(sbmac_string, idx, &res->r, 1);
2704 if (IS_ERR(pldev)) {
2705 printk(KERN_ERR "%s.%d: unable to register platform device\n",
2706 sbmac_string, idx);
2707 err = PTR_ERR(pldev);
2708 goto out_kfree;
2709 }
2710
2711 if (!pldev->dev.driver) {
2712 err = 0; /* No hardware at this address. */
2713 goto out_unregister;
2714 }
2715
2716 sbmac_pldev[idx] = pldev;
2717 return 0;
2718
2719out_unregister:
2720 platform_device_unregister(pldev);
2721
2722out_kfree:
2723 kfree(res);
2724
2725out_err:
2726 return err;
2727}
2728
2729static void __init sbmac_platform_probe(void)
2730{
2731 int i;
2732
2733 /* Set the number of available units based on the SOC type. */
2734 switch (soc_type) {
2735 case K_SYS_SOC_TYPE_BCM1250:
2736 case K_SYS_SOC_TYPE_BCM1250_ALT:
2737 sbmac_max_units = 3;
2738 break;
2739 case K_SYS_SOC_TYPE_BCM1120:
2740 case K_SYS_SOC_TYPE_BCM1125:
2741 case K_SYS_SOC_TYPE_BCM1125H:
2742 case K_SYS_SOC_TYPE_BCM1250_ALT2: /* Hybrid */
2743 sbmac_max_units = 2;
2744 break;
2745 case K_SYS_SOC_TYPE_BCM1x55:
2746 case K_SYS_SOC_TYPE_BCM1x80:
2747 sbmac_max_units = 4;
2748 break;
2749 default:
2750 return; /* none */
2751 }
2752
2753 sbmac_pldev = kcalloc(sbmac_max_units, sizeof(*sbmac_pldev),
2754 GFP_KERNEL);
2755 if (!sbmac_pldev) {
2756 printk(KERN_ERR "%s: unable to allocate memory\n",
2757 sbmac_string);
2758 return;
2759 }
2760
2761 /*
2762 * Walk through the Ethernet controllers and find
2763 * those who have their MAC addresses set.
2764 */
2765 for (i = 0; i < sbmac_max_units; i++)
2766 if (sbmac_platform_probe_one(i))
2767 break;
2768}
2769
2770
2771static void __exit sbmac_platform_cleanup(void)
2772{
2773 int i;
2774
2775 for (i = 0; i < sbmac_max_units; i++)
2776 platform_device_unregister(sbmac_pldev[i]);
2777 kfree(sbmac_pldev);
2778}
2779
2780
2781static struct platform_driver sbmac_driver = { 2672static struct platform_driver sbmac_driver = {
2782 .probe = sbmac_probe, 2673 .probe = sbmac_probe,
2783 .remove = __exit_p(sbmac_remove), 2674 .remove = __exit_p(sbmac_remove),
@@ -2788,20 +2679,11 @@ static struct platform_driver sbmac_driver = {
2788 2679
2789static int __init sbmac_init_module(void) 2680static int __init sbmac_init_module(void)
2790{ 2681{
2791 int err; 2682 return platform_driver_register(&sbmac_driver);
2792
2793 err = platform_driver_register(&sbmac_driver);
2794 if (err)
2795 return err;
2796
2797 sbmac_platform_probe();
2798
2799 return err;
2800} 2683}
2801 2684
2802static void __exit sbmac_cleanup_module(void) 2685static void __exit sbmac_cleanup_module(void)
2803{ 2686{
2804 sbmac_platform_cleanup();
2805 platform_driver_unregister(&sbmac_driver); 2687 platform_driver_unregister(&sbmac_driver);
2806} 2688}
2807 2689