From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: "Kim, Milo" <Milo.Kim@ti.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Girdwood, Liam" <lrg@ti.com>
Subject: Re: [PATCH] regulator: add new regulator driver for lp872x
Date: Wed, 23 May 2012 10:58:08 +0100 [thread overview]
Message-ID: <20120523095808.GD4085@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <A874F61F95741C4A9BA573A70FE3998FA17F@DQHE02.ent.ti.com>
[-- Attachment #1: Type: text/plain, Size: 3366 bytes --]
On Wed, May 23, 2012 at 07:50:59AM +0000, Kim, Milo wrote:
> +static int lp872x_read_byte(struct lp872x *lp, u8 addr, u8 *data)
> +{
> + int ret;
> + unsigned int val;
> +
> + mutex_lock(&lp->xfer_lock);
> + ret = regmap_read(lp->regmap, addr, &val);
> + if (ret < 0) {
> + mutex_unlock(&lp->xfer_lock);
> + dev_err(lp->dev, "failed to read 0x%.2x\n", addr);
> + return ret;
> + }
> + mutex_unlock(&lp->xfer_lock);
> +
> + *data = (u8)val;
> + return 0;
> +}
This should just be a trivial wrapper around regmap_read, the regmap API
handles concurrency for you. Similarly for all your other I/O
functions.
> +static int lp872x_ldo_list_voltage(struct regulator_dev *rdev,
> + unsigned selector)
regulator_list_voltage_table() will appear in -next just after the merge
window.
> +static int lp872x_ldo_set_voltage_sel(struct regulator_dev *rdev,
> + unsigned selector)
regulator_set_voltage_sel_regmap().
> +static int lp872x_ldo_get_voltage_sel(struct regulator_dev *rdev)
regulator_get_voltage_sel_regmap().
> +static int lp872x_regulator_enable(struct regulator_dev *rdev)
Your ENABLE define made the code a bit obscure but this is
regulator_enable_regmap()
> +static int lp872x_regualtor_disable(struct regulator_dev *rdev)
regulator_disable_regmap()
> +static int lp872x_regulator_is_enabled(struct regulator_dev *rdev)
regulator_is_enabled_regmap()
> +static int lp872x_buck_list_voltage(struct regulator_dev *rdev,
> + unsigned selector)
regulator_list_voltage_table()
> + case LP8720_ID_BUCK:
> + if (val & LP8720_EXT_DVS_M) {
> + pinstate = pdata->get_dvs_pin_state ?
> + pdata->get_dvs_pin_state() : DVS_LOW;
This is a really odd implementation. Why isn't the driver managing the
pin and what happens to the consumers that expected to set a voltage
when the pin gets changed?
> +static int lp8725_buck_enable(struct regulator_dev *rdev)
regulator_enable_regmap()
> +static int lp8725_buck_disable(struct regulator_dev *rdev)
regulator_disable_regmap()
> +static int lp8725_buck_is_enabled(struct regulator_dev *rdev)
regulator_is_enabled_regmap()
> + for (i = 0 ; i < num ; i++) {
> + regulator_data = lp->pdata->regulator_data + i;
> + desc = &lp872x_regulator_desc[regulator_data->id];
> + init_data = regulator_data->init_data;
> +
> + rdev = regulator_register(desc, lp->dev, init_data, lp, NULL);
> + if (IS_ERR(rdev)) {
> + dev_err(lp->dev, "regulator register err");
> + ret = PTR_ERR(rdev);
> + goto err;
> + }
You should unconditionally register all the regulators the chip has and
match the init_data to them rather than only registering regulators you
have init_data. This allows users to inspect unconfigured regulators
and allows the core to support things like powering off unused
regulators.
> +static const struct regmap_config lp872x_regmap_config = {
> + .reg_bits = 8,
> + .val_bits = 8,
> +};
Setting max_register would get you debugfs inspection of the regmap.
> + lp->regmap = regmap_init_i2c(cl, &lp872x_regmap_config);
devm_regmap_init_i2c().
> +/**
> + * lp872x_platform_data
> + * @general_config (mandatory) : the value of LP872X_GENERAL_CFG register
Is the chip default never valid?
> + * @regulator_data (mandatory) : platform regulator id and init data
> + * @num_regulators (mandatory) : total number of platform regulators
These should be optional.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-05-23 9:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 7:50 [PATCH] regulator: add new regulator driver for lp872x Kim, Milo
2012-05-23 9:58 ` Mark Brown [this message]
2012-06-15 8:44 ` Kim, Milo
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=20120523095808.GD4085@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=Milo.Kim@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.