@@ -1028,10 +1028,10 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
{
int irq, i, ret = 0;
u8 val;
- struct ab8500_platform_data *plat_data;
- struct ab8500_btemp *di;
+ struct ab8500_platform_data *plat;
- di = kzalloc(sizeof(*di), GFP_KERNEL);
+ struct ab8500_btemp *di =
+ kzalloc(sizeof(struct ab8500_btemp), GFP_KERNEL);
if (!di)
return -ENOMEM;
@@ -1042,22 +1042,23 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
di->initialized = false;
+ plat = dev_get_platdata(di->parent->dev);
+
/* get btemp specific platform data */
- plat_data = dev_get_platdata(di->parent->dev);
- di->pdata = plat_data->btemp;
- if (!di->pdata) {
+ if (!plat || !plat->btemp) {
dev_err(di->dev, "no btemp platform data supplied\n");
ret = -EINVAL;
goto free_device_info;
}
+ di->pdata = plat->btemp;
/* get battery specific platform data */
- di->bat = plat_data->battery;
- if (!di->bat) {
+ if (!plat->battery) {
dev_err(di->dev, "no battery platform data supplied\n");
ret = -EINVAL;
goto free_device_info;
}
+ di->bat = plat->battery;
/* BTEMP supply */
di->btemp_psy.name = "ab8500_btemp";
@@ -3319,10 +3319,10 @@ static int __devexit ab8500_charger_remove(struct platform_device *pdev)
static int __devinit ab8500_charger_probe(struct platform_device *pdev)
{
int irq, i, charger_status, ret = 0, ch_stat;
- struct ab8500_platform_data *plat_data;
- struct ab8500_charger *di;
+ struct ab8500_platform_data *plat;
- di = kzalloc(sizeof(*di), GFP_KERNEL);
+ struct ab8500_charger *di =
+ kzalloc(sizeof(struct ab8500_charger), GFP_KERNEL);
if (!di)
return -ENOMEM;
@@ -3335,24 +3335,24 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
spin_lock_init(&di->usb_state.usb_lock);
mutex_init(&di->usb_ipt_crnt_lock);
- /* get charger specific platform data */
- plat_data = dev_get_platdata(di->parent->dev);
+ plat = dev_get_platdata(di->parent->dev);
- di->pdata = plat_data->charger;
- if (!di->pdata) {
+ /* get charger specific platform data */
+ if (!plat || !plat->charger) {
dev_err(di->dev, "no charger platform data supplied\n");
ret = -EINVAL;
goto free_device_info;
}
+ di->pdata = plat->charger;
/* get battery specific platform data */
- di->bat = plat_data->battery;
- if (!di->bat) {
+ if (!plat->battery) {
dev_err(di->dev, "no battery platform data supplied\n");
ret = -EINVAL;
goto free_device_info;
}
+ di->bat = plat->battery;
di->autopower = false;
di->invalid_charger_detect_state = 0;
@@ -3158,10 +3158,10 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
{
int i, irq;
int ret = 0;
- struct ab8500_platform_data *plat_data;
- struct ab8500_fg *di;
+ struct ab8500_platform_data *plat;
- di = kzalloc(sizeof(*di), GFP_KERNEL);
+ struct ab8500_fg *di =
+ kzalloc(sizeof(struct ab8500_fg), GFP_KERNEL);
if (!di)
return -ENOMEM;
@@ -3172,22 +3172,23 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
di->parent = dev_get_drvdata(pdev->dev.parent);
di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
+ plat = dev_get_platdata(di->parent->dev);
+
/* get fg specific platform data */
- plat_data = dev_get_platdata(di->parent->dev);
- di->pdata = plat_data->fg;
- if (!di->pdata) {
+ if (!plat || !plat->fg) {
dev_err(di->dev, "no fg platform data supplied\n");
ret = -EINVAL;
goto free_device_info;
}
+ di->pdata = plat->fg;
/* get battery specific platform data */
- di->bat = plat_data->battery;
- if (!di->bat) {
+ if (!plat->battery) {
dev_err(di->dev, "no battery platform data supplied\n");
ret = -EINVAL;
goto free_device_info;
}
+ di->bat = plat->battery;
di->fg_psy.name = "ab8500_fg";
di->fg_psy.type = POWER_SUPPLY_TYPE_BATTERY;
@@ -1918,7 +1918,7 @@ static int __devexit abx500_chargalg_remove(struct platform_device *pdev)
static int __devinit abx500_chargalg_probe(struct platform_device *pdev)
{
- struct ab8500_platform_data *plat_data;
+ struct ab8500_platform_data *plat;
int ret = 0;
struct abx500_chargalg *di =
@@ -1926,12 +1926,27 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev)
if (!di)
return -ENOMEM;
- /* get device struct */
+ /* get parent data */
di->dev = &pdev->dev;
di->parent = dev_get_drvdata(pdev->dev.parent);
- plat_data = dev_get_platdata(di->parent->dev);
- di->pdata = plat_data->chargalg;
- di->bat = plat_data->battery;
+
+ plat = dev_get_platdata(di->parent->dev);
+
+ /* get chargalg specific platform data */
+ if (!plat || !plat->chargalg) {
+ dev_err(di->dev, "no chargalg platform data supplied\n");
+ ret = -EINVAL;
+ goto free_device_info;
+ }
+ di->pdata = plat->chargalg;
+
+ /* get battery specific platform data */
+ if (!plat->battery) {
+ dev_err(di->dev, "no battery platform data supplied\n");
+ ret = -EINVAL;
+ goto free_device_info;
+ }
+ di->bat = plat->battery;
/* chargalg supply */
di->chargalg_psy.name = "abx500_chargalg";