lkml.org 
[lkml]   [2012]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] regulator: tps80031: add regulator driver for tps80031
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?
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2012-11-05 12:21    [W:0.073 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site