linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/3] regulator: tps6586x: add and use correct voltage table
Date: Wed, 4 Dec 2013 10:31:36 +0100	[thread overview]
Message-ID: <20131204093136.GN19943@ulmo.nvidia.com> (raw)
In-Reply-To: <c70dc80179c8cfaa18c2665c342ce1bcd827d923.1386100296.git.stefan@agner.ch>

On Tue, Dec 03, 2013 at 08:57:28PM +0100, Stefan Agner wrote:
[...]
> Changes since v2:
>   - Removed reg_ from reg_version
>   - Moved walk through version dependent tables to find_regulator_info,
>     removed the inline definition. This reduces .o size and encapsulates
>     the logic of finding the right regulator into one function. It comes
>     with a slight code duplication, the table search now appears twice.

Well, the table was searched twice in the original patch, too, so this
variant isn't any worse, really.

> ---
>  arch/arm/boot/dts/tegra20-colibri-512.dtsi |  4 +-
>  drivers/regulator/tps6586x-regulator.c     | 91 +++++++++++++++++++++++-------
>  2 files changed, 74 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
[...]
> -static inline struct tps6586x_regulator *find_regulator_info(int id)
> +static struct tps6586x_regulator *find_regulator_info(int id, int version)
>  {
>  	struct tps6586x_regulator *ri;
> +	struct tps6586x_regulator *table = NULL;
> +	int num;
>  	int i;
>  
> +	switch (version) {
> +	case TPS658623:
> +		table = tps658623_regulator;
> +		num = ARRAY_SIZE(tps658623_regulator);
> +		break;
> +	case TPS658643:
> +		table = tps658643_regulator;
> +		num = ARRAY_SIZE(tps658643_regulator);
> +		break;
> +	}
> +

I think you still need to check for table to be valid here. Depending on
the version it might still be NULL.

> +	/* Search version specific table first */
> +	for (i = 0; i < num; i++) {
> +		ri = &table[i];
> +		if (ri->desc.id == id)
> +			return ri;
> +	}

So this would need to be wrapped in an "if (table) { }" block.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131204/cbaa8a9d/attachment.sig>

  reply	other threads:[~2013-12-04  9:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 19:57 [PATCH v3 0/3] regulator: tps6586x: add version detection and voltage tables Stefan Agner
2013-12-03 19:57 ` [PATCH v3 1/3] mfd: tps6586x: add version detection Stefan Agner
2013-12-04  9:24   ` Thierry Reding
2013-12-03 19:57 ` [PATCH v3 2/3] regulator: tps6586x: add and use correct voltage table Stefan Agner
2013-12-04  9:31   ` Thierry Reding [this message]
2013-12-03 19:57 ` [PATCH v3 3/3] ARM: tegra: correct Colibri T20 regulator settings Stefan Agner

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=20131204093136.GN19943@ulmo.nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).