public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Margarita Olaya <magi@slimlogic.co.uk>
Cc: linux-kernel@vger.kernel.org, Liam Girdwood <lrg@slimlogic.co.uk>
Subject: Re: [PATCHv3 4/4] tps65912: add regulator driver
Date: Sun, 15 May 2011 10:01:59 -0700	[thread overview]
Message-ID: <20110515170158.GA11579@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <BANLkTimqHbToRUuA7Krj_n1HBah3hhXODw@mail.gmail.com>

On Fri, May 13, 2011 at 04:30:49PM -0500, Margarita Olaya wrote:
> The tps65912 consiste of 4 DCDCs and 10 LDOs. The output voltages can be
> configured by the SPI or I2C interface, they are meant to supply power
> to the main processor and other components.

Looks pretty good

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

though a few things that you could fix incrementally:

> +static unsigned int tps65912_get_mode(struct regulator_dev *dev)
> +{
> +	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> +	struct tps65912 *mfd = pmic->mfd;
> +	int pwm_mode, eco, mode = 0, id = rdev_get_id(dev);
> +
> +	switch (id) {
> +	case TPS65912_REG_DCDC1:
> +		pwm_mode = tps65912_reg_read(mfd, TPS65912_DCDC1_CTRL);
> +		eco = tps65912_reg_read(mfd, TPS65912_DCDC1_AVS);
> +		break;

This switch statement for the lookup could be factored out into a
separate function for sharing with set.

> +static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
> +{
> +	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> +	struct tps65912 *mfd = pmic->mfd;
> +	int id = rdev_get_id(dev), voltage = 0, range;
> +	int opvsel = 0, avsel = 0, sr, vsel;

You'd save code in this function if you made it into a get_voltage_sel()
- a large chunk of it is a selector to voltage lookup.

> +static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
> +{
> +	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> +	struct tps65912 *mfd = pmic->mfd;
> +	int id = rdev_get_id(dev);
> +	int vsel = 0;
> +	u8 reg;
> +
> +	reg = tps65912_get_ldo_sel_register(pmic, id);
> +	vsel = tps65912_reg_read(mfd, reg);
> +	vsel &= 0x3F;
> +
> +	return tps65912_vsel_to_uv_ldo(vsel);

This is just an open coded get_voltage_sel().

      reply	other threads:[~2011-05-15 17:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-13 21:30 [PATCHv3 4/4] tps65912: add regulator driver Margarita Olaya
2011-05-15 17:01 ` Mark Brown [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=20110515170158.GA11579@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=magi@slimlogic.co.uk \
    /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