From: broonie@opensource.wolfsonmicro.com (Mark Brown)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] mfd: Add Freescale's PMIC MC34708 support
Date: Fri, 20 Apr 2012 10:20:08 +0100 [thread overview]
Message-ID: <20120420092007.GA3892@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1334853521-23792-1-git-send-email-paul.liu@linaro.org>
On Fri, Apr 20, 2012 at 12:38:40AM +0800, Ying-Chun Liu (PaulLiu) wrote:
> +Sub-nodes:
> +- regulators : Contain the regulator nodes. The MC34708 regulators are
> + bound using their names as listed below for enabling.
> +
> + mc34708__sw1a : regulator SW1A
> + mc34708__sw1b : regulator SW1B
There's no point in including the chip name in the properties - the
device has already been bound at the device level, this is just noise
at this level.
> + int ret;
> + int i;
> +
> + memset(buf, 0, 3);
> + for (i = 0; i < PMIC_I2C_RETRY_TIMES; i++) {
> + ret = i2c_smbus_read_i2c_block_data(client, offset, 3, buf);
The I2C layer already has a retry mechanism, and obviously if I2C is
failing at all the board generally has serious problems.
In general I'm not 100% sure why you're not using the regmap API here -
it looks like the 24 bit I/O is just a block I/O. Alternatively you
could use regmap for the register I/O and then open code the 24 bit
access if they really are different. This would let you
make much more use of framework support.
> + return mc34708_reg_write(mc_pmic, offmask, mask | irqbit);
> +}
> +EXPORT_SYMBOL(mc34708_irq_mask);
You shouldn't be open coding stuff like this, you should be implementing
it using genirq. This again gives you better framework support.
> +static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
> + const struct i2c_client *client)
> +{
> + while (id->name[0]) {
> + if (strcmp(client->name, id->name) == 0)
> + return id;
> + id++;
> + }
> +
> + return NULL;
> +}
> +
> +static const struct i2c_device_id *i2c_get_device_id(const struct i2c_client
> + *idev)
> +{
> + const struct i2c_driver *idrv = to_i2c_driver(idev->dev.driver);
> +
> + return i2c_match_id(idrv->id_table, idev);
> +}
This stuff should be added as generic I2C helpers if it's useful.
> + if (pdata && pdata->flags & MC34708_USE_REGULATOR) {
> + struct mc34708_regulator_platform_data regulator_pdata = {
> + .num_regulators = pdata->num_regulators,
> + .regulators = pdata->regulators,
> + };
> +
> + mc34708_add_subdevice_pdata(mc_pmic, "%s-regulator",
> + ®ulator_pdata,
> + sizeof(regulator_pdata));
> + } else if (of_find_node_by_name(np, "regulators")) {
> + mc34708_add_subdevice(mc_pmic, "%s-regulator");
> + }
This shouldn't be conditional, the regulators are always physically
present and even if they're not actively managed we can look at their
setup.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120420/40e2b353/attachment.sig>
next prev parent reply other threads:[~2012-04-20 9:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 16:38 [PATCH 1/2] mfd: Add Freescale's PMIC MC34708 support Ying-Chun Liu (PaulLiu)
2012-04-19 16:38 ` [PATCH 2/2] regulator: Add Freescale's MC34708 regulators Ying-Chun Liu (PaulLiu)
2012-04-20 11:42 ` Mark Brown
2012-04-20 6:35 ` [PATCH 1/2] mfd: Add Freescale's PMIC MC34708 support Lothar Waßmann
2012-04-20 7:40 ` Robert Schwebel
2012-04-20 9:20 ` Mark Brown [this message]
2012-04-22 23:32 ` Marc Reilly
2012-07-04 7:37 ` Uwe Kleine-König
2012-07-04 13:44 ` Shawn Guo
2012-07-05 5:48 ` Ying-Chun Liu (PaulLiu)
2012-07-05 6:46 ` Ying-Chun Liu (PaulLiu)
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=20120420092007.GA3892@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).