Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
- pmic = kzalloc(sizeof(struct pm8921), GFP_KERNEL);
+ pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8921), GFP_KERNEL);
if (!pmic) {
pr_err("Cannot alloc pm8921 struct\n");
return -ENOMEM;
if (!pmic) {
pr_err("Cannot alloc pm8921 struct\n");
return -ENOMEM;
rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val));
if (rc) {
pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc);
rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val));
if (rc) {
pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc);
}
pr_info("PMIC revision 1: %02X\n", val);
rev = val;
}
pr_info("PMIC revision 1: %02X\n", val);
rev = val;
if (rc) {
pr_err("Failed to read hw rev 2 reg %d:rc=%d\n",
REG_HWREV_2, rc);
if (rc) {
pr_err("Failed to read hw rev 2 reg %d:rc=%d\n",
REG_HWREV_2, rc);
}
pr_info("PMIC revision 2: %02X\n", val);
rev |= val << BITS_PER_BYTE;
}
pr_info("PMIC revision 2: %02X\n", val);
rev |= val << BITS_PER_BYTE;
err:
mfd_remove_devices(pmic->dev);
err:
mfd_remove_devices(pmic->dev);
-err_read_rev:
- kfree(pmic);
pm8xxx_irq_exit(pmic->irq_chip);
pmic->irq_chip = NULL;
}
pm8xxx_irq_exit(pmic->irq_chip);
pmic->irq_chip = NULL;
}