Subject: Re: [PATCH 2/7] powerpc: allow localbus compatible serial ports for console device

From: Paul Gortmaker <[email-masked]>
Date: Mon, 07 Jan 2008 10:33:21 -0500

Arnd Bergmann wrote:
> On Monday 07 January 2008, Paul Gortmaker wrote:
>   
>> +       /* Next, fill our array with any localbus serial ports */
>> +       for_each_compatible_node(np, "serial", "ns16550") {
>> +               struct device_node *lbs = of_get_parent(np);
>> +               if (lbs && of_device_is_compatible(lbs, "localbus")) {
>> +                       index = add_legacy_soc_port(np, np);
>> +                       if (index >= 0 && np == stdout)
>> +                               legacy_serial_console = index;
>> +               }
>> +               of_node_put(lbs);
>> +       }
>> +
>>     
>
> This is getting a little silly. Can't you finally unify the code
> so it checks for any 8250/16450/16550 on any soc/isa/tsi-bridge/opb/localbus?
>   

I'd thought about doing that, but there are slight differences
in each test.  To remain 100% faithful to the original implementation
you'd have to have a table or similar that had these various fields
and loop over that -- something like:

compat      parent   pnt-compat  pnt-type   add-fcn
---------------------------------------------------------------
ns16550     NULL     NULL        soc        add_legacy_soc_port
NULL        isa      NULL        NULL       add_legacy_isa_port
ns16550     NULL     NULL        tsi-bridge add_legacy_soc_port
ns16550     NULL     ibm,opb     opb        add_legacy_soc_port
ns16550     NULL     localbus    NULL       add_legacy_soc_port

But, if we were willing to move away from checks based on
the parent->type and stick with parent->compat, then the
unification would be a lot cleaner and easier to implement.
(we could also leave the ISA one out as an oddball, and then
not have to carry an add-fcn either).

Paul.

> 	Arnd <><