mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: atull@opensource.altera.com
Cc: linux@roeck-us.net, jdelvare@suse.de, lm-sensors@lm-sensors.org,
	lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
	delicious.quinoa@gmail.com, dinguyen@opensource.altera.com,
	yvanderv@opensource.altera.com
Subject: Re: [PATCH 2/2] pmbus: ltc2978: add regulator gating
Date: Thu, 21 Aug 2014 19:36:50 -0500	[thread overview]
Message-ID: <20140822003650.GQ24407@sirena.org.uk> (raw)
In-Reply-To: <1408659686-29106-3-git-send-email-atull@opensource.altera.com>

[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

On Thu, Aug 21, 2014 at 05:21:26PM -0500, atull@opensource.altera.com wrote:

> +config SENSORS_LTC2978_REGULATOR
> +	boolean "Regulator support for LTC2974, LTC2978, LTC3880, and LTC3883"
> +	default n

No need to say default n here, it's the default default.

> +	depends on SENSORS_LTC2978
> +	select REGULATOR

I'd expect a depends here.

> +#include <linux/regulator/driver.h>
> +#include <linux/regulator/machine.h>

If you need machine.h that's suspicious...  why do you need it?

> +static int ltc2978_write_pmbus_operation(struct regulator_dev *rdev, u8 value)
> +{
> +	struct device *dev = rdev_get_dev(rdev);
> +	struct i2c_client *client = to_i2c_client(dev->parent);
> +	int ret;
> +
> +	ret = pmbus_set_page(client, 0xff);
> +	if (ret < 0)
> +		return ret;
> +
> +	return i2c_smbus_write_byte_data(client, PMBUS_OPERATION, value);
> +}

This all looks very much like pmbus could use regmap and then the regmap
helpers.  I'd not insist on it though.  What I would however suggest is
that these functions should all be helpers which read the specific
page, addresses and bits to write from the driver structure - I bet the
code is going to be identical for most pmbus using regulators and so it
makes sense to share it like we do with the generic regmap functions.

That means that any good practice can be deployed more easily and any
API updates only need to update the helpers.

> +static struct regulator_init_data ltc2978_regulator_init = {
> +	.constraints = {
> +		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
> +	},
> +};

You should not be forcing this on, you don't know what's safe on any
given board.  Allow the board to specify constraints then it has
control.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-08-22  0:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21 22:21 [PATCH 0/2] add regulator support for pmbus and ltc2978 atull
2014-08-21 22:21 ` [PATCH 1/2] pmbus: add regulator support atull
2014-08-21 22:21 ` [PATCH 2/2] pmbus: ltc2978: add regulator gating atull
2014-08-22  0:36   ` Mark Brown [this message]
2014-08-22  1:18     ` Guenter Roeck
2014-08-22  1:26       ` Mark Brown
2014-08-22  2:30         ` Guenter Roeck
2014-08-22 15:30     ` atull
2014-08-22 21:14 ` [PATCH 0/2] add regulator support for pmbus and ltc2978 atull

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=20140822003650.GQ24407@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=atull@opensource.altera.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=dinguyen@opensource.altera.com \
    --cc=jdelvare@suse.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=yvanderv@opensource.altera.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®