[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130522161422.GP1627@sirena.org.uk>
Date: Wed, 22 May 2013 11:14:22 -0500
From: Mark Brown <broonie@...nel.org>
To: yizhang.mrvl@...il.com
Cc: lgirdwood@...il.com, cxie4@...vell.com, jett.zhou@...vell.com,
linux-kernel@...r.kernel.org, Yi Zhang <yizhang@...vell.com>
Subject: Re: [PATCH] regulator: 88pm800: add regulator driver
On Wed, May 22, 2013 at 08:10:53PM +0800, yizhang.mrvl@...il.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().
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists