diff mbox series

interconnect: qcom: Fix endianness in an intermediate storage

Message ID 20210930122254.8899-1-vladimir.zapolskiy@linaro.org
State New
Headers show
Series interconnect: qcom: Fix endianness in an intermediate storage | expand

Commit Message

Vladimir Zapolskiy Sept. 30, 2021, 12:22 p.m. UTC
A minor issue is reported by sparse:

bcm-voter.c:72:77: warning: restricted __le16 degrades to integer
bcm-voter.c:76:78: warning: restricted __le16 degrades to integer
bcm-voter.c:82:66: warning: incorrect type in argument 2 (different base types)
bcm-voter.c:82:66:    expected unsigned int [usertype] base
bcm-voter.c:82:66:    got restricted __le32 [usertype] unit
bcm-voter.c:85:66: warning: incorrect type in argument 2 (different base types)
bcm-voter.c:85:66:    expected unsigned int [usertype] base
bcm-voter.c:85:66:    got restricted __le32 [usertype] unit

icc-rpmh.c:165:28: warning: incorrect type in assignment (different base types)
icc-rpmh.c:165:28:    expected restricted __le32 [usertype] unit
icc-rpmh.c:165:28:    got unsigned int [usertype]
icc-rpmh.c:166:29: warning: incorrect type in assignment (different base types)
icc-rpmh.c:166:29:    expected restricted __le16 [usertype] width
icc-rpmh.c:166:29:    got unsigned short [usertype]

The change is intended to be non-functional, only the stored data of
'struct bcm_db' is changed and build time warnings from above are gone.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>

---
 drivers/interconnect/qcom/bcm-voter.c | 8 ++++----
 drivers/interconnect/qcom/icc-rpmh.c  | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.33.0

Comments

Bjorn Andersson Sept. 30, 2021, 5:47 p.m. UTC | #1
On Thu 30 Sep 05:22 PDT 2021, Vladimir Zapolskiy wrote:

> A minor issue is reported by sparse:

> 

> bcm-voter.c:72:77: warning: restricted __le16 degrades to integer

> bcm-voter.c:76:78: warning: restricted __le16 degrades to integer

> bcm-voter.c:82:66: warning: incorrect type in argument 2 (different base types)

> bcm-voter.c:82:66:    expected unsigned int [usertype] base

> bcm-voter.c:82:66:    got restricted __le32 [usertype] unit

> bcm-voter.c:85:66: warning: incorrect type in argument 2 (different base types)

> bcm-voter.c:85:66:    expected unsigned int [usertype] base

> bcm-voter.c:85:66:    got restricted __le32 [usertype] unit

> 

> icc-rpmh.c:165:28: warning: incorrect type in assignment (different base types)

> icc-rpmh.c:165:28:    expected restricted __le32 [usertype] unit

> icc-rpmh.c:165:28:    got unsigned int [usertype]

> icc-rpmh.c:166:29: warning: incorrect type in assignment (different base types)

> icc-rpmh.c:166:29:    expected restricted __le16 [usertype] width

> icc-rpmh.c:166:29:    got unsigned short [usertype]

> 

> The change is intended to be non-functional, only the stored data of

> 'struct bcm_db' is changed and build time warnings from above are gone.

> 


Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>


Regards,
Bjorn

> Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>

> ---

>  drivers/interconnect/qcom/bcm-voter.c | 8 ++++----

>  drivers/interconnect/qcom/icc-rpmh.c  | 4 ++--

>  2 files changed, 6 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c

> index 8f385f9c2dd3..976938a84bd1 100644

> --- a/drivers/interconnect/qcom/bcm-voter.c

> +++ b/drivers/interconnect/qcom/bcm-voter.c

> @@ -69,20 +69,20 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)

