diff mbox

[1/5] auxdisplay: charlcd: no need to call charlcd_gotoxy() if nothing changes

Message ID 0cb9a05c09295bcad4dd914ee44806ac6c244cbd.1516008708.git.sean@mess.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Young Jan. 15, 2018, 9:58 a.m. UTC
If the line extends beyond the width to the screen, nothing changes. The
existing code will call charlcd_gotoxy every time for this case.

Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/auxdisplay/charlcd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Miguel Ojeda Feb. 12, 2018, 1:42 p.m. UTC | #1
On Mon, Jan 15, 2018 at 10:58 AM, Sean Young <sean@mess.org> wrote:
> If the line extends beyond the width to the screen, nothing changes. The
> existing code will call charlcd_gotoxy every time for this case.
>
> Signed-off-by: Sean Young <sean@mess.org>
> ---
>  drivers/auxdisplay/charlcd.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
> index 642afd88870b..45ec5ce697c4 100644
> --- a/drivers/auxdisplay/charlcd.c
> +++ b/drivers/auxdisplay/charlcd.c
> @@ -192,10 +192,11 @@ static void charlcd_print(struct charlcd *lcd, char c)
>                         c = lcd->char_conv[(unsigned char)c];
>                 lcd->ops->write_data(lcd, c);
>                 priv->addr.x++;
> +
> +               /* prevents the cursor from wrapping onto the next line */
> +               if (priv->addr.x == lcd->bwidth)
> +                       charlcd_gotoxy(lcd);
>         }
> -       /* prevents the cursor from wrapping onto the next line */
> -       if (priv->addr.x == lcd->bwidth)
> -               charlcd_gotoxy(lcd);
>  }
>

Willy, Geert: is this fine with you? Seems fine: charlcd_write_char()
right now does an unconditional write_cmd() when writing a normal
character; so unless some HW requires the command for some reason even
if there is nothing changed, we can skip it.

>  static void charlcd_clear_fast(struct charlcd *lcd)
> --
> 2.14.3
>
Geert Uytterhoeven Feb. 12, 2018, 1:59 p.m. UTC | #2
On Mon, Feb 12, 2018 at 2:42 PM, Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
> On Mon, Jan 15, 2018 at 10:58 AM, Sean Young <sean@mess.org> wrote:
>> If the line extends beyond the width to the screen, nothing changes. The
>> existing code will call charlcd_gotoxy every time for this case.
>>
>> Signed-off-by: Sean Young <sean@mess.org>
>> ---
>>  drivers/auxdisplay/charlcd.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
>> index 642afd88870b..45ec5ce697c4 100644
>> --- a/drivers/auxdisplay/charlcd.c
>> +++ b/drivers/auxdisplay/charlcd.c
>> @@ -192,10 +192,11 @@ static void charlcd_print(struct charlcd *lcd, char c)
>>                         c = lcd->char_conv[(unsigned char)c];
>>                 lcd->ops->write_data(lcd, c);
>>                 priv->addr.x++;
>> +
>> +               /* prevents the cursor from wrapping onto the next line */
>> +               if (priv->addr.x == lcd->bwidth)
>> +                       charlcd_gotoxy(lcd);
>>         }
>> -       /* prevents the cursor from wrapping onto the next line */
>> -       if (priv->addr.x == lcd->bwidth)
>> -               charlcd_gotoxy(lcd);
>>  }
>>
>
> Willy, Geert: is this fine with you? Seems fine: charlcd_write_char()
> right now does an unconditional write_cmd() when writing a normal
> character; so unless some HW requires the command for some reason even
> if there is nothing changed, we can skip it.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Miguel Ojeda Feb. 12, 2018, 5:30 p.m. UTC | #3
On Mon, Feb 12, 2018 at 2:59 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Mon, Feb 12, 2018 at 2:42 PM, Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
>> On Mon, Jan 15, 2018 at 10:58 AM, Sean Young <sean@mess.org> wrote:
>>> If the line extends beyond the width to the screen, nothing changes. The
>>> existing code will call charlcd_gotoxy every time for this case.
>>>
>>> Signed-off-by: Sean Young <sean@mess.org>
>>> ---
>>>  drivers/auxdisplay/charlcd.c | 7 ++++---
>>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
>>> index 642afd88870b..45ec5ce697c4 100644
>>> --- a/drivers/auxdisplay/charlcd.c
>>> +++ b/drivers/auxdisplay/charlcd.c
>>> @@ -192,10 +192,11 @@ static void charlcd_print(struct charlcd *lcd, char c)
>>>                         c = lcd->char_conv[(unsigned char)c];
>>>                 lcd->ops->write_data(lcd, c);
>>>                 priv->addr.x++;
>>> +
>>> +               /* prevents the cursor from wrapping onto the next line */
>>> +               if (priv->addr.x == lcd->bwidth)
>>> +                       charlcd_gotoxy(lcd);
>>>         }
>>> -       /* prevents the cursor from wrapping onto the next line */
>>> -       if (priv->addr.x == lcd->bwidth)
>>> -               charlcd_gotoxy(lcd);
>>>  }
>>>
>>
>> Willy, Geert: is this fine with you? Seems fine: charlcd_write_char()
>> right now does an unconditional write_cmd() when writing a normal
>> character; so unless some HW requires the command for some reason even
>> if there is nothing changed, we can skip it.
>
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
>

Thanks a lot, picking it up then.

Miguel

> Gr{oetje,eeting}s,
>
>                         Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
diff mbox

Patch

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index 642afd88870b..45ec5ce697c4 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -192,10 +192,11 @@  static void charlcd_print(struct charlcd *lcd, char c)
 			c = lcd->char_conv[(unsigned char)c];
 		lcd->ops->write_data(lcd, c);
 		priv->addr.x++;
+
+		/* prevents the cursor from wrapping onto the next line */
+		if (priv->addr.x == lcd->bwidth)
+			charlcd_gotoxy(lcd);
 	}
-	/* prevents the cursor from wrapping onto the next line */
-	if (priv->addr.x == lcd->bwidth)
-		charlcd_gotoxy(lcd);
 }
 
 static void charlcd_clear_fast(struct charlcd *lcd)