Re: [PATCH 05/11] m68k/atari: Add missing platform check beforeregistering platform devices

From: Geert Uytterhoeven
Date: Sun Mar 25 2012 - 04:02:10 EST


Hi Michael,

On Sun, Mar 25, 2012 at 05:46, Michael Schmitz
<schmitzmic@xxxxxxxxxxxxxx> wrote:
>> On multi-platform kernels, the Atari platform devices should be registered
>> when running on Atari only. Else it may crash later.
>>
>> Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
>> ---
>> Âarch/m68k/atari/config.c | Â Â3 +++
>> Â1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c
>> index af78731..35fb81d 100644
>> --- a/arch/m68k/atari/config.c
>> +++ b/arch/m68k/atari/config.c
>> @@ -693,6 +693,9 @@ static struct platform_device
>> *atari_platform_devices[] __initdata = {
>> Âint __init atari_platform_init(void)
>> Â{
>> + Â Â Â if (!MACH_IS_ATARI)
>> + Â Â Â Â Â Â Â return -ENODEV;
>> +
>> Â Â Â Âreturn platform_add_devices(atari_platform_devices,
>> ARRAY_SIZE(atari_platform_devices));
>> Â}
>>
>
>
> How about this instead - probe for the EtherNAT config register, and
> register devices only if found?

That's even better, but logically, it's an extra change on top, so I'd like
to keep it separate.

> (may apply with a bit of fuzz)
>
> Otherwise, Acked-by: Michael Schmitz <schmitz@xxxxxxxxxx>.
>
> --- arch/m68k/atari/config.c.org  Â2012-03-25 16:02:12.000000000 +1300
> +++ arch/m68k/atari/config.c  Â2012-03-25 13:37:21.000000000 +1300
> @@ -753,7 +753,19 @@
>
> int __init atari_platform_init(void)
> {
> - Â Âreturn platform_add_devices(atari_platform_devices,
> ARRAY_SIZE(atari_platform_devices));
> + Â Âif (MACH_IS_ATARI) {

I prefer the "if (!MACH_IS_ATARI) return -ENODEV;" at the top, as it
- means less code to change if more platform devices are added,
- means less source code to keep on your mental stack when reading the code,
- decreases indentation for the rest of the function.

> + Â Â Â Âu8 ethernat_cr;
> + Â Â Â Âunsigned long enatc_phys = 0x80000023;
> + Â Â Â Âunsigned char *enatc_virt;
> + Â Â Â + Â Â Â Âenatc_virt = (unsigned char *)ioremap(enatc_phys, 0xf);
> + Â Â Â Âif (hwreg_present(enatc_virt)) {
> + Â Â Â Â Â Âiounmap(enatc_virt);
> + Â Â Â Â Â Âreturn platform_add_devices(atari_platform_devices,
> ARRAY_SIZE(atari_platform_devices));
> + Â Â Â Â}
> + Â Â Â Âiounmap(enatc_virt);
> + Â Â}
> + Â Âreturn -ENODEV; Â }
>
> arch_initcall(atari_platform_init);

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/