diff mbox series

[net,1/4] net: aquantia: temperature retrieval fix

Message ID 8167dd20577261b78fbbd8bcad6c9605f510508b.1570708006.git.igor.russkikh@aquantia.com
State Changes Requested
Delegated to: David Miller
Headers show
Series Aquantia/Marvell AQtion atlantic driver fixes 10/2019 | expand

Commit Message

Igor Russkikh Oct. 10, 2019, 2:01 p.m. UTC
Chip temperature is a two byte word, colocated internally with cable
length data. We do all readouts from HW memory by dwords, thus
we should clear extra high bytes, otherwise temperature output
gets weird as soon as we attach a cable to the NIC.

Fixes: 8f8940118654 ("net: aquantia: add infrastructure to readout chip temperature")
Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
---
 .../net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Oct. 11, 2019, 5:38 a.m. UTC | #1
On Thu, Oct 10, 2019 at 02:01:22PM +0000, Igor Russkikh wrote:
> Chip temperature is a two byte word, colocated internally with cable
> length data. We do all readouts from HW memory by dwords, thus
> we should clear extra high bytes, otherwise temperature output
> gets weird as soon as we attach a cable to the NIC.
> 
> Fixes: 8f8940118654 ("net: aquantia: add infrastructure to readout chip temperature")
> Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
> Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
> ---
>  .../net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c   | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
> index da726489e3c8..08b026b41571 100644
> --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
> +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
> @@ -337,7 +337,7 @@ static int aq_fw2x_get_phy_temp(struct aq_hw_s *self, int *temp)
>  	/* Convert PHY temperature from 1/256 degree Celsius
>  	 * to 1/1000 degree Celsius.
>  	 */
> -	*temp = temp_res  * 1000 / 256;
> +	*temp = (temp_res & 0xFFFF)  * 1000 / 256;

Perhaps while the extra space before '*' could be dropped at the same time.

>  
>  	return 0;
>  }
> -- 
> 2.17.1
>
Igor Russkikh Oct. 11, 2019, 8:25 a.m. UTC | #2
>>  	 * to 1/1000 degree Celsius.
>>  	 */
>> -	*temp = temp_res  * 1000 / 256;
>> +	*temp = (temp_res & 0xFFFF)  * 1000 / 256;
> 
> Perhaps while the extra space before '*' could be dropped at the same time.

Hi Simon, thanks for noticing this. Will do.

Regards
  Igor
diff mbox series

Patch

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
index da726489e3c8..08b026b41571 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -337,7 +337,7 @@  static int aq_fw2x_get_phy_temp(struct aq_hw_s *self, int *temp)
 	/* Convert PHY temperature from 1/256 degree Celsius
 	 * to 1/1000 degree Celsius.
 	 */
-	*temp = temp_res  * 1000 / 256;
+	*temp = (temp_res & 0xFFFF)  * 1000 / 256;
 
 	return 0;
 }