lkml.org 
[lkml]   [2009]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] regulator/max1586: support increased V3 voltage range
From
Date
Philipp Zabel <philipp.zabel@gmail.com> writes:

<snip>
> @@ -164,14 +184,25 @@ static int max1586_pmic_probe(struct i2c_client *client,
> {
> struct regulator_dev **rdev;
> struct max1586_platform_data *pdata = client->dev.platform_data;
> - int i, id, ret = 0;
> + struct max1586_data *max1586;
> + int i, id, ret = -ENOMEM;
> +
> + max1586 = kzalloc(sizeof(struct max1586_data) +
> + sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
> + GFP_KERNEL);
> + if (!max1586)
> + goto out;
>
> - rdev = kzalloc(sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
> - GFP_KERNEL);
> - if (!rdev)
> - return -ENOMEM;
> + max1586->client = client;
>
> - ret = -EINVAL;
> + if (!pdata->v3_gain) {
> + ret = -EINVAL;
> + goto out_unmap;
> + }

> + max1586->min_uV = MAX1586_V3_MIN_UV * pdata->v3_gain / 1000000;
> + max1586->max_uV = MAX1586_V3_MAX_UV * pdata->v3_gain / 1000000;
My last comment : you'll overflow an integer capacity here, and will get
min_uV=max_uV=0.

Please replace by :
max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * (pdata->v3_gain / 1000);
max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * (pdata->v3_gain / 1000);

And then add my :
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.

--
Robert



\
 
 \ /
  Last update: 2009-05-28 21:01    [from the cache]
©2003-2011 Jasper Spaans