Skip to content

Commit

Permalink
mac68k: move macsonic and macmace platform devices
Browse files Browse the repository at this point in the history
Move platform device code from the drivers to the platform init function.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
  • Loading branch information
Finn Thain authored and Geert Uytterhoeven committed Feb 27, 2010
1 parent cff75f1 commit eeb9c18
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 58 deletions.
23 changes: 23 additions & 0 deletions arch/m68k/mac/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,16 @@ static struct platform_device esp_1_pdev = {
.id = 1,
};

static struct platform_device sonic_pdev = {
.name = "macsonic",
.id = -1,
};

static struct platform_device mace_pdev = {
.name = "macmace",
.id = -1,
};

int __init mac_platform_init(void)
{
u8 *swim_base;
Expand Down Expand Up @@ -971,6 +981,19 @@ int __init mac_platform_init(void)
break;
}

/*
* Ethernet device
*/

switch (macintosh_config->ether_type) {
case MAC_ETHER_SONIC:
platform_device_register(&sonic_pdev);
break;
case MAC_ETHER_MACE:
platform_device_register(&mace_pdev);
break;
}

return 0;
}

Expand Down
33 changes: 4 additions & 29 deletions drivers/net/macmace.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "mace.h"

static char mac_mace_string[] = "macmace";
static struct platform_device *mac_mace_device;

#define N_TX_BUFF_ORDER 0
#define N_TX_RING (1 << N_TX_BUFF_ORDER)
Expand Down Expand Up @@ -752,6 +751,7 @@ static irqreturn_t mace_dma_intr(int irq, void *dev_id)

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Macintosh MACE ethernet driver");
MODULE_ALIAS("platform:macmace");

static int __devexit mac_mace_device_remove (struct platform_device *pdev)
{
Expand All @@ -777,47 +777,22 @@ static struct platform_driver mac_mace_driver = {
.probe = mace_probe,
.remove = __devexit_p(mac_mace_device_remove),
.driver = {
.name = mac_mace_string,
.name = mac_mace_string,
.owner = THIS_MODULE,
},
};

static int __init mac_mace_init_module(void)
{
int err;

if (!MACH_IS_MAC)
return -ENODEV;

if ((err = platform_driver_register(&mac_mace_driver))) {
printk(KERN_ERR "Driver registration failed\n");
return err;
}

mac_mace_device = platform_device_alloc(mac_mace_string, 0);
if (!mac_mace_device)
goto out_unregister;

if (platform_device_add(mac_mace_device)) {
platform_device_put(mac_mace_device);
mac_mace_device = NULL;
}

return 0;

out_unregister:
platform_driver_unregister(&mac_mace_driver);

return -ENOMEM;
return platform_driver_register(&mac_mace_driver);
}

static void __exit mac_mace_cleanup_module(void)
{
platform_driver_unregister(&mac_mace_driver);

if (mac_mace_device) {
platform_device_unregister(mac_mace_device);
mac_mace_device = NULL;
}
}

module_init(mac_mace_init_module);
Expand Down
33 changes: 4 additions & 29 deletions drivers/net/macsonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <asm/mac_via.h>

static char mac_sonic_string[] = "macsonic";
static struct platform_device *mac_sonic_device;

#include "sonic.h"

Expand Down Expand Up @@ -607,6 +606,7 @@ static int __devinit mac_sonic_probe(struct platform_device *pdev)
MODULE_DESCRIPTION("Macintosh SONIC ethernet driver");
module_param(sonic_debug, int, 0);
MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
MODULE_ALIAS("platform:macsonic");

#include "sonic.c"

Expand All @@ -627,44 +627,19 @@ static struct platform_driver mac_sonic_driver = {
.probe = mac_sonic_probe,
.remove = __devexit_p(mac_sonic_device_remove),
.driver = {
.name = mac_sonic_string,
.name = mac_sonic_string,
.owner = THIS_MODULE,
},
};

static int __init mac_sonic_init_module(void)
{
int err;

if ((err = platform_driver_register(&mac_sonic_driver))) {
printk(KERN_ERR "Driver registration failed\n");
return err;
}

mac_sonic_device = platform_device_alloc(mac_sonic_string, 0);
if (!mac_sonic_device)
goto out_unregister;

if (platform_device_add(mac_sonic_device)) {
platform_device_put(mac_sonic_device);
mac_sonic_device = NULL;
}

return 0;

out_unregister:
platform_driver_unregister(&mac_sonic_driver);

return -ENOMEM;
return platform_driver_register(&mac_sonic_driver);
}

static void __exit mac_sonic_cleanup_module(void)
{
platform_driver_unregister(&mac_sonic_driver);

if (mac_sonic_device) {
platform_device_unregister(mac_sonic_device);
mac_sonic_device = NULL;
}
}

module_init(mac_sonic_init_module);
Expand Down

0 comments on commit eeb9c18

Please sign in to comment.