Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1267677 > unrolled thread

[PATCH] i2c: taos-evm: replace simple_strtoul by kstrtou8

Started byLABBE Corentin <clabbe.montjoie@gmail.com>
First post2015-11-12 08:30 +0100
Last post2015-11-12 09:00 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] i2c: taos-evm: replace simple_strtoul by kstrtou8 LABBE Corentin <clabbe.montjoie@gmail.com> - 2015-11-12 08:30 +0100
    Re: [PATCH] i2c: taos-evm: replace simple_strtoul by kstrtou8 Uwe Kleine-König   <u.kleine-koenig@pengutronix.de> - 2015-11-12 08:50 +0100
      Re: [PATCH] i2c: taos-evm: replace simple_strtoul by kstrtou8 LABBE Corentin <montjoie.mailing@gmail.com> - 2015-11-12 09:00 +0100

#1267677 — [PATCH] i2c: taos-evm: replace simple_strtoul by kstrtou8

FromLABBE Corentin <clabbe.montjoie@gmail.com>
Date2015-11-12 08:30 +0100
Subject[PATCH] i2c: taos-evm: replace simple_strtoul by kstrtou8
Message-ID<qtUut-5Rs-15@gated-at.bofh.it>
The simple_strtoul function is marked as obsolete.
This patch replace it by kstrtou8.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/i2c/busses/i2c-taos-evm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index 4c7fc2d..fe2b705 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -70,6 +70,7 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
 	struct serio *serio = adapter->algo_data;
 	struct taos_data *taos = serio_get_drvdata(serio);
 	char *p;
+	int err;
 
 	/* Encode our transaction. "@" is for the device address, "$" for the
 	   SMBus command and "#" for the data. */
@@ -130,7 +131,9 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
 			return 0;
 	} else {
 		if (p[0] == 'x') {
-			data->byte = simple_strtol(p + 1, NULL, 16);
+			err = kstrtou8(p + 1, 16, &data->byte);
+			if (err)
+				return -EPROTO;
 			return 0;
 		}
 	}
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1267691

FromUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date2015-11-12 08:50 +0100
Message-ID<qtUNQ-5ZA-23@gated-at.bofh.it>
In reply to#1267677
On Thu, Nov 12, 2015 at 08:26:33AM +0100, LABBE Corentin wrote:
> The simple_strtoul function is marked as obsolete.
> This patch replace it by kstrtou8.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/i2c/busses/i2c-taos-evm.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
> index 4c7fc2d..fe2b705 100644
> --- a/drivers/i2c/busses/i2c-taos-evm.c
> +++ b/drivers/i2c/busses/i2c-taos-evm.c
> @@ -70,6 +70,7 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
>  	struct serio *serio = adapter->algo_data;
>  	struct taos_data *taos = serio_get_drvdata(serio);
>  	char *p;
> +	int err;
>  
>  	/* Encode our transaction. "@" is for the device address, "$" for the
>  	   SMBus command and "#" for the data. */
> @@ -130,7 +131,9 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
>  			return 0;
>  	} else {
>  		if (p[0] == 'x') {
> -			data->byte = simple_strtol(p + 1, NULL, 16);
> +			err = kstrtou8(p + 1, 16, &data->byte);
> +			if (err)
> +				return -EPROTO;
>  			return 0;

This is nearly equivalent to the probably more correct:

	return kstrtou8(p + 1, 16, &data->byte);

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1267698

FromLABBE Corentin <montjoie.mailing@gmail.com>
Date2015-11-12 09:00 +0100
Message-ID<qtUXx-62X-21@gated-at.bofh.it>
In reply to#1267691
On Thu, Nov 12, 2015 at 08:46:43AM +0100, Uwe Kleine-König wrote:
> On Thu, Nov 12, 2015 at 08:26:33AM +0100, LABBE Corentin wrote:
> > The simple_strtoul function is marked as obsolete.
> > This patch replace it by kstrtou8.
> > 
> > Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> > ---
> >  drivers/i2c/busses/i2c-taos-evm.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
> > index 4c7fc2d..fe2b705 100644
> > --- a/drivers/i2c/busses/i2c-taos-evm.c
> > +++ b/drivers/i2c/busses/i2c-taos-evm.c
> > @@ -70,6 +70,7 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
> >  	struct serio *serio = adapter->algo_data;
> >  	struct taos_data *taos = serio_get_drvdata(serio);
> >  	char *p;
> > +	int err;
> >  
> >  	/* Encode our transaction. "@" is for the device address, "$" for the
> >  	   SMBus command and "#" for the data. */
> > @@ -130,7 +131,9 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
> >  			return 0;
> >  	} else {
> >  		if (p[0] == 'x') {
> > -			data->byte = simple_strtol(p + 1, NULL, 16);
> > +			err = kstrtou8(p + 1, 16, &data->byte);
> > +			if (err)
> > +				return -EPROTO;
> >  			return 0;
> 
> This is nearly equivalent to the probably more correct:
> 
> 	return kstrtou8(p + 1, 16, &data->byte);
> 

As reported, by Jean Delvare, kstrtou8 could return -EINVAL.
It is why I "drop" the return code from kstrtou8 and return -EPROTO as suggested by Jean.

I have hesitate to put a comment for this, and it seems finaly necessary.

Regards

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web