Thread (6 messages) 6 messages, 2 authors, 2017-07-06

[PATCH v3 2/2] thermal: uniphier: add UniPhier thermal driver

From: Masahiro Yamada <hidden>
Date: 2017-07-05 12:20:38
Also in: linux-pm, lkml

2017-07-05 20:50 GMT+09:00 Kunihiko Hayashi [off-list ref]:
+
+#define TMOD                           0x0928
+#define TMOD_MASK                      GENMASK(9, 0)
+
 [ snip ]
+
+       /*
+        * The bit[8:0] of TMOD register represents 2's complement value
+        * of temperature in Celsius. Since bit8 of TMOD shows a sign bit,
+        * 32bit temperature value is obtained by sign extension.
+        */

Apparently, this comment does not match your code:

     #define TMOD_MASK                      GENMASK(9, 0)


TMOD_MASK is indicating bit[9:0].



Digging into the patch history, now I understood what happened.



In v1, you described
#define TMOD_MASK         0x1ff

This was correct.


In v2, you converted it into
#define TMOD_MASK          GENMASK(9, 0)

This was misconversion.  It should be GENMASK(8, 0)



Anyway, TMOD_MASK is not used any more.

+       *out_temp = sign_extend32(temp, 8) * 1000;

Why magic number here?

   /* MSB of the TMOD field is a sign bit */
   *out_temp = sign_extend32(temp, TMOD_WIDTH) * 1000;


-- 
Best Regards
Masahiro Yamada
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help