diff options
author | Dan Carpenter <error27@gmail.com> | 2010-05-26 18:54:09 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-08-12 05:27:18 -0400 |
commit | eb6e8ddf06ff0d6b6548ca0b95a4edfeb2aaadd0 (patch) | |
tree | 4763ef7bf41e50e3d443fefc3a58faa3ee0df31a /drivers/mfd | |
parent | d281b80c46da8bae806c4ef5682187f07e35389d (diff) |
mfd: Fix 88pm860x uninitialized variable and clean up
The original code had a compile warning:
drivers/mfd/88pm860x-core.c:431: warning: ‘ret’ may be used
uninitialized in this function
It seems like the warning is valid if either pdata or pdata->touch is
NULL.
This patch checks pdata and pdata->touch at the beginning of the
function. That means everything can be pulled in one indent level.
Now all the statements fit within the 80 character limit.
Also at that point the "use_gpadc" variable isn't needed and removing
it simplifies the logic.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Haojian Zhuang <hzhuang1@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/88pm860x-core.c | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index 1580f1f2ec62..07933f3f7e4c 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c | |||
@@ -428,52 +428,44 @@ static int __devinit device_gpadc_init(struct pm860x_chip *chip, | |||
428 | { | 428 | { |
429 | struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ | 429 | struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ |
430 | : chip->companion; | 430 | : chip->companion; |
431 | int use_gpadc = 0, data, ret; | 431 | int data; |
432 | int ret; | ||
432 | 433 | ||
433 | /* initialize GPADC without activating it */ | 434 | /* initialize GPADC without activating it */ |
434 | 435 | ||
435 | if (pdata && pdata->touch) { | 436 | if (!pdata || !pdata->touch) |
436 | /* set GPADC MISC1 register */ | 437 | return -EINVAL; |
437 | data = 0; | ||
438 | data |= (pdata->touch->gpadc_prebias << 1) | ||
439 | & PM8607_GPADC_PREBIAS_MASK; | ||
440 | data |= (pdata->touch->slot_cycle << 3) | ||
441 | & PM8607_GPADC_SLOT_CYCLE_MASK; | ||
442 | data |= (pdata->touch->off_scale << 5) | ||
443 | & PM8607_GPADC_OFF_SCALE_MASK; | ||
444 | data |= (pdata->touch->sw_cal << 7) | ||
445 | & PM8607_GPADC_SW_CAL_MASK; | ||
446 | if (data) { | ||
447 | ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); | ||
448 | if (ret < 0) | ||
449 | goto out; | ||
450 | } | ||
451 | /* set tsi prebias time */ | ||
452 | if (pdata->touch->tsi_prebias) { | ||
453 | data = pdata->touch->tsi_prebias; | ||
454 | ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); | ||
455 | if (ret < 0) | ||
456 | goto out; | ||
457 | } | ||
458 | /* set prebias & prechg time of pen detect */ | ||
459 | data = 0; | ||
460 | data |= pdata->touch->pen_prebias & PM8607_PD_PREBIAS_MASK; | ||
461 | data |= (pdata->touch->pen_prechg << 5) | ||
462 | & PM8607_PD_PRECHG_MASK; | ||
463 | if (data) { | ||
464 | ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); | ||
465 | if (ret < 0) | ||
466 | goto out; | ||
467 | } | ||
468 | 438 | ||
469 | use_gpadc = 1; | 439 | /* set GPADC MISC1 register */ |
440 | data = 0; | ||
441 | data |= (pdata->touch->gpadc_prebias << 1) & PM8607_GPADC_PREBIAS_MASK; | ||
442 | data |= (pdata->touch->slot_cycle << 3) & PM8607_GPADC_SLOT_CYCLE_MASK; | ||
443 | data |= (pdata->touch->off_scale << 5) & PM8607_GPADC_OFF_SCALE_MASK; | ||
444 | data |= (pdata->touch->sw_cal << 7) & PM8607_GPADC_SW_CAL_MASK; | ||
445 | if (data) { | ||
446 | ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); | ||
447 | if (ret < 0) | ||
448 | goto out; | ||
470 | } | 449 | } |
471 | 450 | /* set tsi prebias time */ | |
472 | /* turn on GPADC */ | 451 | if (pdata->touch->tsi_prebias) { |
473 | if (use_gpadc) { | 452 | data = pdata->touch->tsi_prebias; |
474 | ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, | 453 | ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); |
475 | PM8607_GPADC_EN, PM8607_GPADC_EN); | 454 | if (ret < 0) |
455 | goto out; | ||
476 | } | 456 | } |
457 | /* set prebias & prechg time of pen detect */ | ||
458 | data = 0; | ||
459 | data |= pdata->touch->pen_prebias & PM8607_PD_PREBIAS_MASK; | ||
460 | data |= (pdata->touch->pen_prechg << 5) & PM8607_PD_PRECHG_MASK; | ||
461 | if (data) { | ||
462 | ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); | ||
463 | if (ret < 0) | ||
464 | goto out; | ||
465 | } | ||
466 | |||
467 | ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, | ||
468 | PM8607_GPADC_EN, PM8607_GPADC_EN); | ||
477 | out: | 469 | out: |
478 | return ret; | 470 | return ret; |
479 | } | 471 | } |