Commit 306df798 authored by Yi Zhang's avatar Yi Zhang Committed by Samuel Ortiz

mfd: 88pm80x: Remove redundant devm_* calls

devm_* functions are device managed and make error handling
and code simpler; it also fix error exit paths
Signed-off-by: default avatarYi Zhang <yizhang@marvell.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent b3aac62b
...@@ -531,7 +531,7 @@ static int pm800_probe(struct i2c_client *client, ...@@ -531,7 +531,7 @@ static int pm800_probe(struct i2c_client *client,
ret = device_800_init(chip, pdata); ret = device_800_init(chip, pdata);
if (ret) { if (ret) {
dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id); dev_err(chip->dev, "%s id 0x%x failed!\n", __func__, chip->id);
goto err_800_init; goto err_subchip_alloc;
} }
ret = pm800_pages_init(chip); ret = pm800_pages_init(chip);
...@@ -546,10 +546,8 @@ static int pm800_probe(struct i2c_client *client, ...@@ -546,10 +546,8 @@ static int pm800_probe(struct i2c_client *client,
err_page_init: err_page_init:
mfd_remove_devices(chip->dev); mfd_remove_devices(chip->dev);
device_irq_exit_800(chip); device_irq_exit_800(chip);
err_800_init:
devm_kfree(&client->dev, subchip);
err_subchip_alloc: err_subchip_alloc:
pm80x_deinit(client); pm80x_deinit();
out_init: out_init:
return ret; return ret;
} }
...@@ -562,9 +560,7 @@ static int pm800_remove(struct i2c_client *client) ...@@ -562,9 +560,7 @@ static int pm800_remove(struct i2c_client *client)
device_irq_exit_800(chip); device_irq_exit_800(chip);
pm800_pages_exit(chip); pm800_pages_exit(chip);
devm_kfree(&client->dev, chip->subchip); pm80x_deinit();
pm80x_deinit(client);
return 0; return 0;
} }
......
...@@ -257,7 +257,7 @@ static int pm805_probe(struct i2c_client *client, ...@@ -257,7 +257,7 @@ static int pm805_probe(struct i2c_client *client,
pdata->plat_config(chip, pdata); pdata->plat_config(chip, pdata);
err_805_init: err_805_init:
pm80x_deinit(client); pm80x_deinit();
out_init: out_init:
return ret; return ret;
} }
...@@ -269,7 +269,7 @@ static int pm805_remove(struct i2c_client *client) ...@@ -269,7 +269,7 @@ static int pm805_remove(struct i2c_client *client)
mfd_remove_devices(chip->dev); mfd_remove_devices(chip->dev);
device_irq_exit_805(chip); device_irq_exit_805(chip);
pm80x_deinit(client); pm80x_deinit();
return 0; return 0;
} }
......
...@@ -48,14 +48,12 @@ int pm80x_init(struct i2c_client *client, ...@@ -48,14 +48,12 @@ int pm80x_init(struct i2c_client *client,
ret = PTR_ERR(map); ret = PTR_ERR(map);
dev_err(&client->dev, "Failed to allocate register map: %d\n", dev_err(&client->dev, "Failed to allocate register map: %d\n",
ret); ret);
goto err_regmap_init; return ret;
} }
chip->id = id->driver_data; chip->id = id->driver_data;
if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805) { if (chip->id < CHIP_PM800 || chip->id > CHIP_PM805)
ret = -EINVAL; return -EINVAL;
goto err_chip_id;
}
chip->client = client; chip->client = client;
chip->regmap = map; chip->regmap = map;
...@@ -82,19 +80,11 @@ int pm80x_init(struct i2c_client *client, ...@@ -82,19 +80,11 @@ int pm80x_init(struct i2c_client *client,
} }
return 0; return 0;
err_chip_id:
regmap_exit(map);
err_regmap_init:
devm_kfree(&client->dev, chip);
return ret;
} }
EXPORT_SYMBOL_GPL(pm80x_init); EXPORT_SYMBOL_GPL(pm80x_init);
int pm80x_deinit(struct i2c_client *client) int pm80x_deinit(void)
{ {
struct pm80x_chip *chip = i2c_get_clientdata(client);
/* /*
* workaround: clear the dependency between pm800 and pm805. * workaround: clear the dependency between pm800 and pm805.
* would remove it after HW chip fixes the issue. * would remove it after HW chip fixes the issue.
...@@ -103,10 +93,6 @@ int pm80x_deinit(struct i2c_client *client) ...@@ -103,10 +93,6 @@ int pm80x_deinit(struct i2c_client *client)
g_pm80x_chip->companion = NULL; g_pm80x_chip->companion = NULL;
else else
g_pm80x_chip = NULL; g_pm80x_chip = NULL;
regmap_exit(chip->regmap);
devm_kfree(&client->dev, chip);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(pm80x_deinit); EXPORT_SYMBOL_GPL(pm80x_deinit);
......
...@@ -365,5 +365,5 @@ static inline int pm80x_dev_resume(struct device *dev) ...@@ -365,5 +365,5 @@ static inline int pm80x_dev_resume(struct device *dev)
extern int pm80x_init(struct i2c_client *client, extern int pm80x_init(struct i2c_client *client,
const struct i2c_device_id *id); const struct i2c_device_id *id);
extern int pm80x_deinit(struct i2c_client *client); extern int pm80x_deinit(void);
#endif /* __LINUX_MFD_88PM80X_H */ #endif /* __LINUX_MFD_88PM80X_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment