Commit 2aac3de19b72608f474c90034185c2be4908728f
Committed by
Anton Vorontsov
1 parent
5f98eb393c
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ab8500: Clean up probe routines
These patches clean up some ugliness and brings the variable initialisation formatting more into line with other drivers. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Showing 3 changed files with 30 additions and 18 deletions Side-by-side Diff
drivers/power/ab8500_btemp.c
... | ... | @@ -964,10 +964,15 @@ |
964 | 964 | { |
965 | 965 | int irq, i, ret = 0; |
966 | 966 | u8 val; |
967 | - struct abx500_bm_plat_data *plat_data; | |
967 | + struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data; | |
968 | + struct ab8500_btemp *di; | |
968 | 969 | |
969 | - struct ab8500_btemp *di = | |
970 | - kzalloc(sizeof(struct ab8500_btemp), GFP_KERNEL); | |
970 | + if (!plat_data) { | |
971 | + dev_err(&pdev->dev, "No platform data\n"); | |
972 | + return -EINVAL; | |
973 | + } | |
974 | + | |
975 | + di = kzalloc(sizeof(*di), GFP_KERNEL); | |
971 | 976 | if (!di) |
972 | 977 | return -ENOMEM; |
973 | 978 | |
974 | 979 | |
... | ... | @@ -977,13 +982,12 @@ |
977 | 982 | di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
978 | 983 | |
979 | 984 | /* get btemp specific platform data */ |
980 | - plat_data = pdev->dev.platform_data; | |
981 | - if (!plat_data || !plat_data->btemp) { | |
985 | + di->pdata = plat_data->btemp; | |
986 | + if (!di->pdata) { | |
982 | 987 | dev_err(di->dev, "no btemp platform data supplied\n"); |
983 | 988 | ret = -EINVAL; |
984 | 989 | goto free_device_info; |
985 | 990 | } |
986 | - di->pdata = plat_data->btemp; | |
987 | 991 | |
988 | 992 | /* get battery specific platform data */ |
989 | 993 | di->bat = plat_data->battery; |
drivers/power/ab8500_charger.c
... | ... | @@ -2534,10 +2534,15 @@ |
2534 | 2534 | static int __devinit ab8500_charger_probe(struct platform_device *pdev) |
2535 | 2535 | { |
2536 | 2536 | int irq, i, charger_status, ret = 0; |
2537 | - struct abx500_bm_plat_data *plat_data; | |
2537 | + struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data; | |
2538 | + struct ab8500_charger *di; | |
2538 | 2539 | |
2539 | - struct ab8500_charger *di = | |
2540 | - kzalloc(sizeof(struct ab8500_charger), GFP_KERNEL); | |
2540 | + if (!plat_data) { | |
2541 | + dev_err(&pdev->dev, "No platform data\n"); | |
2542 | + return -EINVAL; | |
2543 | + } | |
2544 | + | |
2545 | + di = kzalloc(sizeof(*di), GFP_KERNEL); | |
2541 | 2546 | if (!di) |
2542 | 2547 | return -ENOMEM; |
2543 | 2548 | |
2544 | 2549 | |
... | ... | @@ -2550,13 +2555,12 @@ |
2550 | 2555 | spin_lock_init(&di->usb_state.usb_lock); |
2551 | 2556 | |
2552 | 2557 | /* get charger specific platform data */ |
2553 | - plat_data = pdev->dev.platform_data; | |
2554 | - if (!plat_data || !plat_data->charger) { | |
2558 | + di->pdata = plat_data->charger; | |
2559 | + if (!di->pdata) { | |
2555 | 2560 | dev_err(di->dev, "no charger platform data supplied\n"); |
2556 | 2561 | ret = -EINVAL; |
2557 | 2562 | goto free_device_info; |
2558 | 2563 | } |
2559 | - di->pdata = plat_data->charger; | |
2560 | 2564 | |
2561 | 2565 | /* get battery specific platform data */ |
2562 | 2566 | di->bat = plat_data->battery; |
drivers/power/ab8500_fg.c
... | ... | @@ -2446,10 +2446,15 @@ |
2446 | 2446 | { |
2447 | 2447 | int i, irq; |
2448 | 2448 | int ret = 0; |
2449 | - struct abx500_bm_plat_data *plat_data; | |
2449 | + struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data; | |
2450 | + struct ab8500_fg *di; | |
2450 | 2451 | |
2451 | - struct ab8500_fg *di = | |
2452 | - kzalloc(sizeof(struct ab8500_fg), GFP_KERNEL); | |
2452 | + if (!plat_data) { | |
2453 | + dev_err(&pdev->dev, "No platform data\n"); | |
2454 | + return -EINVAL; | |
2455 | + } | |
2456 | + | |
2457 | + di = kzalloc(sizeof(*di), GFP_KERNEL); | |
2453 | 2458 | if (!di) |
2454 | 2459 | return -ENOMEM; |
2455 | 2460 | |
2456 | 2461 | |
... | ... | @@ -2461,13 +2466,12 @@ |
2461 | 2466 | di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); |
2462 | 2467 | |
2463 | 2468 | /* get fg specific platform data */ |
2464 | - plat_data = pdev->dev.platform_data; | |
2465 | - if (!plat_data || !plat_data->fg) { | |
2469 | + di->pdata = plat_data->fg; | |
2470 | + if (!di->pdata) { | |
2466 | 2471 | dev_err(di->dev, "no fg platform data supplied\n"); |
2467 | 2472 | ret = -EINVAL; |
2468 | 2473 | goto free_device_info; |
2469 | 2474 | } |
2470 | - di->pdata = plat_data->fg; | |
2471 | 2475 | |
2472 | 2476 | /* get battery specific platform data */ |
2473 | 2477 | di->bat = plat_data->battery; |