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: [PATCHv2 4/4] tps65912: add regulator driver
Date: Sat, 14 May 2011 09:27:06 -0700	[thread overview]
Message-ID: <20110514162705.GG2791@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <BANLkTi=xj_eskCt5BT3pThy6pSBhGNsMTA@mail.gmail.com>

On Thu, May 12, 2011 at 01:44:05PM -0500, Margarita Olaya wrote:
> The tps65912 consist 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.
> 
> Signed-off-by: Margarita Olaya Cabrera <magi@slimlogic.co.uk>

A few fairly minor issues, and one thing that I just want you to
confirm...

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

A helper function for this switch statement might be useful, it's used
by both get and set mode calls.

> +static int tps65912_set_voltage_ldo(struct regulator_dev *dev,
> +						unsigned selector)
> +{
> +	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
> +	struct tps65912 *mfd = pmic->mfd;
> +	int id = rdev_get_id(dev), reg, value;
> +
> +	reg = tps65912_get_ldo_sel_register(pmic, id);
> +	value = tps65912_reg_read(mfd, reg);
> +	value &= 0xC0;
> +	return tps65912_reg_write(mfd, reg, selector | value);
> +}

I *think* the register only contains things for this regulator so you
don't need locking beyond the lock the regulator API guarantees you but
if that's not the case you'd need to ensure nothing could jump into the
middle of the read/modify/write cycle.

A comment would help.

      reply	other threads:[~2011-05-14 16:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 18:44 [PATCHv2 4/4] tps65912: add regulator driver Margarita Olaya
2011-05-14 16:27 ` 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=20110514162705.GG2791@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