Code/ibm acpi-extra-thermal.patch

From ThinkWiki
Revision as of 00:50, 27 July 2006 by Thinker (Talk | contribs) (copies from http://pastebin.ca/91872)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--- a/drivers/acpi/ibm_acpi.c 2006-03-20 06:53:29.000000000 +0100 +++ b/drivers/acpi/ibm_acpi.c 2006-07-19 01:55:52.000000000 +0200 @@ -1229,28 +1229,46 @@ static int thermal_read(char *p)

	if (!thermal_tmp_supported)
		len += sprintf(p + len, "temperatures:\tnot supported\n");
	else {

- int i, t; + int i;

		char tmpi[] = "TMPi";

- s8 tmp[8]; + /* + * A few ThinkPads (e.g. R52, T43) have 3 unnamed sensors. We + * want their values as well. + */ + static const size_t named_count = 8; + static const size_t unnamed_count = 3; + static const size_t unnamed_addresses[] = { 0xC0, 0xC1, 0xC2 }; + static const size_t total_count = named_count + unnamed_count; + s8 tmp[total_count];

		if (thermal_updt_supported)
			if (!acpi_evalf(ec_handle, NULL, "UPDT", "v"))
				return -EIO;

- for (i = 0; i < 8; i++) { + for (i = 0; i < named_count; i++) { + int t;

			tmpi[3] = '0' + i;
			if (!acpi_evalf(ec_handle, &t, tmpi, "d"))
				return -EIO;

- if (thermal_updt_supported) - tmp[i] = (t - 2732 + 5) / 10; - else - tmp[i] = t; + tmp[i] = (s8)t;

		}

- len += sprintf(p + len, - "temperatures:\t%d %d %d %d %d %d %d %d\n", - tmp[0], tmp[1], tmp[2], tmp[3], - tmp[4], tmp[5], tmp[6], tmp[7]); + for (i = 0; i < unnamed_count; ++i) { + size_t address = unnamed_addresses[i]; + u8 t; + if (!acpi_ec_read(address, &t)) + return -EIO; + tmp[i+named_count] = (s8)t; + } + + len += sprintf(p + len, "temperatures:\t" ); + for (i = 0; i < total_count; ++i) { + int value = thermal_updt_supported +  ? (tmp[i] - 2732 + 5) / 10 +  : tmp[i]; + len += sprintf(p + len, "%d%c", value, + i == total_count - 1 ? '\n' : ' '); + }

	}

	return len;