Skip to content

Commit 2937f5d

Browse files
Charles Hansre
authored andcommitted
power: supply: max14577: Handle NULL pdata when CONFIG_OF is not set
When the kernel is not configured CONFIG_OF, the max14577_charger_dt_init function returns NULL. Fix the max14577_charger_probe functionby returning -ENODATA instead of potentially passing a NULL pointer to PTR_ERR. This fixes the below smatch warning: max14577_charger_probe() warn: passing zero to 'PTR_ERR' Fixes: e30110e ("charger: max14577: Configure battery-dependent settings from DTS and sysfs") Signed-off-by: Charles Han <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent a9aece5 commit 2937f5d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/power/supply/max14577_charger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static struct max14577_charger_platform_data *max14577_charger_dt_init(
501501
static struct max14577_charger_platform_data *max14577_charger_dt_init(
502502
struct platform_device *pdev)
503503
{
504-
return NULL;
504+
return ERR_PTR(-ENODATA);
505505
}
506506
#endif /* CONFIG_OF */
507507

@@ -572,7 +572,7 @@ static int max14577_charger_probe(struct platform_device *pdev)
572572
chg->max14577 = max14577;
573573

574574
chg->pdata = max14577_charger_dt_init(pdev);
575-
if (IS_ERR_OR_NULL(chg->pdata))
575+
if (IS_ERR(chg->pdata))
576576
return PTR_ERR(chg->pdata);
577577

578578
ret = max14577_charger_reg_init(chg);

0 commit comments

Comments
 (0)