FreeBSD Bugzilla – Attachment 111513 Details for
Bug 152792
[acpica] [patch] move temperature conversion macros to a common header
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.10 KB, created by
Mark Johnston
on 2010-12-02 21:10:09 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Mark Johnston
Created:
2010-12-02 21:10:09 UTC
Size:
3.10 KB
patch
obsolete
>diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c >index ec4178e..f3a283c 100644 >--- a/sys/dev/acpica/acpi_thermal.c >+++ b/sys/dev/acpica/acpi_thermal.c >@@ -54,9 +54,6 @@ __FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_thermal.c,v 1.74 2010/06/11 19:27:21 > #define _COMPONENT ACPI_THERMAL > ACPI_MODULE_NAME("THERMAL") > >-#define TZ_ZEROC 2732 >-#define TZ_KELVTOC(x) (((x) - TZ_ZEROC) / 10), abs(((x) - TZ_ZEROC) % 10) >- > #define TZ_NOTIFY_TEMPERATURE 0x80 /* Temperature changed. */ > #define TZ_NOTIFY_LEVELS 0x81 /* Cooling levels changed. */ > #define TZ_NOTIFY_DEVICES 0x82 /* Device lists changed. */ >diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c >index 8ba46c7..0220b54 100644 >--- a/sys/dev/amdtemp/amdtemp.c >+++ b/sys/dev/amdtemp/amdtemp.c >@@ -433,8 +433,6 @@ amdtemp_sysctl(SYSCTL_HANDLER_ARGS) > return (error); > } > >-#define AMDTEMP_ZERO_C_TO_K 2732 >- > static int32_t > amdtemp_gettemp0f(device_t dev, amdsensor_t sensor) > { >@@ -468,7 +466,7 @@ amdtemp_gettemp0f(device_t dev, amdsensor_t sensor) > pci_write_config(dev, AMDTEMP_THERMTP_STAT, cfg | sel, 1); > > /* CurTmp starts from -49C. */ >- offset = AMDTEMP_ZERO_C_TO_K - 490; >+ offset = TZ_ZEROC - 490; > > /* Adjust offset if DiodeOffset is set and valid. */ > temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4); >@@ -497,7 +495,7 @@ amdtemp_gettemp(device_t dev, amdsensor_t sensor) > int32_t diode_offset, offset; > > /* CurTmp starts from 0C. */ >- offset = AMDTEMP_ZERO_C_TO_K; >+ offset = TZ_ZEROC; > > /* Adjust offset if DiodeOffset is set and valid. */ > temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4); >diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c >index 7cfc9c6..cb26b1b 100644 >--- a/sys/dev/coretemp/coretemp.c >+++ b/sys/dev/coretemp/coretemp.c >@@ -48,8 +48,6 @@ __FBSDID("$FreeBSD: src/sys/dev/coretemp/coretemp.c,v 1.12 2010/08/04 00:25:13 d > #include <machine/cputypes.h> > #include <machine/md_var.h> > >-#define TZ_ZEROC 2732 >- > struct coretemp_softc { > device_t sc_dev; > int sc_tjmax; >@@ -331,7 +329,7 @@ coretemp_get_temp_sysctl(SYSCTL_HANDLER_ARGS) > device_t dev = (device_t) arg1; > int temp; > >- temp = coretemp_get_temp(dev) * 10 + TZ_ZEROC; >+ temp = TZ_CEL_TO_KEL(coretemp_get_temp(dev)); > > return (sysctl_handle_int(oidp, &temp, 0, req)); > } >diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h >index eae9c10..3ffccf9 100644 >--- a/sys/sys/sysctl.h >+++ b/sys/sys/sysctl.h >@@ -114,6 +114,19 @@ struct ctlname { > */ > #define CTL_AUTO_START 0x100 > >+/* >+ * Conversion between Celsius and Kelvin, for drivers that want to >+ * display a temperature reading through a sysctl. The IK sysctl format >+ * expects a value that's converted into multiples of 0.1 degrees Kelvin, >+ * so one multiplies a celsius reading by 10 and adds TZ_ZEROC to get the >+ * correct value. >+ */ >+#define TZ_ZEROC 2732 >+#define TZ_CTOKELV(x) ((x) * 10 + TZ_ZEROC) >+#define TZ_KELVTOC_INT(x) (((x) - TZ_ZEROC) / 10) >+#define TZ_KELVTOC_FRAC(x) abs(((x) - TZ_ZEROC) % 10) >+#define TZ_KELVTOC(x) TZ_KELVTOC_INT(x), TZ_KELVTOC_FRAC(x) >+ > #ifdef _KERNEL > #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \ > struct sysctl_req *req
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 152792
: 111513