Re: [PATCH 1/2 v3] pinctrl: make a copy of pinmux map

From: Arnd Bergmann
Date: Wed Nov 30 2011 - 08:36:32 EST


On Wednesday 30 November 2011, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@xxxxxxxxxx>
>
> This makes a deep copy of the pinmux function map instead of
> keeping the copy supplied from the platform around. This makes
> it possible to tag the platforms map with __initdata as is also
> done as part of this patch.
>
> Rationale: a certain target platform (PXA) has numerous
> pinmux maps, many of which will be lying around unused after
> boot in a multi-platform binary. Instead, deep-copy the one
> we're going to use and tag them all __initdata so they go away
> after boot.
>
> Suggested-by: Arnd Bergmann <arnd.bergmann@xxxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Reviewed-by: Arnd Bergmann <arnd@xxxxxxxxxx>

> @@ -348,32 +351,48 @@ EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output);
> int __init pinmux_register_mappings(struct pinmux_map const *maps,
> unsigned num_maps)
> {
> + int ret = 0;
> int i;
>
> - if (pinmux_maps != NULL) {
> + if (pinmux_maps_num != 0) {
> pr_err("pinmux mappings already registered, you can only "
> "register one set of maps\n");
> return -EINVAL;
> }

A trick pointed out by Rusty Russell in a recent blog post [1] is to
not initialize the return value initially, but always set it only
in the error path so that the compiler can warn you when you ever
forget setting it in one path.

Arnd

[1] http://rusty.ozlabs.org/?p=232
--
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/