linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: int340x: check for sensor when PTYP is missing
@ 2017-06-06 23:00 Srinivas Pandruvada
  2017-06-07 10:55 ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2017-06-06 23:00 UTC (permalink / raw)
  To: rui.zhang, edubezval; +Cc: linux-pm, linux-kernel, Srinivas Pandruvada

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.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/thermal/int340x_thermal/int3403_thermal.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/int340x_thermal/int3403_thermal.c b/drivers/thermal/int340x_thermal/int3403_thermal.c
index c4890c9..8a7f24d 100644
--- a/drivers/thermal/int340x_thermal/int3403_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3403_thermal.c
@@ -238,8 +238,16 @@ static int int3403_add(struct platform_device *pdev)
 	status = acpi_evaluate_integer(priv->adev->handle, "PTYP",
 				       NULL, &priv->type);
 	if (ACPI_FAILURE(status)) {
-		result = -EINVAL;
-		goto err;
+		unsigned long long tmp;
+
+		status = acpi_evaluate_integer(priv->adev->handle, "_TMP",
+					       NULL, &tmp);
+		if (ACPI_FAILURE(status)) {
+			result = -EINVAL;
+			goto err;
+		} else {
+			priv->type = INT3403_TYPE_SENSOR;
+		}
 	}
 
 	platform_set_drvdata(pdev, priv);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal: int340x: check for sensor when PTYP is missing
  2017-06-06 23:00 [PATCH] thermal: int340x: check for sensor when PTYP is missing Srinivas Pandruvada
@ 2017-06-07 10:55 ` Andy Shevchenko
  2017-06-09 22:23   ` Srinivas Pandruvada
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2017-06-07 10:55 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Zhang, Rui, edubezval@gmail.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Jun 7, 2017 at 2:00 AM, Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> 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;

> +               } else {

This is redundant.

> +                       priv->type = INT3403_TYPE_SENSOR;
> +               }
>         }

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal: int340x: check for sensor when PTYP is missing
  2017-06-07 10:55 ` Andy Shevchenko
@ 2017-06-09 22:23   ` Srinivas Pandruvada
  2017-06-09 22:36     ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2017-06-09 22:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Zhang, Rui, edubezval@gmail.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org

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@linux.intel.com> 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;
> > +               }
> >         }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal: int340x: check for sensor when PTYP is missing
  2017-06-09 22:23   ` Srinivas Pandruvada
@ 2017-06-09 22:36     ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-06-09 22:36 UTC (permalink / raw)
  To: Srinivas Pandruvada
  Cc: Zhang, Rui, edubezval@gmail.com, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Sat, Jun 10, 2017 at 1:23 AM, Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
> 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@linux.intel.com> wrote:

>> > 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?

We make priv->type assignment in one place.

That's the difference.

So, you may choose your way of course. It's not a big deal.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-09 22:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-06 23:00 [PATCH] thermal: int340x: check for sensor when PTYP is missing Srinivas Pandruvada
2017-06-07 10:55 ` Andy Shevchenko
2017-06-09 22:23   ` Srinivas Pandruvada
2017-06-09 22:36     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).