Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=24d560d7b9cf90451c6ef6248c09fb4cee1c76e6
Commit:     24d560d7b9cf90451c6ef6248c09fb4cee1c76e6
Parent:     91a69c9646a5b709381d99a171890e77377b1b9c
Author:     Christian Krafft <[EMAIL PROTECTED]>
AuthorDate: Mon Apr 23 21:35:40 2007 +0200
Committer:  Arnd Bergmann <[EMAIL PROTECTED]>
CommitDate: Mon Apr 23 21:44:39 2007 +0200

    [POWERPC] cbe_thermal: clean up computation of temperature
    
    This patch introduces a little function for transforming
    register values into temperature.
    
    Signed-off-by: Christian Krafft <[EMAIL PROTECTED]>
    Signed-off-by: Arnd Bergmann <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/cell/cbe_thermal.c |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c 
b/arch/powerpc/platforms/cell/cbe_thermal.c
index e8bcd2a..0d486fd 100644
--- a/arch/powerpc/platforms/cell/cbe_thermal.c
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -31,6 +31,11 @@
 #include "cbe_regs.h"
 #include "spu_priv1_mmio.h"
 
+static inline u8 reg_to_temp(u8 reg_value)
+{
+       return ((reg_value & 0x3f) << 1) + 65;
+}
+
 static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev)
 {
        struct spu *spu;
@@ -58,20 +63,14 @@ static u8 spu_read_register_value(struct sys_device 
*sysdev, union spe_reg __iom
 
 static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
 {
-       int value;
+       u8 value;
        struct cbe_pmd_regs __iomem *pmd_regs;
 
        pmd_regs = get_pmd_regs(sysdev);
 
        value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1);
-       /* clear all other bits */
-       value &= 0x3F;
-       /* temp is stored in steps of 2 degrees */
-       value *= 2;
-       /* base temp is 65 degrees */
-       value += 65;
-
-       return sprintf(buf, "%d\n", (int) value);
+
+       return sprintf(buf, "%d\n", reg_to_temp(value));
 }
 
 static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
@@ -82,16 +81,9 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char 
*buf, int pos)
        pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
        value = in_be64(&pmd_regs->ts_ctsr2);
 
-       /* access the corresponding byte */
-       value >>= pos;
-       /* clear all other bits */
-       value &= 0x3F;
-       /* temp is stored in steps of 2 degrees */
-       value *= 2;
-       /* base temp is 65 degrees */
-       value += 65;
+       value = (value >> pos) & 0x3f;
 
-       return sprintf(buf, "%d\n", (int) value);
+       return sprintf(buf, "%d\n", reg_to_temp(value));
 }
 
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to