Skip to contentSkip to conversation

ACPI/Thermal: Add check of "_TZD" availability and evaluating result

PATCH Superseded [email protected] 3 participants 4 messages Aug 24, 2013 – Aug 25, 2013

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI/Thermal: Add check of "_TZD" availability and evaluating result

From: Lan Tianyu <[email protected]>

Some machines don't provide _TZD. So add check of "_TZD" availability before doing futher operations. This patch also adds the check of evaluating result.

---
 drivers/acpi/thermal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/thermal.c +3 -2
index 09f9340..6809fbd 100644
@@ -492,11 +492,12 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
 			break;
 	}
 
-	if (flag & ACPI_TRIPS_DEVICES) {
+	if ((flag & ACPI_TRIPS_DEVICES)
+			&& acpi_has_method(tz->device->handle, "_TZD")) {
 		memset(&devices, 0, sizeof(struct acpi_handle_list));
 		status = acpi_evaluate_reference(tz->device->handle, "_TZD",
 						NULL, &devices);
-		if (memcmp(&tz->devices, &devices,
+		if (ACPI_SUCCESS(status) && memcmp(&tz->devices, &devices,
 				sizeof(struct acpi_handle_list))) {
 			memcpy(&tz->devices, &devices,
 				sizeof(struct acpi_handle_list));
Signature · 1 line
1.8.4.rc0.1.g8f6a3e5.dirty
#1 lore raw
Quoted 16 lines · On Saturday, August 24, 2013 05:01:28 PM [email protected] wrote:

From: Lan Tianyu <[email protected]>

Some machines don't provide _TZD. So add check of "_TZD" availability before doing futher operations. This patch also adds the check of evaluating result.

---
 drivers/acpi/thermal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/thermal.c +0 -0
index 09f9340..6809fbd 100644

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 496

Quoted 6 lines
drivers/acpi/thermal.c +2 -1
@@ -492,11 +492,12 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
 			break;
 	}
 
-	if (flag & ACPI_TRIPS_DEVICES) {
+	if ((flag & ACPI_TRIPS_DEVICES)
+			&& acpi_has_method(tz->device->handle, "_TZD")) {

Please arrange the whitespace here like this:

	if ((flag & ACPI_TRIPS_DEVICES)
	    && acpi_has_method(tz->device->handle, "_TZD")) {

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 501

Quoted 6 lines
drivers/acpi/thermal.c +1 -1
 		memset(&devices, 0, sizeof(struct acpi_handle_list));
 		status = acpi_evaluate_reference(tz->device->handle, "_TZD",
 						NULL, &devices);
-		if (memcmp(&tz->devices, &devices,
+		if (ACPI_SUCCESS(status) && memcmp(&tz->devices, &devices,
 				sizeof(struct acpi_handle_list))) {

I wonder why you can't use "tz->device == devices" here instead of the memcmp?

And also "tz->devices = devices" below for that matter.

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 503

Quoted 2 lines
drivers/acpi/thermal.c +0 -0
 			memcpy(&tz->devices, &devices,
 				sizeof(struct acpi_handle_list));

Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#2 lore raw

Hi Rafael:
Thanks for review.

2013/8/24 Rafael J. Wysocki <[email protected]>:

Quoted 20 lines · On Saturday, August 24, 2013 05:01:28 PM [email protected] wrote:
Quoted 19 lines

From: Lan Tianyu <[email protected]>

Some machines don't provide _TZD. So add check of "_TZD" availability before doing futher operations. This patch also adds the check of evaluating result.

---
 drivers/acpi/thermal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/thermal.c +0 -0
index 09f9340..6809fbd 100644
@@ -492,11 +492,12 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
                      break;
      }
 
Quoted 9 lines

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 496

Quoted 3 lines
drivers/acpi/thermal.c +2 -1
-     if (flag & ACPI_TRIPS_DEVICES) {
+     if ((flag & ACPI_TRIPS_DEVICES)
+                     && acpi_has_method(tz->device->handle, "_TZD")) {

Please arrange the whitespace here like this:

if ((flag & ACPI_TRIPS_DEVICES)
&& acpi_has_method(tz->device->handle, "_TZD")) {

Ok. I will update.

Quoted 9 lines

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 501

Quoted 7 lines
drivers/acpi/thermal.c +1 -1
              memset(&devices, 0, sizeof(struct acpi_handle_list));
              status = acpi_evaluate_reference(tz->device->handle, "_TZD",
                                              NULL, &devices);
-             if (memcmp(&tz->devices, &devices,
+             if (ACPI_SUCCESS(status) && memcmp(&tz->devices, &devices,
                              sizeof(struct acpi_handle_list))) {

I wonder why you can't use "tz->device == devices" here instead of the memcmp?

After changing like this, compiling failed with the following warning.

drivers/acpi/thermal.c: In function 'acpi_thermal_trips_update':
drivers/acpi/thermal.c:500:43: error: invalid operands to binary == (have 'struct acpi_handle_list' and 'struct acpi_handle_list')

   if (ACPI_SUCCESS(status) && tz->devices == devices) {
                                                                    ^
Quoted 3 lines

And also "tz->devices = devices" below for that matter.

This change is ok.

Quoted 13 lines

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 503

Quoted 2 lines
drivers/acpi/thermal.c +0 -0
                      memcpy(&tz->devices, &devices,
                              sizeof(struct acpi_handle_list));

Rafael

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards
Tianyu Lan
#3 lore raw
Quoted 46 lines · Lan Tianyu

Hi Rafael:
Thanks for review.

2013/8/24 Rafael J. Wysocki <[email protected]>:

Quoted 20 lines · On Saturday, August 24, 2013 05:01:28 PM [email protected] wrote:
Quoted 19 lines

From: Lan Tianyu <[email protected]>

Some machines don't provide _TZD. So add check of "_TZD" availability before doing futher operations. This patch also adds the check of evaluating result.

---
 drivers/acpi/thermal.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/acpi/thermal.c +0 -0
index 09f9340..6809fbd 100644
@@ -492,11 +492,12 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
                      break;
      }
 
Quoted 9 lines

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 496

Quoted 3 lines
drivers/acpi/thermal.c +2 -1
-     if (flag & ACPI_TRIPS_DEVICES) {
+     if ((flag & ACPI_TRIPS_DEVICES)
+                     && acpi_has_method(tz->device->handle, "_TZD")) {

Please arrange the whitespace here like this:

if ((flag & ACPI_TRIPS_DEVICES)
&& acpi_has_method(tz->device->handle, "_TZD")) {

Ok. I will update.

Quoted 9 lines

drivers/acpi/thermal.c static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) · line 501

Quoted 7 lines
drivers/acpi/thermal.c +1 -1
              memset(&devices, 0, sizeof(struct acpi_handle_list));
              status = acpi_evaluate_reference(tz->device->handle, "_TZD",
                                              NULL, &devices);
-             if (memcmp(&tz->devices, &devices,
+             if (ACPI_SUCCESS(status) && memcmp(&tz->devices, &devices,
                              sizeof(struct acpi_handle_list))) {

I wonder why you can't use "tz->device == devices" here instead of the memcmp?

Quoted 7 lines

After changing like this, compiling failed with the following warning.

drivers/acpi/thermal.c: In function 'acpi_thermal_trips_update':
drivers/acpi/thermal.c:500:43: error: invalid operands to binary == (have 'struct acpi_handle_list' and 'struct acpi_handle_list')

   if (ACPI_SUCCESS(status) && tz->devices == devices) {
                                                                    ^

OK, so please use memcmp(&tz->devices, &devices, sizeof(devices)).

Quoted 6 lines
Quoted 4 lines

And also "tz->devices = devices" below for that matter.

This change is ok.

Thanks,
Rafael