[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99cab456-5d08-931c-0d59-4415f822c542@amd.com>
Date:   Wed, 17 May 2023 10:04:29 -0400
From:   Yazen Ghannam <yazen.ghannam@....com>
To:     Guenter Roeck <linux@...ck-us.net>
Cc:     yazen.ghannam@....com, x86@...nel.org,
        linux-kernel@...r.kernel.org, platform-driver-x86@...r.kernel.org,
        markgross@...nel.org, hdegoede@...hat.com,
        Shyam-sundar.S-k@....com, linux-edac@...r.kernel.org,
        clemens@...isch.de, jdelvare@...e.com, linux-hwmon@...r.kernel.org,
        mario.limonciello@....com, babu.moger@....com
Subject: Re: [PATCH 3/6] hwmon: (k10temp) Check return value of amd_smn_read()
On 5/17/23 8:25 AM, Guenter Roeck wrote:
[...]
>>  static long get_raw_temp(struct k10temp_data *data)
>> @@ -213,9 +214,11 @@ static int k10temp_read_temp(struct device *dev, u32 attr, int channel,
>>  				*val = 0;
>>  			break;
>>  		case 2 ... 13:		/* Tccd{1-12} */
>> -			amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
>> -				     ZEN_CCD_TEMP(data->ccd_offset, channel - 2),
>> -						  ®val);
>> +			if (amd_smn_read(amd_pci_dev_to_node_id(data->pdev),
>> +					 ZEN_CCD_TEMP(data->ccd_offset, channel - 2),
>> +					 ®val))
>> +				return -EINVAL;
>> +
> 
> -EINVAL: Invalid Argument, supposed to be used for bad user input.
> I don't see how that would apply here. amd_smn_read() returns
> a valid error code. This error core should be returned to the caller,
> or there needs to be an explanation why this is not appropriate.
>
Understood. Will change it to return the amd_smn_read() error code.
>>  			*val = (regval & ZEN_CCD_TEMP_MASK) * 125 - 49000;
>>  			break;
>>  		default:
>> @@ -373,8 +376,10 @@ static void k10temp_get_ccd_support(struct pci_dev *pdev,
>>  	int i;
>>  
>>  	for (i = 0; i < limit; i++) {
>> -		amd_smn_read(amd_pci_dev_to_node_id(pdev),
>> -			     ZEN_CCD_TEMP(data->ccd_offset, i), ®val);
>> +		if (amd_smn_read(amd_pci_dev_to_node_id(pdev),
>> +				 ZEN_CCD_TEMP(data->ccd_offset, i), ®val))
>> +			continue;
>> +
> The reason for ignoring the error should be explained here.
>
Sure thing. I'll add a code comment above.
Thanks,
Yazen
Powered by blists - more mailing lists