[3/4] pinctrl: stmfx: update the result type of dm_i2c_reg_read
diff mbox series

Message ID 20200128094415.5768-4-patrick.delaunay@st.com
State Accepted
Delegated to: Patrick Delaunay
Headers show
Series
  • Several patch to solve warning on stm32mp1 board with W=1
Related show

Commit Message

Patrick Delaunay Jan. 28, 2020, 9:44 a.m. UTC
Use int as result of dm_i2c_reg_read to avoid warning with
W=1 (warning: comparison is always false due to limited range
of data type [-Wtype-limits])

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/pinctrl/pinctrl-stmfx.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Patrice CHOTARD Feb. 14, 2020, 7:55 a.m. UTC | #1
On 1/28/20 10:44 AM, Patrick Delaunay wrote:
> Use int as result of dm_i2c_reg_read to avoid warning with
> W=1 (warning: comparison is always false due to limited range
> of data type [-Wtype-limits])
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  drivers/pinctrl/pinctrl-stmfx.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c
> index 0b5a0433cd..0def27166e 100644
> --- a/drivers/pinctrl/pinctrl-stmfx.c
> +++ b/drivers/pinctrl/pinctrl-stmfx.c
> @@ -351,11 +351,12 @@ static int stmfx_chip_init(struct udevice *dev)
>  	int ret;
>  	struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
>  
> -	id = dm_i2c_reg_read(dev, STMFX_REG_CHIP_ID);
> -	if (id < 0) {
> -		dev_err(dev, "error reading chip id: %d\n", id);
> +	ret = dm_i2c_reg_read(dev, STMFX_REG_CHIP_ID);
> +	if (ret < 0) {
> +		dev_err(dev, "error reading chip id: %d\n", ret);
>  		return ret;
>  	}
> +	id = (u8)ret;
>  	/*
>  	 * Check that ID is the complement of the I2C address:
>  	 * STMFX I2C address follows the 7-bit format (MSB), that's why

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks
Patrick Delaunay Feb. 14, 2020, 10:31 a.m. UTC | #2
Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: mardi 28 janvier 2020 10:44
> 
> Use int as result of dm_i2c_reg_read to avoid warning with
> W=1 (warning: comparison is always false due to limited range of data type [-
> Wtype-limits])
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---

Applied to u-boot-stm32/master, thanks!

Regards
Patrick

Patch
diff mbox series

diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c
index 0b5a0433cd..0def27166e 100644
--- a/drivers/pinctrl/pinctrl-stmfx.c
+++ b/drivers/pinctrl/pinctrl-stmfx.c
@@ -351,11 +351,12 @@  static int stmfx_chip_init(struct udevice *dev)
 	int ret;
 	struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
 
-	id = dm_i2c_reg_read(dev, STMFX_REG_CHIP_ID);
-	if (id < 0) {
-		dev_err(dev, "error reading chip id: %d\n", id);
+	ret = dm_i2c_reg_read(dev, STMFX_REG_CHIP_ID);
+	if (ret < 0) {
+		dev_err(dev, "error reading chip id: %d\n", ret);
 		return ret;
 	}
+	id = (u8)ret;
 	/*
 	 * Check that ID is the complement of the I2C address:
 	 * STMFX I2C address follows the 7-bit format (MSB), that's why