On Wed, May 22, 2013 at 08:10:53PM +0800, [email protected] 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: signature.asc
Description: Digital signature

Reply via email to