public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd.bergmann@linaro.org>
To: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-kernel@vger.kernel.org, Stephen Warren <swarren@nvidia.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Barry Song <21cnbao@gmail.com>,
	Shawn Guo <shawn.guo@freescale.com>,
	Thomas Abraham <thomas.abraham@linaro.org>,
	Dong Aisheng <dong.aisheng@linaro.org>,
	Rajendra Nayak <rajendra.nayak@linaro.org>,
	Haojian Zhuang <haojian.zhuang@marvell.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 1/2 v3] pinctrl: make a copy of pinmux map
Date: Wed, 30 Nov 2011 13:30:08 +0000	[thread overview]
Message-ID: <201111301330.09043.arnd.bergmann@linaro.org> (raw)
In-Reply-To: <1322656361-6463-1-git-send-email-linus.walleij@stericsson.com>

On Wednesday 30 November 2011, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> 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@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Arnd Bergmann <arnd@linaro.org>

> @@ -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

  reply	other threads:[~2011-11-30 13:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-30 12:32 [PATCH 1/2 v3] pinctrl: make a copy of pinmux map Linus Walleij
2011-11-30 13:30 ` Arnd Bergmann [this message]
2011-11-30 15:22   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201111301330.09043.arnd.bergmann@linaro.org \
    --to=arnd.bergmann@linaro.org \
    --cc=21cnbao@gmail.com \
    --cc=dong.aisheng@linaro.org \
    --cc=grant.likely@secretlab.ca \
    --cc=haojian.zhuang@marvell.com \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rajendra.nayak@linaro.org \
    --cc=shawn.guo@freescale.com \
    --cc=swarren@nvidia.com \
    --cc=thomas.abraham@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox