Re: [PATCH] thermal: int340x: check for sensor when PTYP is missing

From: Srinivas Pandruvada
Date: Fri Jun 09 2017 - 18:23:25 EST


On Wed, 2017-06-07 at 13:55 +0300, Andy Shevchenko wrote:
> On Wed, Jun 7, 2017 at 2:00 AM, Srinivas Pandruvada
> <srinivas.pandruvada@xxxxxxxxxxxxxxx> wrote:
> >
> > For INT3403 sensor PTYP field is mandatory. But some platforms
> > didn't
> > have this field for sensors. This cause load failure for int3403
> > driver.
> >
> > This change checks for the presence of _TMP method and if present,
> > then
> > treats this device as a sensor.
> >
> > ÂÂÂÂÂÂÂÂstatus = acpi_evaluate_integer(priv->adev->handle, "PTYP",
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂNULL, &priv->type);
> > ÂÂÂÂÂÂÂÂif (ACPI_FAILURE(status)) {
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂresult = -EINVAL;
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂgoto err;
> >
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned long long tmp;
> You may use &priv->type as temporary variable, though I would go
> other
> way around:
> declare tmp for function, then
>
> ÂÂÂÂunsigned long long tmp;
> ...
> ÂÂÂÂstatus = acpi_evaluate_integer(priv->adev->handle, "PTYP",ÂÂNULL,
> &tmp);
> ÂÂÂÂif (ACPI_FAILURE(status)) {
> ÂÂÂÂÂÂÂÂstatus = acpi_evaluate_integer(priv->adev->handle, "_TMP",
> NULL, &tmp);
> ÂÂÂÂÂÂÂÂif (ACPI_FAILURE(status)) {
> ÂÂÂÂÂÂÂÂÂÂÂÂresult = -EINVAL;
> ÂÂÂÂÂÂÂÂÂÂÂÂgoto err;
> ÂÂÂÂÂÂÂÂ}
> ÂÂÂÂÂÂÂÂtmp = INT3403_TYPE_SENSOR;
> ÂÂÂÂ}
> ÂÂÂÂpriv->type = tmp;
>
So what are we saving by doing this way?

Thanks,
Srinivas

> >
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ} else {
> This is redundant.
>
> >
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpriv->type = INT3403_TYPE_SENSOR;
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
> > ÂÂÂÂÂÂÂÂ}