public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: Axel Lin <axel.lin@ingics.com>
Cc: Linus Walleij <linus.walleij@linaro.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: rockchip: Simplify for loop iteration
Date: Thu, 22 Aug 2013 11:01:09 +0200	[thread overview]
Message-ID: <201308221101.10749.heiko@sntech.de> (raw)
In-Reply-To: <1377052130.20078.0.camel@phoenix>

Am Mittwoch, 21. August 2013, 04:28:50 schrieb Axel Lin:
> Just return once a match found makes the code simpler and shorter.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

as I'm a bit late for an Ack it seems, I can only offer a thanks for making 
this nicer :-)


Heiko


> ---
>  drivers/pinctrl/pinctrl-rockchip.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c
> b/drivers/pinctrl/pinctrl-rockchip.c index c22457d..64ad0c0 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -167,18 +167,14 @@ static const inline struct rockchip_pin_group
> *pinctrl_name_to_group( const struct rockchip_pinctrl *info,
>  					const char *name)
>  {
> -	const struct rockchip_pin_group *grp = NULL;
>  	int i;
> 
>  	for (i = 0; i < info->ngroups; i++) {
> -		if (strcmp(info->groups[i].name, name))
> -			continue;
> -
> -		grp = &info->groups[i];
> -		break;
> +		if (!strcmp(info->groups[i].name, name))
> +			return &info->groups[i];
>  	}
> 
> -	return grp;
> +	return NULL;
>  }
> 
>  /*
> @@ -204,17 +200,12 @@ static struct rockchip_pin_bank *bank_num_to_bank(
>  	struct rockchip_pin_bank *b = info->ctrl->pin_banks;
>  	int i;
> 
> -	for (i = 0; i < info->ctrl->nr_banks; i++) {
> +	for (i = 0; i < info->ctrl->nr_banks; i++, b++) {
>  		if (b->bank_num == num)
> -			break;
> -
> -		b++;
> +			return b;
>  	}
> 
> -	if (b->bank_num != num)
> -		return ERR_PTR(-EINVAL);
> -
> -	return b;
> +	return ERR_PTR(-EINVAL);
>  }
> 
>  /*


      parent reply	other threads:[~2013-08-22  9:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-21  2:28 [PATCH] pinctrl: rockchip: Simplify for loop iteration Axel Lin
2013-08-21 22:32 ` Linus Walleij
2013-08-22  9:01 ` Heiko Stübner [this message]

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=201308221101.10749.heiko@sntech.de \
    --to=heiko@sntech.de \
    --cc=axel.lin@ingics.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.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