[PATCH 3/5] m68k/atari: EtherNAT - register EtherNAT platform devices only when probed

Michael Schmitz
2012-04-01T03:03:03Z

Hi All,

Part 3 in the EtherNAT series - only register platform devices if the
card is present.

Signed-off-by: Michael Schmitz <schmitz@debian.org>

--
arch/m68k/atari/config.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
index 12a76ab..92bf83a 100644
--- a/arch/m68k/atari/config.c
+++ b/arch/m68k/atari/config.c
@@ -752,7 +752,18 @@ static struct platform_device
*atari_platform_devices[] __initdata = {

int __init atari_platform_init(void)
{
- return platform_add_devices(atari_platform_devices,
ARRAY_SIZE(atari_platform_devices));
+ int rv = -ENODEV;
+ unsigned char *enatc_virt;
+
+ if (!MACH_IS_ATARI)
+ return -ENODEV;
+
+ enatc_virt = (unsigned char
*)ioremap((ATARI_ETHERNAT_PHYS_ADDR+0x23), 0xf);
+ if (hwreg_present(enatc_virt))
+ rv = platform_add_devices(atari_platform_devices,
ARRAY_SIZE(atari_platform_devices));
+ iounmap(enatc_virt);
+
+ return rv;
}

arch_initcall(atari_platform_init);