2023-12-06 22:24:40

by Christophe Leroy

[permalink] [raw]
Subject: [PATCH v2] i2c: cpm: Remove linux,i2c-index conversion from be32

sparse reports an error on some data that gets converted from be32.

That's because that data is typed u32 instead of __be32.

The type is correct, the be32_to_cpu() conversion is not.

Remove the conversion.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Christophe Leroy <[email protected]>
---
v2: Use u32 directly, remove be32_to_cpu().
---
drivers/i2c/busses/i2c-cpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 9a664abf734d..771d60bc8d71 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -658,7 +658,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
/* register new adapter to i2c module... */

data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
- cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
+ cpm->adap.nr = (data && len == 4) ? *data : -1;
result = i2c_add_numbered_adapter(&cpm->adap);

if (result < 0)
--
2.41.0


2023-12-08 11:27:52

by Jochen Friedrich

[permalink] [raw]
Subject: Re: [PATCH v2] i2c: cpm: Remove linux,i2c-index conversion from be32

Acked-By: Jochen Friedrich <[email protected]>

Am 06.12.2023 um 23:24 schrieb Christophe Leroy:
> sparse reports an error on some data that gets converted from be32.
>
> That's because that data is typed u32 instead of __be32.
>
> The type is correct, the be32_to_cpu() conversion is not.
>
> Remove the conversion.
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: Christophe Leroy <[email protected]>
> ---
> v2: Use u32 directly, remove be32_to_cpu().
> ---
> drivers/i2c/busses/i2c-cpm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
> index 9a664abf734d..771d60bc8d71 100644
> --- a/drivers/i2c/busses/i2c-cpm.c
> +++ b/drivers/i2c/busses/i2c-cpm.c
> @@ -658,7 +658,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
> /* register new adapter to i2c module... */
>
> data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
> - cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
> + cpm->adap.nr = (data && len == 4) ? *data : -1;
> result = i2c_add_numbered_adapter(&cpm->adap);
>
> if (result < 0)

2023-12-09 00:11:14

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH v2] i2c: cpm: Remove linux,i2c-index conversion from be32

Hi Christophe,

On Wed, Dec 06, 2023 at 11:24:03PM +0100, Christophe Leroy wrote:
> sparse reports an error on some data that gets converted from be32.
>
> That's because that data is typed u32 instead of __be32.
>
> The type is correct, the be32_to_cpu() conversion is not.
>
> Remove the conversion.
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: Christophe Leroy <[email protected]>
> ---
> v2: Use u32 directly, remove be32_to_cpu().
> ---
> drivers/i2c/busses/i2c-cpm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
> index 9a664abf734d..771d60bc8d71 100644
> --- a/drivers/i2c/busses/i2c-cpm.c
> +++ b/drivers/i2c/busses/i2c-cpm.c
> @@ -658,7 +658,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
> /* register new adapter to i2c module... */
>
> data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
> - cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
> + cpm->adap.nr = (data && len == 4) ? *data : -1;

thanks!

Reviewed-by: Andi Shyti <[email protected]>

Andi

2023-12-19 17:19:27

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH v2] i2c: cpm: Remove linux,i2c-index conversion from be32

On Wed, Dec 06, 2023 at 11:24:03PM +0100, Christophe Leroy wrote:
> sparse reports an error on some data that gets converted from be32.
>
> That's because that data is typed u32 instead of __be32.
>
> The type is correct, the be32_to_cpu() conversion is not.
>
> Remove the conversion.
>
> Reported-by: kernel test robot <[email protected]>
> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: Christophe Leroy <[email protected]>

Applied to for-next, thanks!


Attachments:
(No filename) (536.00 B)
signature.asc (849.00 B)
Download all attachments