From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: sonic zhang <sonic.adi@gmail.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
Linux Kernel <linux-kernel@vger.kernel.org>,
uclinux-dist-devel <uclinux-dist-devel@blackfin.uclinux.org>
Subject: Re: [PATCH v2] regulator: new drivers for AD5398 and AD5821
Date: Wed, 2 Jun 2010 11:33:29 +0100 [thread overview]
Message-ID: <20100602103329.GA2457@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1275468694.2545.1.camel@eight.analog.com>
On Wed, Jun 02, 2010 at 04:51:34PM +0800, sonic zhang wrote:
> +static int ad5398_read_reg(struct i2c_client *client, unsigned short *data)
> +{
> + unsigned short val;
> + int ret;
> +
> + ret = i2c_master_recv(client, (char *)&val, 2);
> + if (ret < 0) {
> + dev_err(&client->dev, "I2C read error\n");
> + return ret;
> + }
> + *data = swab16(val);
Should this not be a be16_to_cpu() or similar rather than an
unconditional byte swap? Presumably the byte swap is not going to be
needed if the CPU has the same endianness as the CPU that the system is
using.
> + /* read chip enable bit */
> + ret = ad5398_read_reg(client, &data);
> + if (ret < 0)
> + return ret;
> + /* prepare register data */
> + selector = (selector << chip->current_offset) & chip->current_mask;
> + selector |= (data & AD5398_CURRENT_EN_MASK);
The reason I was querying this code on the original submission is that
it is more normal to write this as something like
data = selector | (data & ~chip->current_mask);
ie, to write the code as "set these bits" rather than "preserve these
bits". This is more clearly robust to the reader since it's clear that
there aren't other register bits which should be set.
> + chip->min_uA = init_data->constraints.min_uA;
> + chip->max_uA = init_data->constraints.max_uA;
This looks very wrong, especially given that you use the min_uA and
max_uA settings to scale the register values being written in to the
chip. I would expect that either the limits would be fixed in the
silicon or (if they depend on things like the associated passives which
can be configured per-board) that there would be some other setting in
the platform data which specifies what's actually being changed.
The constraints being specified by the platform should not influence the
physical properties of the chip, they control which values are allowed
in a particular design (for example, saying that values over a given
limit are not allowed due to the limits of the hardware connected to the
regulator) and are separate to what the chip is capable of.
next prev parent reply other threads:[~2010-06-02 10:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-02 8:51 [PATCH v2] regulator: new drivers for AD5398 and AD5821 sonic zhang
2010-06-02 9:02 ` [Uclinux-dist-devel] " Mike Frysinger
2010-06-02 9:29 ` Sonic Zhang
2010-06-02 9:36 ` Mike Frysinger
2010-06-02 10:10 ` Sonic Zhang
2010-06-02 10:18 ` Mike Frysinger
2010-06-02 9:47 ` Mark Brown
2010-06-02 10:33 ` Mark Brown [this message]
2010-06-03 2:57 ` Sonic Zhang
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=20100602103329.GA2457@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=sonic.adi@gmail.com \
--cc=uclinux-dist-devel@blackfin.uclinux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox