linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
Cc: linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com,
	lm-sensors@lm-sensors.org, linux-input@vger.kernel.org,
	linux-watchdog@vger.kernel.org, linux-leds@vger.kernel.org,
	"Samuel Ortiz" <sameo@linux.intel.com>,
	"Liam Girdwood" <lrg@ti.com>,
	"Alessandro Zummo" <a.zummo@towertech.it>,
	"Jean Delvare" <khali@linux-fr.org>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Ashish Jangam" <ashish.jangam@kpitcummins.com>,
	"Andrew Jones" <drjones@redhat.com>,
	"Donggeun Kim" <dg77.kim@samsung.com>,
	"Philippe Rétornaz" <philippe.retornaz@epfl.ch>,
	"Wim Van Sebroeck" <wim@iguana.be>,
	"Bryan Wu" <bryan.wu@canonical.com>,
	"Richard Purdie <rpurdie@rpsys.net> Anthony Olech"
	<anthony.olech@diasemi.com>
Subject: Re: [RFC PATCH 2/8] regulator: Add Dialog DA906x voltage regulators support.
Date: Sat, 25 Aug 2012 08:10:20 -0700	[thread overview]
Message-ID: <20120825151020.GB6520@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <201208241455@sw-eng-lt-dc-vm2>

On Fri, Aug 24, 2012 at 02:55:00PM +0100, Krystian Garbaciak wrote:

> +static int da906x_set_voltage(struct regulator_dev *rdev,
> +				int min_uV, int max_uV, unsigned *selector)
> +{
> +	struct da906x_regulator *regl = rdev_get_drvdata(rdev);
> +	const struct field *fvol = &regl->info->voltage;
> +	int ret;
> +	unsigned val;
> +
> +	val = regulator_map_voltage_linear(rdev, min_uV, max_uV);
> +	if (val < 0)
> +		return -EINVAL;
> +
> +	val = (val + fvol->offset) << fvol->shift;
> +	ret = da906x_reg_update(regl->hw, fvol->addr, fvol->mask, val);
> +	if (ret >= 0)
> +		*selector = val;
> +
> +	return ret;
> +}

This is just set_voltage_sel_regmap().

> +static int da906x_enable(struct regulator_dev *rdev)
> +{
> +	struct da906x_regulator *regl = rdev_get_drvdata(rdev);
> +	int ret;
> +
> +	if (regl->info->suspend.mask) {
> +		/* Make sure to exit from suspend mode on enable */
> +		ret = da906x_reg_clear_bits(regl->hw, regl->info->suspend.addr,
> +					    regl->info->suspend.mask);
> +		if (ret < 0)
> +			return ret;
> +
> +		/* BUCKs need mode update after wake-up from suspend state. */
> +		ret = da906x_update_mode_internal(regl, SYS_STATE_NORMAL);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
> +	return regulator_enable_regmap(rdev);

If suspend_mask is optional the regulators using it should just use the
standard operation.

> +/* Regulator event handlers */
> +irqreturn_t da906x_ldo_lim_event(int irq, void *data)

By "event handler" you mean "interrupt"

> +	bits = da906x_reg_read(hw, DA906X_REG_STATUS_D);
> +	if (bits < 0)
> +		return IRQ_HANDLED;

If you fail to detect an interrupt you report that you handled one...?

> +	if (!da906x_pdata) {
> +		dev_err(&pdev->dev, "No platform init data supplied\n");
> +		return -ENODEV;
> +	}

Platform data should be totally optional.

> +	bcores_merged = (ret & DA906X_BCORE_MERGE) ? true : false;
> +	bmem_bio_merged = (ret & DA906X_BUCK_MERGE) ? true : false;

The use of the ternery operation here is even worse than normal, you can
assign the values directly.

       reply	other threads:[~2012-08-25 15:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201208241445@sw-eng-lt-dc-vm2>
     [not found] ` <201208241450@sw-eng-lt-dc-vm2>
     [not found]   ` <201208241455@sw-eng-lt-dc-vm2>
2012-08-25 15:10     ` Mark Brown [this message]
2012-08-29 14:50       ` [RFC PATCH 2/8] regulator: Add Dialog DA906x voltage regulators support Krystian Garbaciak
2012-08-30 17:47         ` Mark Brown
2012-08-31 10:00           ` Krystian Garbaciak
2013-05-09 14:05             ` Guennadi Liakhovetski
2013-05-09 14:18               ` Anthony Olech
2013-05-09 14:28                 ` Guennadi Liakhovetski
2013-05-09 14:42                   ` Anthony Olech
2013-05-09 14:50                     ` Guennadi Liakhovetski
2012-08-25 18:31   ` [PATCH 1/8] mfd: Add Dialog DA906x core driver Mark Brown
2012-08-31 11:20     ` Krystian Garbaciak
2012-08-31 11:37       ` Philippe Rétornaz
2012-08-31 17:16       ` Mark Brown

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=20120825151020.GB6520@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=a.zummo@towertech.it \
    --cc=anthony.olech@diasemi.com \
    --cc=ashish.jangam@kpitcummins.com \
    --cc=bryan.wu@canonical.com \
    --cc=dg77.kim@samsung.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=drjones@redhat.com \
    --cc=khali@linux-fr.org \
    --cc=krystian.garbaciak@diasemi.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=lrg@ti.com \
    --cc=philippe.retornaz@epfl.ch \
    --cc=rtc-linux@googlegroups.com \
    --cc=sameo@linux.intel.com \
    --cc=wim@iguana.be \
    /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).