Re: [PATCH 2/2] regulator: tps80031: add regulator driver fortps80031

From: Mark Brown
Date: Mon Nov 05 2012 - 05:42:40 EST


On Mon, Nov 05, 2012 at 03:14:18PM +0530, Laxman Dewangan wrote:

> + switch (ri->device_flags) {
> + case 0:

Should we be using different versions of the ops depending on the device
flags rather than having these switches? It seems like we can't change
at runtime and it would make the code a lot simpler.

> + if (sel < 57)
> + voltage = 607700 + 12660 * sel;
> + else if (sel == 57)
> + voltage = 1350 * 1000;
> + else if (sel == 58)
> + voltage = 1500 * 1000;
> + else if (sel == 59)
> + voltage = 1800 * 1000;
> + else if (sel == 60)
> + voltage = 1900 * 1000;
> + else if (sel == 61)
> + voltage = 2100 * 1000;

This looks like a switch statement with a default case (as do most of
these).

> + ret = tps80031_write(parent, ri->rinfo->volt_id,
> + ri->rinfo->volt_reg, sel + 1);

Why the + 1 (and - 1 in the get()). I'd expect we can just use the
register value directly as a selector.

> + if (!(ri->config_flags & VBUS_SW_ONLY)) {
> + dev_err(&rdev->dev, "%s() is not supported with flag 0x%08x\n",
> + __func__, ri->config_flags);
> + return -EIO;
> + }

Same as the device flags above - we should this be set by changing the
ops when we register?

Attachment: signature.asc
Description: Digital signature