public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Alberto Panizzo <maramaopercheseimorto@gmail.com>
Cc: "Samuel Ortiz" <sameo@linux.intel.com>,
	"Sascha linux-arm" <s.hauer@pengutronix.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-arm-kernel-infradead <linux-arm-kernel@lists.infradead.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH 3/4] regulator: add voltage selection capability to mc13783 regulators.
Date: Sat, 12 Dec 2009 18:22:39 +0000	[thread overview]
Message-ID: <20091212182239.GD3092@sirena.org.uk> (raw)
In-Reply-To: <1260636976.2054.36.camel@climbing-alby>

On Sat, Dec 12, 2009 at 05:56:16PM +0100, Alberto Panizzo wrote:
> This patch, complete the mc13783 regulator subsystem driver with 
> voltage selecting capability.
> Main Switches (SW1AB, SW2AB) are not supported yet.
> 
> Signed-off-by: Alberto Panizzo <maramaopercheseimorto@gmail.com>

This is broadly OK but there are a number of issues, mostly stylistic
which it would be better to fix.  scripts/checkpatch.pl will catch a lot
of these.

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

on the basis that the code is correct, though.

> +static int mc13783_regulator_list_voltage (struct regulator_dev *rdev, unsigned selector)

These long lines really ought to be wrapped, and you've got an extra
space before the ( which isn't the usual coding style.  There's lots of
other odditities with things like this which checkpatch should catch.

> +static int mc13783_get_best_voltage_index(struct regulator_dev *rdev,
> +						int min_uV, int max_uV)
> +{
> +	int reg_id = rdev_get_id(rdev);
> +	int i;
> +	int bestmatch;
> +	int bestindex;
> +
> +	/*
> +	 * Locate the minimum voltage fitting the criteria on
> +	 * this regulator. The switchable voltages are not
> +	 * in strict falling order so we need to check them
> +	 * all for the best match.
> +	 */
> +	bestmatch = INT_MAX;
> +	bestindex = -1;
> +	for (i = 0; i < mc13783_regulators[reg_id].desc.n_voltages; i++) {
> +		if (mc13783_regulators[reg_id].voltages[i] <= max_uV &&
> +		    mc13783_regulators[reg_id].voltages[i] >= min_uV &&
> +		    mc13783_regulators[reg_id].voltages[i] < bestmatch) {
> +			bestmatch = mc13783_regulators[reg_id].voltages[i];
> +			bestindex = i;
> +		}
> +	}

Not that it makes much difference but you could just ignore max_uV until
you're done then check it once at the end since you're selecting for the
lowest matching voltage anyway.

> +	/* If it is a fixed regulator*/
> +	if (mc13783_regulators[id].desc.n_voltages == 1)
> +	{

if (...)  {

though it might be as well to define the fixed voltage regulators
separately with their own get and list functions rather than special
casing like this.

> +	mc13783_lock(priv->mc13783);
> +	ret = mc13783_reg_read( priv->mc13783,
> +				mc13783_regulators[id].vsel_reg, &val);

Extra space after the (.

  parent reply	other threads:[~2009-12-13  1:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-12 16:37 [PATCH 0/4] Patch series for introduce voltage selecting for mc13783 regulators Alberto Panizzo
2009-12-12 16:48 ` [PATCH 1/4] mfd: mc13783: Take care of semantic inversion between read and write value of two bits in POWER_MISCELLANEUS register Alberto Panizzo
2009-12-12 16:53   ` [PATCH 2/4] mfd: mc13783: When probing, unlock the mc13783 before subsystems initialisation Alberto Panizzo
2009-12-12 16:56     ` [PATCH 3/4] regulator: add voltage selection capability to mc13783 regulators Alberto Panizzo
2009-12-12 17:06       ` [PATCH 4/4] regulator: mc13783 change to platform_driver_register Alberto Panizzo
2009-12-12 18:23         ` Mark Brown
2009-12-13 20:05         ` Uwe Kleine-König
2009-12-14 10:59           ` Alberto Panizzo
2009-12-12 18:22       ` Mark Brown [this message]
2009-12-13 20:01       ` [PATCH 3/4] regulator: add voltage selection capability to mc13783 regulators Uwe Kleine-König
2009-12-14 10:41         ` Alberto Panizzo
2009-12-14 11:04           ` Mark Brown
2009-12-13 19:57     ` [PATCH 2/4] mfd: mc13783: When probing, unlock the mc13783 before subsystems initialisation Uwe Kleine-König
2009-12-12 18:11   ` [PATCH 1/4] mfd: mc13783: Take care of semantic inversion between read and write value of two bits in POWER_MISCELLANEUS register Mark Brown
2009-12-13 19:56   ` Uwe Kleine-König
2009-12-14 10:14     ` Alberto Panizzo

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=20091212182239.GD3092@sirena.org.uk \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maramaopercheseimorto@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sameo@linux.intel.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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