hwmon: pm8xxx-adc: Fix reading sysfs for vbatt

The memory where the sysfs attribute is stored on
initialization gets overwritten causing invalid length
on the vbatt sysfs reading. Fix it by removing the
dynamic memory allocation for BTM parameters.

Change-Id: If8b88c9460b0018a159688b5ba28798d97e0b0b6
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
This commit is contained in:
Siddartha Mohanadoss
2012-01-06 16:31:44 -08:00
parent ad4b25a942
commit 402673e9a0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -145,7 +145,7 @@ struct pm8xxx_adc {
struct wake_lock adc_wakelock;
int msm_suspend_check;
struct pm8xxx_adc_amux_properties *conv;
struct pm8xxx_adc_arb_btm_param batt[0];
struct pm8xxx_adc_arb_btm_param batt;
struct sensor_device_attribute sens_attr[0];
};
@@ -451,8 +451,8 @@ static void pm8xxx_adc_btm_warm_scheduler_fn(struct work_struct *work)
spin_lock_irqsave(&adc_pmic->btm_lock, flags);
warm_status = irq_read_line(adc_pmic->btm_warm_irq);
if (adc_pmic->batt->btm_warm_fn != NULL)
adc_pmic->batt->btm_warm_fn(warm_status);
if (adc_pmic->batt.btm_warm_fn != NULL)
adc_pmic->batt.btm_warm_fn(warm_status);
spin_unlock_irqrestore(&adc_pmic->btm_lock, flags);
}
@@ -465,8 +465,8 @@ static void pm8xxx_adc_btm_cool_scheduler_fn(struct work_struct *work)
spin_lock_irqsave(&adc_pmic->btm_lock, flags);
cool_status = irq_read_line(adc_pmic->btm_cool_irq);
if (adc_pmic->batt->btm_cool_fn != NULL)
adc_pmic->batt->btm_cool_fn(cool_status);
if (adc_pmic->batt.btm_cool_fn != NULL)
adc_pmic->batt.btm_cool_fn(cool_status);
spin_unlock_irqrestore(&adc_pmic->btm_lock, flags);
}
@@ -860,7 +860,7 @@ uint32_t pm8xxx_adc_btm_configure(struct pm8xxx_adc_arb_btm_param *btm_param)
if (rc < 0)
goto write_err;
adc_pmic->batt->btm_cool_fn = btm_param->btm_cool_fn;
adc_pmic->batt.btm_cool_fn = btm_param->btm_cool_fn;
}
if (btm_param->btm_warm_fn != NULL) {
@@ -874,7 +874,7 @@ uint32_t pm8xxx_adc_btm_configure(struct pm8xxx_adc_arb_btm_param *btm_param)
if (rc < 0)
goto write_err;
adc_pmic->batt->btm_warm_fn = btm_param->btm_warm_fn;
adc_pmic->batt.btm_warm_fn = btm_param->btm_warm_fn;
}
rc = pm8xxx_adc_read_reg(PM8XXX_ADC_ARB_BTM_CNTRL1, &arb_btm_cntrl1);
@@ -952,10 +952,10 @@ static uint32_t pm8xxx_adc_btm_read(uint32_t channel)
if (rc < 0)
goto write_err;
if (pmic_adc->batt->btm_warm_fn != NULL)
if (pmic_adc->batt.btm_warm_fn != NULL)
enable_irq(adc_pmic->btm_warm_irq);
if (pmic_adc->batt->btm_cool_fn != NULL)
if (pmic_adc->batt.btm_cool_fn != NULL)
enable_irq(adc_pmic->btm_cool_irq);
write_err:
@@ -1159,7 +1159,6 @@ static int __devinit pm8xxx_adc_probe(struct platform_device *pdev)
}
adc_pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8xxx_adc) +
sizeof(struct pm8xxx_adc_arb_btm_param) +
(sizeof(struct sensor_device_attribute) *
pdata->adc_num_board_channel), GFP_KERNEL);
if (!adc_pmic) {