From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Daniel Ribeiro <drwyrm@gmail.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
linux-kernel <linux-kernel@vger.kernel.org>,
Eric Miao <eric.y.miao@gmail.com>,
David Brownell <david-b@pacbell.net>,
Pierre Ossman <pierre@ossman.eu>,
openezx-devel <openezx-devel@lists.openezx.org>,
linux-arm-kernel <linux-arm-kernel@lists.arm.linux.org.uk>
Subject: Re: [PATCHv2 2/2] PCAP regulator driver (for 2.6.32)
Date: Sat, 27 Jun 2009 02:04:34 +0100 [thread overview]
Message-ID: <20090627010434.GC4379@sirena.org.uk> (raw)
In-Reply-To: <1246057721.10360.318.camel@brutus>
On Fri, Jun 26, 2009 at 08:08:41PM -0300, Daniel Ribeiro wrote:
> Changed: Removed workaround for regulator use_count issues.
The usual place for these comments is after the --- with the diffstat
(the tools can then deal automatically with them). Incidentally, the
code you had would only help pxamci with this particular regulator
driver.
> Add (partial) support for the voltage regulators on the PCAP2 PMIC.
>
> Signed-off-by: Daniel Ribeiro <drwyrm@gmail.com>
Sorry, I've noticed a race condition below that I didn't spot first time
round below:
> +static int pcap_regulator_set_voltage(struct regulator_dev *rdev,
> + int min_uV, int max_uV)
> +{
> + struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];
> + void *pcap = rdev_get_drvdata(rdev);
> + int uV;
> + u32 tmp;
> + u8 i;
> +
> + if (vreg->n_voltages == 1)
> + return -EINVAL;
It'd be a little more friendly to check if the supported voltage is in
the requested range. However, that'd only be an issue if constraints
allowed voltage changes which is obviously broken so a comment to that
effect would be enough. I wouldn't have mentioned it but...
> +{
> + struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)];
> + void *pcap = rdev_get_drvdata(rdev);
> + u32 tmp;
> +
> + if (vreg->en == NA)
> + return -EINVAL;
> +
> + ezx_pcap_read(pcap, vreg->reg, &tmp);
> + tmp |= (1 << vreg->en);
> + ezx_pcap_write(pcap, vreg->reg, tmp);
This read/modify/write cycle is racy; the individual regulator is locked
by the core but this register is shared between all regulators on the
chip so if two are being updated at once things will go wrong. Most of
the MFDs have a set_bits() function that does an atomic read/modify/write
cycle for cases like this.
next prev parent reply other threads:[~2009-06-27 1:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-26 23:08 [PATCHv2 2/2] PCAP regulator driver (for 2.6.32) Daniel Ribeiro
2009-06-27 1:04 ` Mark Brown [this message]
2009-06-27 2:14 ` Daniel Ribeiro
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=20090627010434.GC4379@sirena.org.uk \
--to=broonie@opensource.wolfsonmicro.com \
--cc=david-b@pacbell.net \
--cc=drwyrm@gmail.com \
--cc=eric.y.miao@gmail.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=openezx-devel@lists.openezx.org \
--cc=pierre@ossman.eu \
/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