Skip to contentSkip to conversation

platform/x86: intel_ips: remove unused val in read_mgtv

PATCH In review yangerkun 2 participants 3 messages Jun 4, 2021 – Jun 7, 2021 x86 platform drivers

lore
Share & tools
lore

yangerkun

author
#0 lore raw

PATCH 1/1 platform/x86: intel_ips: remove unused val in read_mgtv

drivers/platform/x86/intel_ips.c:832:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]

  832 |  u16 ret;
      |      ^~~

Fix it by remove the define.

---
 drivers/platform/x86/intel_ips.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_ips.c +2 -13
index bffe548187ee..d40a00ba859a 100644
@@ -829,19 +829,8 @@ static u16 calc_avg_temp(struct ips_driver *ips, u16 *array)
 
 static u16 read_mgtv(struct ips_driver *ips)
 {
-	u16 ret;
-	u64 slope, offset;
-	u64 val;
-
-	val = thm_readq(THM_MGTV);
-	val = (val & TV_MASK) >> TV_SHIFT;
-
-	slope = offset = thm_readw(THM_MGTA);
-	slope = (slope & MGTA_SLOPE_MASK) >> MGTA_SLOPE_SHIFT;
-	offset = offset & MGTA_OFFSET_MASK;
-
-	ret = ((val * slope + 0x40) >> 7) + offset;
-
+	thm_readq(THM_MGTV);
+	thm_readw(THM_MGTA);
 	return 0; /* MCH temp reporting buggy */
 }
 
Signature · 1 line
2.31.1
#1 lore raw

Hi,

Quoted 30 lines · yangerkun

drivers/platform/x86/intel_ips.c:832:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]

  832 |  u16 ret;
      |      ^~~

Fix it by remove the define.

---
 drivers/platform/x86/intel_ips.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_ips.c +0 -8
index bffe548187ee..d40a00ba859a 100644
@@ -829,19 +829,8 @@ static u16 calc_avg_temp(struct ips_driver *ips, u16 *array)
 
 static u16 read_mgtv(struct ips_driver *ips)
 {
-	u16 ret;
-	u64 slope, offset;
-	u64 val;
-
-	val = thm_readq(THM_MGTV);
-	val = (val & TV_MASK) >> TV_SHIFT;
-
-	slope = offset = thm_readw(THM_MGTA);

drivers/platform/x86/intel_ips.c static u16 calc_avg_temp(struct ips_driver *ips, u16 *array) · line 836

Quoted 10 lines
drivers/platform/x86/intel_ips.c +2 -5
-	slope = (slope & MGTA_SLOPE_MASK) >> MGTA_SLOPE_SHIFT;
-	offset = offset & MGTA_OFFSET_MASK;
-
-	ret = ((val * slope + 0x40) >> 7) + offset;
-
+	thm_readq(THM_MGTV);
+	thm_readw(THM_MGTA);
 	return 0; /* MCH temp reporting buggy */
 }
 

I believe it would be good to keep the code around to document how the temperature can be calculated.

Please submit a patch marking ret as __maybe_unused instead.

Regards,

Hans

author
#2 lore raw
Quoted 48 lines · Hans de Goede

Hi,

Quoted 30 lines · yangerkun

drivers/platform/x86/intel_ips.c:832:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]

   832 |  u16 ret;
       |      ^~~

Fix it by remove the define.

---
  drivers/platform/x86/intel_ips.c | 15 ++-------------
  1 file changed, 2 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_ips.c +0 -8
index bffe548187ee..d40a00ba859a 100644
@@ -829,19 +829,8 @@ static u16 calc_avg_temp(struct ips_driver *ips, u16 *array)
 
  static u16 read_mgtv(struct ips_driver *ips)
  {
-	u16 ret;
-	u64 slope, offset;
-	u64 val;
-
-	val = thm_readq(THM_MGTV);
-	val = (val & TV_MASK) >> TV_SHIFT;
-
-	slope = offset = thm_readw(THM_MGTA);

drivers/platform/x86/intel_ips.c static u16 calc_avg_temp(struct ips_driver *ips, u16 *array) · line 836

Quoted 10 lines
drivers/platform/x86/intel_ips.c +2 -5
-	slope = (slope & MGTA_SLOPE_MASK) >> MGTA_SLOPE_SHIFT;
-	offset = offset & MGTA_OFFSET_MASK;
-
-	ret = ((val * slope + 0x40) >> 7) + offset;
-
+	thm_readq(THM_MGTV);
+	thm_readw(THM_MGTA);
  	return 0; /* MCH temp reporting buggy */
  }
 

I believe it would be good to keep the code around to document how the temperature can be calculated.

Quoted 1 line

Please submit a patch marking ret as __maybe_unused instead.

Thanks for your reply, will send v2.

Quoted 7 lines

Regards,

Hans

.