Re: [PATCH 23/24] C6X: Power and Sleep Controller

Arnd Bergmann
2011-08-22T21:21:14Z

On Monday 22 August 2011 16:09:44 Mark Salter wrote:
> +void __init psc_init(void)
> +{
> + struct device_node *node;
> + const __be32 *p;
> + int i, len;
> +
> + node = of_find_compatible_node(NULL, NULL, "ti,c64x+psc");
> + if (!node)
> + return;
> +
> + psc.base = of_iomap(node, 0);
> + if (!psc.base) {
> + of_node_put(node);
> + return;
> + }
> +
> + p = of_get_property(node, "ti,number-psc-domains", &len);
> + if (p && len == sizeof(u32))
> + psc.num_domains = be32_to_cpup(p);
> +
> + p = of_get_property(node, "ti,number-psc-modules", &len);
> + if (p && len == sizeof(u32))
> + psc.num_modules = be32_to_cpup(p);
> +
> + p = of_get_property(node, "ti,module-domain-map", &len);
> + if (p) {
> + len /= sizeof(u32);
> + if (len > MAX_PSC_MODULES)
> + len = MAX_PSC_MODULES;
> + for (i = 0; i <= len; i++)
> + psc.module_domains[i] = be32_to_cpup(&p[i]);
> + }
> +
> + of_node_put(node);
> +}

I think this should be a proper driver instead, using a struct platform_driver
and a match table instead the hacky of_find_compatible_node. That is generally
the preferred approach for any nonessential code that can be initialized later
and is not referenced by core code. As far as I can tell, this is the case
here, though I could not actually find the callers so far.

Arnd