Hi Sean,

On Sat, 12 Jan 2008 15:42:45 -0500 Sean MacLennan <[EMAIL PROTECTED]> wrote:
>
> +++ b/arch/powerpc/platforms/44x/warp.c

> +static int __init warp_probe(void)
> +{
> +     unsigned long root = of_get_flat_dt_root();
> +
> +     if (!of_flat_dt_is_compatible(root, "pika,warp"))
> +             return 0;
> +
> +     return 1;

I should have noticed this earlier and it is really only a simple cleanup
but it could be done if you do another respin.

        return of_flat_dt_is_compatible(root, "pika,warp");

> +void warp_set_power_leds(int green, int red)
> +{
> +     static void __iomem *gpio_base = NULL;
> +     unsigned leds;
> +
> +     if (gpio_base == NULL) {
> +             struct device_node *np, *from;
> +             int i;
> +
> +             /* Power LEDS are on the second GPIO controller */
> +             for (from = NULL, i = 0; i < 2; ++i, from = np) {
> +                     np = of_find_compatible_node(from, NULL, 
> "ibm,gpio-440EP");
> +                     if (np == NULL) {
> +                             printk(KERN_ERR __FILE__ ": Unable to find 
> gpio\n");
> +                             return;
> +                     }
> +             }

                struct device_node *np;
                int i = 0;

                for_each_compatible_node(np, NULL, "ibm,gpio-440EP")
                        if (i++ == 1)
                                break;
                if (i < 2) {
                        printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
                        return;
                }

or

                struct device_node *np = of_find_compatible_node(NULL, NULL, 
"ibm,gpio-440EP");

                if (np)
                        np = of_find_compatible_node(np, NULL, 
"ibm,gpio-440EP");
                if (!np) {
                        printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
                        return;
                }

One small thing - all three solutions assume that the device tree
routines return the nodes in the order that they are in the dts file ...
which is OK for now, but something to consider.

> +             gpio_base = of_iomap(np, 0);

                of_node_put(np);

> +static int __devinit warp_fpga_init(void)

> +     irq = irq_of_parse_and_map(np, 0);
> +     if (irq  == NO_IRQ) {

                of_node_put(np);

> +             printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n");
> +             return -EBUSY;
> +     }
> +
> +     /* We do not call of_iomap here since it would map in the entire
> +      * fpga space, which is over 8k.
> +      */
> +     if (of_address_to_resource(np, 0, &res)) {

                of_node_put(np);

> +             printk(KERN_ERR __FILE__ ": Unable to get FPGA address\n");
> +             return -ENOENT;
> +     }

        of_node_put(np);

-- 
Cheers,
Stephen Rothwell                    [EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/

Attachment: pgphazTYnCgLR.pgp
Description: PGP signature

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Reply via email to