mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: yizhang.mrvl@gmail.com
Cc: lgirdwood@gmail.com, cxie4@marvell.com, jett.zhou@marvell.com,
	linux-kernel@vger.kernel.org, Yi Zhang <yizhang@marvell.com>
Subject: Re: [PATCH] regulator: 88pm800: add regulator driver
Date: Wed, 22 May 2013 11:14:22 -0500	[thread overview]
Message-ID: <20130522161422.GP1627@sirena.org.uk> (raw)
In-Reply-To: <1369224653-27150-1-git-send-email-yizhang.mrvl@gmail.com>

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

On Wed, May 22, 2013 at 08:10:53PM +0800, yizhang.mrvl@gmail.com wrote:

You need a DT binding document for any new DT bindings like this one.

> +static const unsigned int BUCK1_table[] = {
> +	/* 0x00-0x4F: from 0.6 to 1.5875V with step 0.0125V */
> +	/* 0x50-0x7F: from 1.6 to 1.8V with step 0.05V */

Write this out as code, don't use a big table for large sets of
voltages.

> +static int pm800_list_voltage(struct regulator_dev *rdev, unsigned index)
> +{
> +	struct pm800_regulator_info *info = rdev_get_drvdata(rdev);
> +	int ret = -EINVAL;
> +
> +	if (info->vol_table && (index < rdev->desc->n_voltages))
> +		ret = info->vol_table[index];
> +
> +	return ret;
> +}

For things that are just table lookups use the framework helpers.

> +static int choose_voltage(struct regulator_dev *rdev, int min_uv, int max_uv)
> +{

Similarly here.

> +static int pm800_set_voltage(struct regulator_dev *rdev,
> +			     int min_uv, int max_uv, unsigned *sel)
> +{
> +	*sel = choose_voltage(rdev, min_uv, max_uv);
> +	if (*sel < 0)
> +		return -EINVAL;
> +	return regulator_set_voltage_sel_regmap(rdev, *sel);
> +}

Implement map_voltage.

> +	for_each_child_of_node(nproot, np) {
> +		if (!of_node_cmp(np->name, info->desc.name)) {
> +			config->init_data =
> +				of_get_regulator_init_data(&pdev->dev, np);
> +			config->of_node = np;
> +			break;
> +		}
> +	}

Use of_regulator_match().

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

  reply	other threads:[~2013-05-22 16:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-22 12:10 yizhang.mrvl
2013-05-22 16:14 ` Mark Brown [this message]
2013-05-24  3:01   ` yi zhang
2013-05-25 19:56     ` Mark Brown
2013-05-28  2:32       ` yi zhang
2013-05-28 10:04         ` Mark Brown
2013-05-28 12:10           ` Chao Xie
2013-05-28 14:20             ` 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=20130522161422.GP1627@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=cxie4@marvell.com \
    --cc=jett.zhou@marvell.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yizhang.mrvl@gmail.com \
    --cc=yizhang@marvell.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®