diff mbox series

[3/3] soc: qcom: pmic_pdcharger_ulog: Fix hypothetical ulog request message endianess

Message ID 20231205-pmicpdcharger-ulog-fixups-v1-3-71c95162cb84@redhat.com (mailing list archive)
State Accepted
Commit fbfd1f55ad34be14e52b39a1b83ae1f0d29b890c
Headers show
Series soc: qcom: pmic_pdcharger_ulog: Fix compilation | expand

Commit Message

Andrew Halaney Dec. 5, 2023, 11:05 p.m. UTC
Sparse reports the following:

    % ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make C=2 W=1 drivers/soc/qcom/pmic_pdcharger_ulog.o
    ...
      CC      drivers/soc/qcom/pmic_pdcharger_ulog.o
      CHECK   drivers/soc/qcom/pmic_pdcharger_ulog.c
    drivers/soc/qcom/pmic_pdcharger_ulog.c:57:34: warning: incorrect type in initializer (different base types)
    drivers/soc/qcom/pmic_pdcharger_ulog.c:57:34:    expected restricted __le32 [usertype] owner
    drivers/soc/qcom/pmic_pdcharger_ulog.c:57:34:    got int
    drivers/soc/qcom/pmic_pdcharger_ulog.c:58:33: warning: incorrect type in initializer (different base types)
    drivers/soc/qcom/pmic_pdcharger_ulog.c:58:33:    expected restricted __le32 [usertype] type
    drivers/soc/qcom/pmic_pdcharger_ulog.c:58:33:    got int
    drivers/soc/qcom/pmic_pdcharger_ulog.c:59:35: warning: incorrect type in initializer (different base types)
    drivers/soc/qcom/pmic_pdcharger_ulog.c:59:35:    expected restricted __le32 [usertype] opcode
    drivers/soc/qcom/pmic_pdcharger_ulog.c:59:35:    got int

Let's deal with endianness conversion in the rare case this ever runs
on a big-endian machine (and to quiet down sparse for this file).

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312060355.M0eJtq4X-lkp@intel.com/
Fixes: 086fdb48bc65 ("soc: qcom: add ADSP PDCharger ULOG driver")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
---
 drivers/soc/qcom/pmic_pdcharger_ulog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Neil Armstrong Dec. 12, 2023, 3:24 p.m. UTC | #1
On 06/12/2023 00:05, Andrew Halaney wrote:
> Sparse reports the following:
> 
>      % ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make C=2 W=1 drivers/soc/qcom/pmic_pdcharger_ulog.o
>      ...
>        CC      drivers/soc/qcom/pmic_pdcharger_ulog.o
>        CHECK   drivers/soc/qcom/pmic_pdcharger_ulog.c
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:57:34: warning: incorrect type in initializer (different base types)
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:57:34:    expected restricted __le32 [usertype] owner
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:57:34:    got int
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:58:33: warning: incorrect type in initializer (different base types)
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:58:33:    expected restricted __le32 [usertype] type
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:58:33:    got int
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:59:35: warning: incorrect type in initializer (different base types)
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:59:35:    expected restricted __le32 [usertype] opcode
>      drivers/soc/qcom/pmic_pdcharger_ulog.c:59:35:    got int
> 
> Let's deal with endianness conversion in the rare case this ever runs
> on a big-endian machine (and to quiet down sparse for this file).
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202312060355.M0eJtq4X-lkp@intel.com/
> Fixes: 086fdb48bc65 ("soc: qcom: add ADSP PDCharger ULOG driver")
> Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
> ---
>   drivers/soc/qcom/pmic_pdcharger_ulog.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/soc/qcom/pmic_pdcharger_ulog.c b/drivers/soc/qcom/pmic_pdcharger_ulog.c
> index f1aaacf05005..238cd38589dc 100644
> --- a/drivers/soc/qcom/pmic_pdcharger_ulog.c
> +++ b/drivers/soc/qcom/pmic_pdcharger_ulog.c
> @@ -54,9 +54,9 @@ static int pmic_pdcharger_ulog_request(struct pmic_pdcharger_ulog *pg)
>   {
>   	struct get_ulog_req_msg req_msg = {
>   		.hdr = {
> -			.owner = MSG_OWNER_CHG_ULOG,
> -			.type = MSG_TYPE_REQ_RESP,
> -			.opcode = GET_CHG_ULOG_REQ
> +			.owner = cpu_to_le32(MSG_OWNER_CHG_ULOG),
> +			.type = cpu_to_le32(MSG_TYPE_REQ_RESP),
> +			.opcode = cpu_to_le32(GET_CHG_ULOG_REQ)
>   		},
>   		.log_size = MAX_ULOG_SIZE
>   	};
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
diff mbox series

Patch

diff --git a/drivers/soc/qcom/pmic_pdcharger_ulog.c b/drivers/soc/qcom/pmic_pdcharger_ulog.c
index f1aaacf05005..238cd38589dc 100644
--- a/drivers/soc/qcom/pmic_pdcharger_ulog.c
+++ b/drivers/soc/qcom/pmic_pdcharger_ulog.c
@@ -54,9 +54,9 @@  static int pmic_pdcharger_ulog_request(struct pmic_pdcharger_ulog *pg)
 {
 	struct get_ulog_req_msg req_msg = {
 		.hdr = {
-			.owner = MSG_OWNER_CHG_ULOG,
-			.type = MSG_TYPE_REQ_RESP,
-			.opcode = GET_CHG_ULOG_REQ
+			.owner = cpu_to_le32(MSG_OWNER_CHG_ULOG),
+			.type = cpu_to_le32(MSG_TYPE_REQ_RESP),
+			.opcode = cpu_to_le32(GET_CHG_ULOG_REQ)
 		},
 		.log_size = MAX_ULOG_SIZE
 	};