All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Laxman Dewangan <ldewangan.com@nvidia.com>
Cc: lrg@slimlogic.co.uk, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	ldewangan@nvidia.com
Subject: Re: [PATCH V1] TPS62360: Add tps62360 regulator driver
Date: Thu, 5 Jan 2012 06:29:19 +0000	[thread overview]
Message-ID: <20120105062919.GI11867@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1325668818-1096-1-git-send-email-ldewangan@nvidia.com>

On Wed, Jan 04, 2012 at 02:50:18PM +0530, Laxman Dewangan wrote:
> Change-Id: I93739aad865401047738f899b2248f2714d824ea

Don't include gerritt droppings in upstream submissions.

> +/* Supported voltage values for regulators */
> +static const u16 TPS62360_VOLTAGES[] = {
> +	 770,  780,  790,  800,  810,  820,  830,  840,  850,  860,
> +	 870,  880,  890,  900,  910,  920,  930,  940,  950,  960,
> +	 970,  980,  990, 1000, 1010, 1020, 1030, 1040, 1050, 1060,
> +	1070, 1080, 1090, 1110, 1110, 1120, 1130, 1140, 1150, 1160,
> +	1170, 1180, 1190, 1200, 1210, 1220, 1230, 1240, 1250, 1260,
> +	1270, 1280, 1290, 1300, 1310, 1320, 1330, 1340, 1350, 1360,
> +	1370, 1380, 1390, 1400,
> +};

Why are you using a lookup table here?  Just calaculate the values.
This is a pervasive problem with the TI drivers which leads me to
suspect cut'n'paste and therefore an opportunity to factor some code
out.

> +static int tps62360_reg_modify_bits(struct tps62360_chip *tps, u8 reg,
> +		u8 set_mask, u8 clear_mask)
> +{

There's a lot of code in this driver that looks like it could be
factored out by using the regmap API, not just the register I/O but also
the cache.

> +static int tps62360_dcdc_is_enabled(struct regulator_dev *dev)
> +{
> +	/**
> +	 * Always return 1 as the EN is not controlled by register
> +	 * programming */
> +	return 1;
> +}

Don't implement unsupported operations.

> +
> +	for (vsel = 0; vsel < tps->desc.n_voltages; ++vsel) {
> +		int uV = tps->voltages[vsel] * 1000;
> +		if (min_uV <= uV && uV <= max_uV) {

Not only do all the drivers coming in for these devices use lookup
tables they also all open code the lookup :/

> +	init_data = &pdata->reg_init_data;
> +	tps = kzalloc(sizeof(*tps), GFP_KERNEL);
> +	if (!tps) {

Use devm_kzalloc(), saves having to worry about cleanup.

> +static void tps62360_shutdown(struct i2c_client *client)
> +{
> +	struct tps62360_chip *tps = i2c_get_clientdata(client);
> +	int st;
> +
> +	if (!tps->en_discharge)
> +		return;
> +
> +	/* Configure the output discharge path */
> +	st = tps62360_reg_modify_bits(tps, REG_RAMPCTRL, BIT(2), BIT(2));
> +	if (st < 0)
> +		dev_err(tps->dev, "%s() fails in updating reg %d\n",
> +			__func__, REG_RAMPCTRL);
> +}

I rather suspect that if this is worth doing it's also worth doing over
suspend...

> +MODULE_DESCRIPTION("TPS62360 voltage regulator driver");
> +MODULE_LICENSE("GPL v2");
> +MODULE_ALIAS("platform:tps62360");

This isn't a platform driver, it's a driver for an I2C device.

> + * @vsel: Select the voltage id register.

What's this?

> + * @init_uV: initial micro volts which need to be set.

No, there's no way stuff like this should be being open coded in
individual regulator drivers - this isn't at all specific to this
regulator so it should be (and is) supported by the standard
constraints.

  reply	other threads:[~2012-01-05  6:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-04  9:20 [PATCH V1] TPS62360: Add tps62360 regulator driver Laxman Dewangan
2012-01-04  9:20 ` Laxman Dewangan
2012-01-05  6:29 ` Mark Brown [this message]
2012-01-05 13:48   ` Laxman Dewangan
2012-01-06 17:44     ` Mark Brown
     [not found]     ` <96C9D994977DD0439FB6D3FE3B13DD907DBD3A9E9B-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2012-01-06 18:57       ` Mark Brown
2012-01-06 18:57         ` Mark Brown
     [not found]         ` <20120106185755.GC2893-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-07 17:46           ` Laxman Dewangan
2012-01-07 17:46             ` Laxman Dewangan
     [not found]             ` <96C9D994977DD0439FB6D3FE3B13DD907DBD3AA0DE-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2012-01-07 19:10               ` Mark Brown
2012-01-07 19:10                 ` Mark Brown
2012-01-08  7:42                 ` Laxman Dewangan
     [not found]                   ` <96C9D994977DD0439FB6D3FE3B13DD907DBD3AA0E4-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2012-01-08 16:58                     ` Mark Brown
2012-01-08 16:58                       ` Mark Brown
     [not found]                       ` <20120108165819.GB29065-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-09  7:04                         ` Laxman Dewangan
2012-01-09  7:04                           ` Laxman Dewangan
2012-01-09  7:11                           ` Mark Brown
     [not found]                             ` <20120109071128.GA22134-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-09  7:33                               ` Laxman Dewangan
2012-01-09  7:33                                 ` Laxman Dewangan
     [not found]                                 ` <96C9D994977DD0439FB6D3FE3B13DD907DBDABA9B6-kdsAE/FnitNDw2glCA4ptUEOCMrvLtNR@public.gmane.org>
2012-01-09  7:39                                   ` Mark Brown
2012-01-09  7:39                                     ` Mark Brown
     [not found]                                     ` <20120109073859.GG22134-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-09  8:47                                       ` Laxman Dewangan
2012-01-09  8:47                                         ` Laxman Dewangan
2012-01-09  8:48                                         ` Mark Brown
2012-01-09  9:19                                           ` Laxman Dewangan

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=20120105062919.GI11867@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=ldewangan.com@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    /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.