[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Yk6iHfvLffyocjrK@gofer.mess.org>
Date: Thu, 7 Apr 2022 09:34:37 +0100
From: Sean Young <sean@...s.org>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
stable <stable@...r.kernel.org>,
Михаил <vrserver1@...il.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Subject: Re: [PATCH 5.16 0172/1017] media: gpio-ir-tx: fix transmit with long
spaces on Orange Pi PC
On Tue, Apr 05, 2022 at 03:16:07PM +0200, Geert Uytterhoeven wrote:
> On Tue, Apr 5, 2022 at 1:33 PM Greg Kroah-Hartman
> <gregkh@...uxfoundation.org> wrote:
> > From: Sean Young <sean@...s.org>
> >
> > commit 5ad05ecad4326ddaa26a83ba2233a67be24c1aaa upstream.
> >
> > Calling udelay for than 1000us does not always yield the correct
> > results.
> >
> > Cc: stable@...r.kernel.org
> > Reported-by: Михаил <vrserver1@...il.com>
> > Signed-off-by: Sean Young <sean@...s.org>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@...nel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> > ---
> > drivers/media/rc/gpio-ir-tx.c | 28 +++++++++++++++++++++-------
> > 1 file changed, 21 insertions(+), 7 deletions(-)
> >
> > --- a/drivers/media/rc/gpio-ir-tx.c
> > +++ b/drivers/media/rc/gpio-ir-tx.c
> > @@ -48,11 +48,29 @@ static int gpio_ir_tx_set_carrier(struct
> > return 0;
> > }
> >
> > +static void delay_until(ktime_t until)
> > +{
> > + /*
> > + * delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on
> > + * m68k ndelay(s64) does not compile; so use s32 rather than s64.
> > + */
> > + s32 delta;
> > +
> > + while (true) {
> > + delta = ktime_us_delta(until, ktime_get());
> > + if (delta <= 0)
> > + return;
> > +
> > + /* udelay more than 1ms may not work */
> > + delta = min(delta, 1000);
> > + udelay(delta);
> > + }
>
> Yeah, that's why we have mdelay(), which loops around udelay() if no
> arch-specific implementation is provided.
That is a good point. That doesn't make this patch incorrect, just a bit ugly.
Can this patch be merged as-is please, and I'll write an patch upstream that
simplifies the code.
Thanks
Sean
>
> > +}
> > +
> > static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
> > uint count)
> > {
> > ktime_t edge;
> > - s32 delta;
> > int i;
> >
> > local_irq_disable();
> > @@ -63,9 +81,7 @@ static void gpio_ir_tx_unmodulated(struc
> > gpiod_set_value(gpio_ir->gpio, !(i % 2));
> >
> > edge = ktime_add_us(edge, txbuf[i]);
> > - delta = ktime_us_delta(edge, ktime_get());
> > - if (delta > 0)
> > - udelay(delta);
> > + delay_until(edge);
> > }
> >
> > gpiod_set_value(gpio_ir->gpio, 0);
> > @@ -97,9 +113,7 @@ static void gpio_ir_tx_modulated(struct
> > if (i % 2) {
> > // space
> > edge = ktime_add_us(edge, txbuf[i]);
> > - delta = ktime_us_delta(edge, ktime_get());
> > - if (delta > 0)
> > - udelay(delta);
> > + delay_until(edge);
> > } else {
> > // pulse
> > ktime_t last = ktime_add_us(edge, txbuf[i]);
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-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
Powered by blists - more mailing lists