mfd: 88pm800: Enhance error handling for sub pages probe/remove
pm800_pages_init and pm800_pages_exit are called by pm800_probe. Change the code to enhance error handling and remove unused code at pm800_pages_init/exit and pm800_probe. Signed-off-by: Yi Zhang <yizhang@marvell.com> Signed-off-by: Chao Xie <chao.xie@marvell.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Родитель
c750d8e053
Коммит
52705344d0
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/mfd/88pm80x.h>
|
||||
|
@ -370,50 +371,64 @@ static int pm800_pages_init(struct pm80x_chip *chip)
|
|||
struct pm80x_subchip *subchip;
|
||||
struct i2c_client *client = chip->client;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
subchip = chip->subchip;
|
||||
/* PM800 block power: i2c addr 0x31 */
|
||||
if (subchip->power_page_addr) {
|
||||
subchip->power_page =
|
||||
i2c_new_dummy(client->adapter, subchip->power_page_addr);
|
||||
subchip->regmap_power =
|
||||
devm_regmap_init_i2c(subchip->power_page,
|
||||
&pm80x_regmap_config);
|
||||
i2c_set_clientdata(subchip->power_page, chip);
|
||||
} else
|
||||
dev_info(chip->dev,
|
||||
"PM800 block power 0x31: No power_page_addr\n");
|
||||
if (!subchip || !subchip->power_page_addr || !subchip->gpadc_page_addr)
|
||||
return -ENODEV;
|
||||
|
||||
/* PM800 block GPADC: i2c addr 0x32 */
|
||||
if (subchip->gpadc_page_addr) {
|
||||
subchip->gpadc_page = i2c_new_dummy(client->adapter,
|
||||
subchip->gpadc_page_addr);
|
||||
subchip->regmap_gpadc =
|
||||
devm_regmap_init_i2c(subchip->gpadc_page,
|
||||
&pm80x_regmap_config);
|
||||
i2c_set_clientdata(subchip->gpadc_page, chip);
|
||||
} else
|
||||
dev_info(chip->dev,
|
||||
"PM800 block GPADC 0x32: No gpadc_page_addr\n");
|
||||
/* PM800 block power page */
|
||||
subchip->power_page = i2c_new_dummy(client->adapter,
|
||||
subchip->power_page_addr);
|
||||
if (subchip->power_page == NULL) {
|
||||
ret = -ENODEV;
|
||||
goto out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
subchip->regmap_power = devm_regmap_init_i2c(subchip->power_page,
|
||||
&pm80x_regmap_config);
|
||||
if (IS_ERR(subchip->regmap_power)) {
|
||||
ret = PTR_ERR(subchip->regmap_power);
|
||||
dev_err(chip->dev,
|
||||
"Failed to allocate regmap_power: %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(subchip->power_page, chip);
|
||||
|
||||
/* PM800 block GPADC */
|
||||
subchip->gpadc_page = i2c_new_dummy(client->adapter,
|
||||
subchip->gpadc_page_addr);
|
||||
if (subchip->gpadc_page == NULL) {
|
||||
ret = -ENODEV;
|
||||
goto out;
|
||||
}
|
||||
|
||||
subchip->regmap_gpadc = devm_regmap_init_i2c(subchip->gpadc_page,
|
||||
&pm80x_regmap_config);
|
||||
if (IS_ERR(subchip->regmap_gpadc)) {
|
||||
ret = PTR_ERR(subchip->regmap_gpadc);
|
||||
dev_err(chip->dev,
|
||||
"Failed to allocate regmap_gpadc: %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
i2c_set_clientdata(subchip->gpadc_page, chip);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void pm800_pages_exit(struct pm80x_chip *chip)
|
||||
{
|
||||
struct pm80x_subchip *subchip;
|
||||
|
||||
regmap_exit(chip->regmap);
|
||||
i2c_unregister_device(chip->client);
|
||||
|
||||
subchip = chip->subchip;
|
||||
if (subchip->power_page) {
|
||||
regmap_exit(subchip->regmap_power);
|
||||
|
||||
if (subchip && subchip->power_page)
|
||||
i2c_unregister_device(subchip->power_page);
|
||||
}
|
||||
if (subchip->gpadc_page) {
|
||||
regmap_exit(subchip->regmap_gpadc);
|
||||
|
||||
if (subchip && subchip->gpadc_page)
|
||||
i2c_unregister_device(subchip->gpadc_page);
|
||||
}
|
||||
}
|
||||
|
||||
static int device_800_init(struct pm80x_chip *chip,
|
||||
|
|
Загрузка…
Ссылка в новой задаче