>  	for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {

>  		for (i = 0; i < bcm->num_nodes; i++) {

>  			node = bcm->nodes[i];

> -			temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,

> +			temp = bcm_div(node->sum_avg[bucket] * le16_to_cpu(bcm->aux_data.width),

>  				       node->buswidth * node->channels);

>  			agg_avg[bucket] = max(agg_avg[bucket], temp);

>  

> -			temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,

> +			temp = bcm_div(node->max_peak[bucket] * le16_to_cpu(bcm->aux_data.width),

>  				       node->buswidth);

>  			agg_peak[bucket] = max(agg_peak[bucket], temp);

>  		}

>  

>  		temp = agg_avg[bucket] * bcm->vote_scale;

> -		bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);

> +		bcm->vote_x[bucket] = bcm_div(temp, le32_to_cpu(bcm->aux_data.unit));

>  

>  		temp = agg_peak[bucket] * bcm->vote_scale;

> -		bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);

> +		bcm->vote_y[bucket] = bcm_div(temp, le32_to_cpu(bcm->aux_data.unit));

>  	}

>  

>  	if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&

> diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c

> index 3eb7936d2cf6..e8533027ce38 100644

> --- a/drivers/interconnect/qcom/icc-rpmh.c

> +++ b/drivers/interconnect/qcom/icc-rpmh.c

> @@ -162,8 +162,8 @@ int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev)

>  		return -EINVAL;

>  	}

>  

> -	bcm->aux_data.unit = le32_to_cpu(data->unit);

> -	bcm->aux_data.width = le16_to_cpu(data->width);

> +	bcm->aux_data.unit = data->unit;

> +	bcm->aux_data.width = data->width;

>  	bcm->aux_data.vcd = data->vcd;

>  	bcm->aux_data.reserved = data->reserved;

>  	INIT_LIST_HEAD(&bcm->list);

> -- 

> 2.33.0

>
Georgi Djakov Oct. 4, 2021, 12:29 p.m. UTC | #2
Hi Vladimir,

Thanks for working on this!

On 30.09.21 15:22, Vladimir Zapolskiy wrote:
> A minor issue is reported by sparse:

> 

> bcm-voter.c:72:77: warning: restricted __le16 degrades to integer

> bcm-voter.c:76:78: warning: restricted __le16 degrades to integer

> bcm-voter.c:82:66: warning: incorrect type in argument 2 (different base types)

> bcm-voter.c:82:66:    expected unsigned int [usertype] base

> bcm-voter.c:82:66:    got restricted __le32 [usertype] unit

> bcm-voter.c:85:66: warning: incorrect type in argument 2 (different base types)

> bcm-voter.c:85:66:    expected unsigned int [usertype] base

> bcm-voter.c:85:66:    got restricted __le32 [usertype] unit

> 

> icc-rpmh.c:165:28: warning: incorrect type in assignment (different base types)

> icc-rpmh.c:165:28:    expected restricted __le32 [usertype] unit

> icc-rpmh.c:165:28:    got unsigned int [usertype]

> icc-rpmh.c:166:29: warning: incorrect type in assignment (different base types)

> icc-rpmh.c:166:29:    expected restricted __le16 [usertype] width

> icc-rpmh.c:166:29:    got unsigned short [usertype]

> 

> The change is intended to be non-functional, only the stored data of

> 'struct bcm_db' is changed and build time warnings from above are gone.


Nice! But with your patch i see another sparse warning. Could you fix
it too, please?

bcm-voter.c:117:21: warning: restricted __le32 degrades to integer
bcm-voter.c:117:21: warning: restricted __le32 degrades to integer

Thanks,
Georgi

> 

> Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>

> ---

>   drivers/interconnect/qcom/bcm-voter.c | 8 ++++----

>   drivers/interconnect/qcom/icc-rpmh.c  | 4 ++--

>   2 files changed, 6 insertions(+), 6 deletions(-)

> 

> diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c

> index 8f385f9c2dd3..976938a84bd1 100644

> --- a/drivers/interconnect/qcom/bcm-voter.c

> +++ b/drivers/interconnect/qcom/bcm-voter.c

> @@ -69,20 +69,20 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)

