thermal/drivers/qcom-spmi: Use devm_iio_channel_get

The iio_channel_get() function has now its devm_ version.

Use it and remove all the rollback code for iio_channel_release() as well
as the .remove ops.

[Compiled tested only]

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
This commit is contained in:
Daniel Lezcano 2017-10-19 19:06:00 +02:00 committed by Eduardo Valentin
parent d377aba193
commit 7a4ca51b70

View File

@ -125,7 +125,7 @@ static int qpnp_tm_get_temp(void *data, int *temp)
if (!temp) if (!temp)
return -EINVAL; return -EINVAL;
if (IS_ERR(chip->adc)) { if (!chip->adc) {
ret = qpnp_tm_update_temp_no_adc(chip); ret = qpnp_tm_update_temp_no_adc(chip);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -224,67 +224,53 @@ static int qpnp_tm_probe(struct platform_device *pdev)
return irq; return irq;
/* ADC based measurements are optional */ /* ADC based measurements are optional */
chip->adc = iio_channel_get(&pdev->dev, "thermal"); chip->adc = devm_iio_channel_get(&pdev->dev, "thermal");
if (PTR_ERR(chip->adc) == -EPROBE_DEFER) if (IS_ERR(chip->adc)) {
return PTR_ERR(chip->adc); ret = PTR_ERR(chip->adc);
chip->adc = NULL;
if (ret == -EPROBE_DEFER)
return ret;
}
chip->base = res; chip->base = res;
ret = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, &type); ret = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, &type);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "could not read type\n"); dev_err(&pdev->dev, "could not read type\n");
goto fail; return ret;
} }
ret = qpnp_tm_read(chip, QPNP_TM_REG_SUBTYPE, &subtype); ret = qpnp_tm_read(chip, QPNP_TM_REG_SUBTYPE, &subtype);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "could not read subtype\n"); dev_err(&pdev->dev, "could not read subtype\n");
goto fail; return ret;
} }
if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) { if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) {
dev_err(&pdev->dev, "invalid type 0x%02x or subtype 0x%02x\n", dev_err(&pdev->dev, "invalid type 0x%02x or subtype 0x%02x\n",
type, subtype); type, subtype);
ret = -ENODEV; return -ENODEV;
goto fail;
} }
ret = qpnp_tm_init(chip); ret = qpnp_tm_init(chip);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "init failed\n"); dev_err(&pdev->dev, "init failed\n");
goto fail; return ret;
} }
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr, ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr,
IRQF_ONESHOT, node->name, chip); IRQF_ONESHOT, node->name, chip);
if (ret < 0) if (ret < 0)
goto fail; return ret;
chip->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, chip, chip->tz_dev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, chip,
&qpnp_tm_sensor_ops); &qpnp_tm_sensor_ops);
if (IS_ERR(chip->tz_dev)) { if (IS_ERR(chip->tz_dev)) {
dev_err(&pdev->dev, "failed to register sensor\n"); dev_err(&pdev->dev, "failed to register sensor\n");
ret = PTR_ERR(chip->tz_dev); return PTR_ERR(chip->tz_dev);
goto fail;
} }
return 0; return 0;
fail:
if (!IS_ERR(chip->adc))
iio_channel_release(chip->adc);
return ret;
}
static int qpnp_tm_remove(struct platform_device *pdev)
{
struct qpnp_tm_chip *chip = dev_get_drvdata(&pdev->dev);
if (!IS_ERR(chip->adc))
iio_channel_release(chip->adc);
return 0;
} }
static const struct of_device_id qpnp_tm_match_table[] = { static const struct of_device_id qpnp_tm_match_table[] = {
@ -299,7 +285,6 @@ static struct platform_driver qpnp_tm_driver = {
.of_match_table = qpnp_tm_match_table, .of_match_table = qpnp_tm_match_table,
}, },
.probe = qpnp_tm_probe, .probe = qpnp_tm_probe,
.remove = qpnp_tm_remove,
}; };
module_platform_driver(qpnp_tm_driver); module_platform_driver(qpnp_tm_driver);