diff mbox series

[v4,07/20] thermal/drivers/tsens: limit num_sensors to 9

Message ID 20221221020520.1326964-8-dmitry.baryshkov@linaro.org
State New
Headers show
Series thermal/drivers/tsens: specify nvmem cells in DT rather than parsing them manually | expand

Commit Message

Dmitry Baryshkov Dec. 21, 2022, 2:05 a.m. UTC
According to the vendor kernels (msm-3.10, 3.14 and 3.18), msm8939
supports only 9 sensors. Remove the rogue sensor's hw_id.

Fixes: 332bc8ebab2c ("thermal: qcom: tsens-v0_1: Add support for MSM8939")
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/thermal/qcom/tsens-v0_1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Daniel Lezcano Dec. 21, 2022, 6:15 p.m. UTC | #1
On 21/12/2022 19:05, Dmitry Baryshkov wrote:
> On 21/12/2022 17:45, Daniel Lezcano wrote:
>> On 21/12/2022 03:05, Dmitry Baryshkov wrote:
>>> According to the vendor kernels (msm-3.10, 3.14 and 3.18), msm8939
>>> supports only 9 sensors. Remove the rogue sensor's hw_id.
>>>
>>> Fixes: 332bc8ebab2c ("thermal: qcom: tsens-v0_1: Add support for 
>>> MSM8939")
>>> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>> ---
>>>   drivers/thermal/qcom/tsens-v0_1.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/thermal/qcom/tsens-v0_1.c 
>>> b/drivers/thermal/qcom/tsens-v0_1.c
>>> index 0bc4e5cec184..57ac23f9d9b7 100644
>>> --- a/drivers/thermal/qcom/tsens-v0_1.c
>>> +++ b/drivers/thermal/qcom/tsens-v0_1.c
>>> @@ -605,9 +605,9 @@ static const struct tsens_ops ops_8939 = {
>>>   };
>>>   struct tsens_plat_data data_8939 = {
>>> -    .num_sensors    = 10,
>>> +    .num_sensors    = 9,
>>>       .ops        = &ops_8939,
>>> -    .hw_ids        = (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9, 
>>> 10 },
>>> +    .hw_ids        = (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9 },
>>
>> Does not patch 4 says we can drop those hw_ids ?
> 
> No. In patch 4 we drop contiguous IDs. For the msm8939 sensor 4 is 
> omitted from hw_ids, so we can not drop the array.

Ah, yes, indeed.

  .num_sensor = ARRAY_SIZE(data_8939.hw_ids); should work

If the hw_ids are ordered, you may consider a bitmask instead of an array
Dmitry Baryshkov Dec. 21, 2022, 7:42 p.m. UTC | #2
On 21/12/2022 20:15, Daniel Lezcano wrote:
> On 21/12/2022 19:05, Dmitry Baryshkov wrote:
>> On 21/12/2022 17:45, Daniel Lezcano wrote:
>>> On 21/12/2022 03:05, Dmitry Baryshkov wrote:
>>>> According to the vendor kernels (msm-3.10, 3.14 and 3.18), msm8939
>>>> supports only 9 sensors. Remove the rogue sensor's hw_id.
>>>>
>>>> Fixes: 332bc8ebab2c ("thermal: qcom: tsens-v0_1: Add support for 
>>>> MSM8939")
>>>> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
>>>> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>>> ---
>>>>   drivers/thermal/qcom/tsens-v0_1.c | 4 ++--
>>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/thermal/qcom/tsens-v0_1.c 
>>>> b/drivers/thermal/qcom/tsens-v0_1.c
>>>> index 0bc4e5cec184..57ac23f9d9b7 100644
>>>> --- a/drivers/thermal/qcom/tsens-v0_1.c
>>>> +++ b/drivers/thermal/qcom/tsens-v0_1.c
>>>> @@ -605,9 +605,9 @@ static const struct tsens_ops ops_8939 = {
>>>>   };
>>>>   struct tsens_plat_data data_8939 = {
>>>> -    .num_sensors    = 10,
>>>> +    .num_sensors    = 9,
>>>>       .ops        = &ops_8939,
>>>> -    .hw_ids        = (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9, 
>>>> 10 },
>>>> +    .hw_ids        = (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9 },
>>>
>>> Does not patch 4 says we can drop those hw_ids ?
>>
>> No. In patch 4 we drop contiguous IDs. For the msm8939 sensor 4 is 
>> omitted from hw_ids, so we can not drop the array.
> 
> Ah, yes, indeed.
> 
>   .num_sensor = ARRAY_SIZE(data_8939.hw_ids); should work

Interesting suggestion, I should give it a thought.

> 
> If the hw_ids are ordered, you may consider a bitmask instead of an array

I'm not sure if it's worth doing that. With the current approach it is 
easy to get hw_id corresponding to the sensor #i, If we switch to the 
bitmask, it wouldn't be that easy. And the saved space isn't that big.
Konrad Dybcio Dec. 21, 2022, 8:13 p.m. UTC | #3
On 21.12.2022 03:05, Dmitry Baryshkov wrote:
> According to the vendor kernels (msm-3.10, 3.14 and 3.18), msm8939
> supports only 9 sensors. Remove the rogue sensor's hw_id.
msm-3.18 and 8939.. I would have never thought it was there!


> 
> Fixes: 332bc8ebab2c ("thermal: qcom: tsens-v0_1: Add support for MSM8939")
> Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  drivers/thermal/qcom/tsens-v0_1.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
> index 0bc4e5cec184..57ac23f9d9b7 100644
> --- a/drivers/thermal/qcom/tsens-v0_1.c
> +++ b/drivers/thermal/qcom/tsens-v0_1.c
> @@ -605,9 +605,9 @@ static const struct tsens_ops ops_8939 = {
>  };
>  
>  struct tsens_plat_data data_8939 = {
> -	.num_sensors	= 10,
> +	.num_sensors	= 9,
>  	.ops		= &ops_8939,
> -	.hw_ids		= (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9, 10 },
> +	.hw_ids		= (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9 },
>  
>  	.feat		= &tsens_v0_1_feat,
>  	.fields	= tsens_v0_1_regfields,
diff mbox series

Patch

diff --git a/drivers/thermal/qcom/tsens-v0_1.c b/drivers/thermal/qcom/tsens-v0_1.c
index 0bc4e5cec184..57ac23f9d9b7 100644
--- a/drivers/thermal/qcom/tsens-v0_1.c
+++ b/drivers/thermal/qcom/tsens-v0_1.c
@@ -605,9 +605,9 @@  static const struct tsens_ops ops_8939 = {
 };
 
 struct tsens_plat_data data_8939 = {
-	.num_sensors	= 10,
+	.num_sensors	= 9,
 	.ops		= &ops_8939,
-	.hw_ids		= (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9, 10 },
+	.hw_ids		= (unsigned int []){ 0, 1, 2, 3, 5, 6, 7, 8, 9 },
 
 	.feat		= &tsens_v0_1_feat,
 	.fields	= tsens_v0_1_regfields,