All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
Cc: swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org,
	dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	kai.poggensee-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org,
	sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [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-XLVq0VzYD2Y@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]

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.


[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
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>

WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: Stefan Agner <stefan@agner.ch>
Cc: swarren@wwwdotorg.org, dev@lynxeye.de, lee.jones@linaro.org,
	lgirdwood@gmail.com, broonie@kernel.org,
	kai.poggensee@avionic-design.de, sameo@linux.intel.com,
	linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [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>

[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]

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.


[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

Thread overview: 17+ 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 ` Stefan Agner
2013-12-03 19:57 ` Stefan Agner
2013-12-03 19:57 ` [PATCH v3 2/3] regulator: tps6586x: add and use correct voltage table Stefan Agner
2013-12-03 19:57   ` Stefan Agner
     [not found]   ` <c70dc80179c8cfaa18c2665c342ce1bcd827d923.1386100296.git.stefan-XLVq0VzYD2Y@public.gmane.org>
2013-12-04  9:31     ` Thierry Reding [this message]
2013-12-04  9:31       ` Thierry Reding
2013-12-04  9:31       ` Thierry Reding
     [not found] ` <cover.1386100296.git.stefan-XLVq0VzYD2Y@public.gmane.org>
2013-12-03 19:57   ` [PATCH v3 1/3] mfd: tps6586x: add version detection Stefan Agner
2013-12-03 19:57     ` Stefan Agner
2013-12-03 19:57     ` Stefan Agner
     [not found]     ` <77384d24810d9a22fc04cad6f7468f54a9cbaafe.1386100296.git.stefan-XLVq0VzYD2Y@public.gmane.org>
2013-12-04  9:24       ` Thierry Reding
2013-12-04  9:24         ` Thierry Reding
2013-12-04  9:24         ` Thierry Reding
2013-12-03 19:57   ` [PATCH v3 3/3] ARM: tegra: correct Colibri T20 regulator settings Stefan Agner
2013-12-03 19:57     ` Stefan Agner
2013-12-03 19:57     ` 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-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=dev-8ppwABl0HbeELgA04lAiVw@public.gmane.org \
    --cc=kai.poggensee-RM9K5IK7kjKj5M59NBduVrNAH6kLmebB@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=stefan-XLVq0VzYD2Y@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.