Re: [PATCH v5 5/8] drivers: thermal: tsens: Add critical interrupt support

From: Stephen Boyd
Date: Wed Feb 19 2020 - 19:05:42 EST


Quoting Amit Kucheria (2020-02-18 10:12:09)
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 0e7cf5236932..5b003d598234 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -125,6 +125,28 @@ static int tsens_register(struct tsens_priv *priv)
> goto err_put_device;
> }
>
> + if (priv->feat->crit_int) {
> + irq_crit = platform_get_irq_byname(pdev, "critical");
> + if (irq_crit < 0) {
> + ret = irq_crit;
> + /* For old DTs with no IRQ defined */
> + if (irq_crit == -ENXIO)
> + ret = 0;
> + goto err_crit_int;
> + }
> + ret = devm_request_threaded_irq(&pdev->dev, irq_crit,
> + NULL, tsens_critical_irq_thread,
> + IRQF_ONESHOT,
> + dev_name(&pdev->dev), priv);
> + if (ret) {
> + dev_err(&pdev->dev, "%s: failed to get critical irq\n", __func__);
> + goto err_crit_int;
> + }
> +
> + enable_irq_wake(irq_crit);
> + }
> +
> +err_crit_int:

Why use a goto? Can't this be done with if-else statements?

if (priv->feat->crit_int) {
irq_crit = platform_get_irq_byname(pdev, "critical");
if (irq_crit < 0) {
...
} else {
ret = devm_request_threaded_irq(&pdev->dev, irq_crit,
NULL, tsens_critical_irq_thread,
IRQF_ONESHOT,
dev_name(&pdev->dev), priv);
if (ret)
dev_err(&pdev->dev, "%s: failed to get critical irq\n", __func__);
else
enable_irq_wake(irq_crit);
}
}

Or if the nesting is so deep that we need goto labels then perhaps it
needs to be another function.

> enable_irq_wake(irq);
>
> err_put_device: