diff mbox series

[v3,03/19] hwmon: (mr75203) update pvt->v_num to the actual number of used sensors

Message ID 20220830192212.28570-4-farbere@amazon.com (mailing list archive)
State Changes Requested
Headers show
Series Variety of fixes and new features for mr75203 driver | expand

Commit Message

Farber, Eliav Aug. 30, 2022, 7:21 p.m. UTC
This issue is relevant when "intel,vm-map" is set in device-tree, and
defines a lower number of VMs than actually supported.

This change is needed for all places that use pvt->v_num later on in the
code.

Signed-off-by: Eliav Farber <farbere@amazon.com>
---
 drivers/hwmon/mr75203.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Guenter Roeck Aug. 31, 2022, 2:41 a.m. UTC | #1
On 8/30/22 12:21, Eliav Farber wrote:
> This issue is relevant when "intel,vm-map" is set in device-tree, and
> defines a lower number of VMs than actually supported.
> 
> This change is needed for all places that use pvt->v_num later on in the
> code.
> 
> Signed-off-by: Eliav Farber <farbere@amazon.com>
> ---
>   drivers/hwmon/mr75203.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
> index 0e29877a1a9c..f89f7bb5d698 100644
> --- a/drivers/hwmon/mr75203.c
> +++ b/drivers/hwmon/mr75203.c
> @@ -605,6 +605,7 @@ static int mr75203_probe(struct platform_device *pdev)
>   					break;
>   
>   			vm_num = i;
> +			pvt->v_num = i;

How about the existing assignment in the probe function ?

>   		}
>   
>   		in_config = devm_kcalloc(dev, vm_num + 1,
Farber, Eliav Aug. 31, 2022, 4:50 a.m. UTC | #2
On 8/31/2022 5:41 AM, Guenter Roeck wrote:
> On 8/30/22 12:21, Eliav Farber wrote:
>> This issue is relevant when "intel,vm-map" is set in device-tree, and
>> defines a lower number of VMs than actually supported.
>>
>> This change is needed for all places that use pvt->v_num later on in the
>> code.
>>
>> Signed-off-by: Eliav Farber <farbere@amazon.com>
>> ---
>>   drivers/hwmon/mr75203.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
>> index 0e29877a1a9c..f89f7bb5d698 100644
>> --- a/drivers/hwmon/mr75203.c
>> +++ b/drivers/hwmon/mr75203.c
>> @@ -605,6 +605,7 @@ static int mr75203_probe(struct platform_device 
>> *pdev)
>>                                       break;
>>
>>                       vm_num = i;
>> +                     pvt->v_num = i;
>
> How about the existing assignment in the probe function ? 
The probe function uses a local variable vm_num which is also updated
(just one line earlier in code) in the previous patch.

--
Thanks, Eliav
Guenter Roeck Aug. 31, 2022, 5:31 a.m. UTC | #3
On 8/30/22 21:50, Farber, Eliav wrote:
> On 8/31/2022 5:41 AM, Guenter Roeck wrote:
>> On 8/30/22 12:21, Eliav Farber wrote:
>>> This issue is relevant when "intel,vm-map" is set in device-tree, and
>>> defines a lower number of VMs than actually supported.
>>>
>>> This change is needed for all places that use pvt->v_num later on in the
>>> code.
>>>
>>> Signed-off-by: Eliav Farber <farbere@amazon.com>
>>> ---
>>>   drivers/hwmon/mr75203.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
>>> index 0e29877a1a9c..f89f7bb5d698 100644
>>> --- a/drivers/hwmon/mr75203.c
>>> +++ b/drivers/hwmon/mr75203.c
>>> @@ -605,6 +605,7 @@ static int mr75203_probe(struct platform_device *pdev)
>>>                                       break;
>>>
>>>                       vm_num = i;
>>> +                     pvt->v_num = i;
>>
>> How about the existing assignment in the probe function ? 
> The probe function uses a local variable vm_num which is also updated
> (just one line earlier in code) in the previous patch.
> 

I meant
	pvt->v_num = vm_num;
at line 536 of the current code, but I guess the idea is to overwrite that.

Thanks,
Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
index 0e29877a1a9c..f89f7bb5d698 100644
--- a/drivers/hwmon/mr75203.c
+++ b/drivers/hwmon/mr75203.c
@@ -605,6 +605,7 @@  static int mr75203_probe(struct platform_device *pdev)
 					break;
 
 			vm_num = i;
+			pvt->v_num = i;
 		}
 
 		in_config = devm_kcalloc(dev, vm_num + 1,