diff mbox series

[RFC/RFT,1/7] i2c: sh_mobile: simplify sending address for RX

Message ID 20190116210555.12209-2-wsa+renesas@sang-engineering.com
State Accepted
Headers show
Series i2c: sh_mobile: state machine simplifications | expand

Commit Message

Wolfram Sang Jan. 16, 2019, 9:05 p.m. UTC
pd->pos won't be smaller than -1, so we can simplify the logic.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-sh_mobile.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Geert Uytterhoeven Jan. 17, 2019, 10:11 a.m. UTC | #1
Hi Wolfram,

On Thu, Jan 17, 2019 at 1:36 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> pd->pos won't be smaller than -1, so we can simplify the logic.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks for your patch!

> --- a/drivers/i2c/busses/i2c-sh_mobile.c
> +++ b/drivers/i2c/busses/i2c-sh_mobile.c
> @@ -392,13 +392,9 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
>         int real_pos;
>
>         do {
> -               if (pd->pos <= -1) {

If this condition is never true, shouldn't the block just be removed instead?

> +               if (sh_mobile_i2c_is_first_byte(pd)) {
>                         sh_mobile_i2c_get_data(pd, &data);
> -
> -                       if (sh_mobile_i2c_is_first_byte(pd))
> -                               i2c_op(pd, OP_TX_FIRST, data);
> -                       else
> -                               i2c_op(pd, OP_TX, data);
> +                       i2c_op(pd, OP_TX_FIRST, data);
>                         break;
>                 }

Gr{oetje,eeting}s,

                        Geert
Wolfram Sang Jan. 17, 2019, 10:18 a.m. UTC | #2
On Thu, Jan 17, 2019 at 11:11:09AM +0100, Geert Uytterhoeven wrote:
> Hi Wolfram,
> 
> On Thu, Jan 17, 2019 at 1:36 AM Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> > pd->pos won't be smaller than -1, so we can simplify the logic.
> >
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/i2c/busses/i2c-sh_mobile.c
> > +++ b/drivers/i2c/busses/i2c-sh_mobile.c
> > @@ -392,13 +392,9 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
> >         int real_pos;
> >
> >         do {
> > -               if (pd->pos <= -1) {
> 
> If this condition is never true, shouldn't the block just be removed instead?

"pd->pos won't be *smaller* than -1"
Geert Uytterhoeven Jan. 17, 2019, 10:23 a.m. UTC | #3
Hi Wolfram,

On Thu, Jan 17, 2019 at 11:18 AM Wolfram Sang <wsa@the-dreams.de> wrote:
> On Thu, Jan 17, 2019 at 11:11:09AM +0100, Geert Uytterhoeven wrote:
> > On Thu, Jan 17, 2019 at 1:36 AM Wolfram Sang
> > <wsa+renesas@sang-engineering.com> wrote:
> > > pd->pos won't be smaller than -1, so we can simplify the logic.
> > >
> > > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> >
> > Thanks for your patch!
> >
> > > --- a/drivers/i2c/busses/i2c-sh_mobile.c
> > > +++ b/drivers/i2c/busses/i2c-sh_mobile.c
> > > @@ -392,13 +392,9 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
> > >         int real_pos;
> > >
> > >         do {
> > > -               if (pd->pos <= -1) {
> >
> > If this condition is never true, shouldn't the block just be removed instead?
>
> "pd->pos won't be *smaller* than -1"

I stand corrected.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index a64f2ff3cb49..e18e3cedf817 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -392,13 +392,9 @@  static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
 	int real_pos;
 
 	do {
-		if (pd->pos <= -1) {
+		if (sh_mobile_i2c_is_first_byte(pd)) {
 			sh_mobile_i2c_get_data(pd, &data);
-
-			if (sh_mobile_i2c_is_first_byte(pd))
-				i2c_op(pd, OP_TX_FIRST, data);
-			else
-				i2c_op(pd, OP_TX, data);
+			i2c_op(pd, OP_TX_FIRST, data);
 			break;
 		}