>   	for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {

>   		for (i = 0; i < bcm->num_nodes; i++) {

>   			node = bcm->nodes[i];

> -			temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,

> +			temp = bcm_div(node->sum_avg[bucket] * le16_to_cpu(bcm->aux_data.width),

>   				       node->buswidth * node->channels);

>   			agg_avg[bucket] = max(agg_avg[bucket], temp);

>   

> -			temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,

> +			temp = bcm_div(node->max_peak[bucket] * le16_to_cpu(bcm->aux_data.width),

>   				       node->buswidth);

>   			agg_peak[bucket] = max(agg_peak[bucket], temp);

>   		}

>   

>   		temp = agg_avg[bucket] * bcm->vote_scale;

> -		bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);

> +		bcm->vote_x[bucket] = bcm_div(temp, le32_to_cpu(bcm->aux_data.unit));

>   

>   		temp = agg_peak[bucket] * bcm->vote_scale;

> -		bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);

> +		bcm->vote_y[bucket] = bcm_div(temp, le32_to_cpu(bcm->aux_data.unit));

>   	}

>   

>   	if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&

> diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c

> index 3eb7936d2cf6..e8533027ce38 100644

> --- a/drivers/interconnect/qcom/icc-rpmh.c

> +++ b/drivers/interconnect/qcom/icc-rpmh.c

> @@ -162,8 +162,8 @@ int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev)

>   		return -EINVAL;

>   	}

>   

> -	bcm->aux_data.unit = le32_to_cpu(data->unit);

> -	bcm->aux_data.width = le16_to_cpu(data->width);

> +	bcm->aux_data.unit = data->unit;

> +	bcm->aux_data.width = data->width;

>   	bcm->aux_data.vcd = data->vcd;

>   	bcm->aux_data.reserved = data->reserved;

>   	INIT_LIST_HEAD(&bcm->list);

>
diff mbox series

Patch

diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
index 8f385f9c2dd3..976938a84bd1 100644
--- a/drivers/interconnect/qcom/bcm-voter.c
+++ b/drivers/interconnect/qcom/bcm-voter.c
@@ -69,20 +69,20 @@  static void bcm_aggregate(struct qcom_icc_bcm *bcm)
 	for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
 		for (i = 0; i < bcm->num_nodes; i++) {
 			node = bcm->nodes[i];
-			temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,
+			temp = bcm_div(node->sum_avg[bucket] * le16_to_cpu(bcm->aux_data.width),
 				       node->buswidth * node->channels);
 			agg_avg[bucket] = max(agg_avg[bucket], temp);
 
-			temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,
+			temp = bcm_div(node->max_peak[bucket] * le16_to_cpu(bcm->aux_data.width),
 				       node->buswidth);
 			agg_peak[bucket] = max(agg_peak[bucket], temp);
 		}
 
 		temp = agg_avg[bucket] * bcm->vote_scale;
-		bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);
+		bcm->vote_x[bucket] = bcm_div(temp, le32_to_cpu(bcm->aux_data.unit));
 
 		temp = agg_peak[bucket] * bcm->vote_scale;
-		bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
+		bcm->vote_y[bucket] = bcm_div(temp, le32_to_cpu(bcm->aux_data.unit));
 	}
 
 	if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&
diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c
index 3eb7936d2cf6..e8533027ce38 100644
--- a/drivers/interconnect/qcom/icc-rpmh.c
+++ b/drivers/interconnect/qcom/icc-rpmh.c
@@ -162,8 +162,8 @@  int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev)
 		return -EINVAL;
 	}
 
-	bcm->aux_data.unit = le32_to_cpu(data->unit);
-	bcm->aux_data.width = le16_to_cpu(data->width);
+	bcm->aux_data.unit = data->unit;
+	bcm->aux_data.width = data->width;
 	bcm->aux_data.vcd = data->vcd;
 	bcm->aux_data.reserved = data->reserved;
 	INIT_LIST_HEAD(&bcm->list);