Commit a2e904fc authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

staging: hikey9xx: hi6421-spmi-pmic: cleanup probe code

Cleanup the error handling code, making the messages more
consistent and removing an uneeded call to free_irq().

While here, also remove debug messages and make the
error messages more consistent.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/651b4053599b9f25efecac3b1d4ce6abce0bd097.1611949675.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fcd73240
...@@ -154,7 +154,7 @@ static void hi6421_spmi_pmic_irq_prc(struct hi6421_spmi_pmic *ddata) ...@@ -154,7 +154,7 @@ static void hi6421_spmi_pmic_irq_prc(struct hi6421_spmi_pmic *ddata)
} }
} }
static const struct regmap_config spmi_regmap_config = { static const struct regmap_config regmap_config = {
.reg_bits = 16, .reg_bits = 16,
.val_bits = 8, .val_bits = 8,
.max_register = 0xffff, .max_register = 0xffff,
...@@ -166,7 +166,6 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) ...@@ -166,7 +166,6 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct hi6421_spmi_pmic *ddata; struct hi6421_spmi_pmic *ddata;
struct regmap *map;
unsigned int virq; unsigned int virq;
int ret, i; int ret, i;
...@@ -174,14 +173,13 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) ...@@ -174,14 +173,13 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
if (!ddata) if (!ddata)
return -ENOMEM; return -ENOMEM;
map = devm_regmap_init_spmi_ext(pdev, &spmi_regmap_config); ddata->regmap = devm_regmap_init_spmi_ext(pdev, &regmap_config);
if (IS_ERR(map)) if (IS_ERR(ddata->regmap))
return PTR_ERR(map); return PTR_ERR(ddata->regmap);
spin_lock_init(&ddata->lock); spin_lock_init(&ddata->lock);
ddata->dev = dev; ddata->dev = dev;
ddata->regmap = map;
ddata->gpio = of_get_gpio(np, 0); ddata->gpio = of_get_gpio(np, 0);
if (ddata->gpio < 0) if (ddata->gpio < 0)
...@@ -192,7 +190,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) ...@@ -192,7 +190,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
ret = devm_gpio_request_one(dev, ddata->gpio, GPIOF_IN, "pmic"); ret = devm_gpio_request_one(dev, ddata->gpio, GPIOF_IN, "pmic");
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to request gpio%d\n", ddata->gpio); dev_err(dev, "Failed to request gpio%d\n", ddata->gpio);
return ret; return ret;
} }
...@@ -201,58 +199,42 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) ...@@ -201,58 +199,42 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev)
hi6421_spmi_pmic_irq_prc(ddata); hi6421_spmi_pmic_irq_prc(ddata);
ddata->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL); ddata->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL);
if (!ddata->irqs) { if (!ddata->irqs)
ret = -ENOMEM; return -ENOMEM;
goto irq_malloc;
}
ddata->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0, ddata->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0,
&hi6421_spmi_domain_ops, ddata); &hi6421_spmi_domain_ops, ddata);
if (!ddata->domain) { if (!ddata->domain) {
dev_err(dev, "failed irq domain add simple!\n"); dev_err(dev, "Failed to create IRQ domain\n");
ret = -ENODEV; return -ENODEV;
goto irq_malloc;
} }
for (i = 0; i < HISI_IRQ_NUM; i++) { for (i = 0; i < HISI_IRQ_NUM; i++) {
virq = irq_create_mapping(ddata->domain, i); virq = irq_create_mapping(ddata->domain, i);
if (!virq) { if (!virq) {
dev_err(dev, "Failed mapping hwirq\n"); dev_err(dev, "Failed to map H/W IRQ\n");
ret = -ENOSPC; return -ENOSPC;
goto irq_malloc;
} }
ddata->irqs[i] = virq; ddata->irqs[i] = virq;
dev_dbg(dev, "%s: ddata->irqs[%d] = %d\n",
__func__, i, ddata->irqs[i]);
} }
ret = request_threaded_irq(ddata->irq, hi6421_spmi_irq_handler, NULL, ret = request_threaded_irq(ddata->irq, hi6421_spmi_irq_handler, NULL,
IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND, IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND,
"pmic", ddata); "pmic", ddata);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "could not claim pmic IRQ: error %d\n", ret); dev_err(dev, "Failed to start IRQ handling thread: error %d\n",
goto irq_malloc; ret);
return ret;
} }
dev_set_drvdata(&pdev->dev, ddata); dev_set_drvdata(&pdev->dev, ddata);
/*
* The logic below will rely that the ddata is already stored at
* drvdata.
*/
dev_dbg(&pdev->dev, "SPMI-PMIC: adding children for %pOF\n",
pdev->dev.of_node);
ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs), hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs),
NULL, 0, NULL); NULL, 0, NULL);
if (!ret) if (ret < 0)
return 0;
dev_err(dev, "Failed to add child devices: %d\n", ret); dev_err(dev, "Failed to add child devices: %d\n", ret);
irq_malloc:
free_irq(ddata->irq, ddata);
return ret; return ret;
} }
......
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