Re: [PATCH 1/3] drivers: thermal: tsens: Add critical interrupt support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Amit Kucheria (2019-11-11 11:21:27)
> diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
> index 4359a4247ac3..2989cb952cdb 100644
> --- a/drivers/thermal/qcom/tsens-common.c
> +++ b/drivers/thermal/qcom/tsens-common.c
> @@ -321,6 +357,65 @@ static inline u32 masked_irq(u32 hw_id, u32 mask, enum tsens_ver ver)
>         return 0;
>  }
>  
> +/**
> + * tsens_critical_irq_thread - Threaded interrupt handler for critical interrupts
> + * @irq: irq number
> + * @data: tsens controller private data
> + *
> + * Check all sensors to find ones that violated their critical threshold limits.
> + * Clear and then re-enable the interrupt.
> + *
> + * The level-triggered interrupt might deassert if the temperature returned to
> + * within the threshold limits by the time the handler got scheduled. We
> + * consider the irq to have been handled in that case.
> + *
> + * Return: IRQ_HANDLED
> + */
> +irqreturn_t tsens_critical_irq_thread(int irq, void *data)
> +{
> +       struct tsens_priv *priv = data;
> +       struct tsens_irq_data d;
> +       bool enable = true, disable = false;

Why not just use true and false in the one place these variables are
used?

> +       unsigned long flags;
> +       int temp, ret, i;
> +
> +       for (i = 0; i < priv->num_sensors; i++) {
> +               struct tsens_sensor *s = &priv->sensor[i];

Maybe make this const?

> +               u32 hw_id = s->hw_id;
> +
> +               if (IS_ERR(priv->sensor[i].tzd))

IS_ERR(s->tzd)?

> +                       continue;
> +               if (!tsens_threshold_violated(priv, hw_id, &d))
> +                       continue;
> +               ret = get_temp_tsens_valid(s, &temp);

Can this accept a const 's'?

> +               if (ret) {
> +                       dev_err(priv->dev, "[%u] %s: error reading sensor\n", hw_id, __func__);
> +                       continue;
> +               }
> +
> +               spin_lock_irqsave(&priv->ul_lock, flags);
> +
> +               tsens_read_irq_state(priv, hw_id, s, &d);
> +
> +               if (d.crit_viol &&
> +                   !masked_irq(hw_id, d.crit_irq_mask, tsens_version(priv))) {
> +                       tsens_set_interrupt(priv, hw_id, CRITICAL, disable);
> +                       if (d.crit_thresh > temp) {
> +                               dev_dbg(priv->dev, "[%u] %s: re-arm upper\n",
> +                                       priv->sensor[i].hw_id, __func__);

hw_id instead of priv->sensor...?

> +                       } else {
> +                               dev_dbg(priv->dev, "[%u] %s: TZ update trigger (%d mC)\n",
> +                                       hw_id, __func__, temp);
> +                       }
> +                       tsens_set_interrupt(priv, hw_id, CRITICAL, enable);
> +               }
> +
> +               spin_unlock_irqrestore(&priv->crit_lock, flags);
> +       }
> +
> +       return IRQ_HANDLED;
> +}
> +
>  /**
>   * tsens_irq_thread - Threaded interrupt handler for uplow interrupts
>   * @irq: irq number
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 7d317660211e..784c4976c4f9 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -121,6 +121,27 @@ static int tsens_register(struct tsens_priv *priv)
>  
>         enable_irq_wake(irq);
>  
> +       if (tsens_version(priv) > VER_1_X) {
> +               irq = platform_get_irq_byname(pdev, "critical");
> +               if (irq < 0) {
> +                       ret = irq;
> +                       goto err_put_device;
> +               }
> +
> +               ret = devm_request_threaded_irq(&pdev->dev, irq,
> +                                               NULL, tsens_critical_irq_thread,
> +                                               IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
> +                                               dev_name(&pdev->dev), priv);
> +               if (ret) {
> +                       dev_err(&pdev->dev, "%s: failed to get critical irq\n", __func__);
> +                       goto err_put_device;

Do we need to disable_irq_wake() for the previous irq here?

> +               }
> +
> +               enable_irq_wake(irq);
> +       }
> +
> +       return 0;
> +
>  err_put_device:
>         put_device(&pdev->dev);
>         return ret;




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux