2012-11-22 21:03:52

by Chao Bi

[permalink] [raw]
Subject: [PATCH] serial:ifx6x60:Delete SPI timer when shut down port


When shut down SPI port, it's possible that MRDY has been asserted and a SPI
timer was activated waiting for SRDY assert, in the case, it needs to delete
this timer.

Signed-off-by: Chen Jun <[email protected]>
Signed-off-by: channing <[email protected]>
---
drivers/tty/serial/ifx6x60.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 5b9bc19..467020b 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -552,7 +552,10 @@ static void ifx_port_shutdown(struct tty_port *port)
container_of(port, struct ifx_spi_device, tty_port);

mrdy_set_low(ifx_dev);
- clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
+ if (test_and_clear_bit(IFX_SPI_STATE_TIMER_PENDING,
+ &ifx_dev->flags)) {
+ del_timer(&ifx_dev->spi_timer);
+ }
tasklet_kill(&ifx_dev->io_work_tasklet);
}

--
1.7.1



2012-11-22 18:30:39

by Alan

[permalink] [raw]
Subject: Re: [PATCH] serial:ifx6x60:Delete SPI timer when shut down port

On Thu, 22 Nov 2012 16:43:07 +0800
chao bi <[email protected]> wrote:

>
> When shut down SPI port, it's possible that MRDY has been asserted
> and a SPI timer was activated waiting for SRDY assert, in the case,
> it needs to delete this timer.
>
> Signed-off-by: Chen Jun <[email protected]>
> Signed-off-by: channing <[email protected]>
> ---
> drivers/tty/serial/ifx6x60.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/tty/serial/ifx6x60.c
> b/drivers/tty/serial/ifx6x60.c index 5b9bc19..467020b 100644
> --- a/drivers/tty/serial/ifx6x60.c
> +++ b/drivers/tty/serial/ifx6x60.c
> @@ -552,7 +552,10 @@ static void ifx_port_shutdown(struct tty_port
> *port) container_of(port, struct ifx_spi_device, tty_port);
>
> mrdy_set_low(ifx_dev);
> - clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
> + if (test_and_clear_bit(IFX_SPI_STATE_TIMER_PENDING,
> + &ifx_dev->flags)) {
> + del_timer(&ifx_dev->spi_timer);
> + }

You don't actually need the test here as far as I can see. Providing a
timer has been initialised (init_timer) then running del_timer is safe
even if the timer is not currently queued or has completed.

Alan

2012-11-23 01:18:59

by Chao Bi

[permalink] [raw]
Subject: Re: [PATCH] serial:ifx6x60:Delete SPI timer when shut down port

On Thu, 2012-11-22 at 11:06 +0000, Alan Cox wrote:
> > --- a/drivers/tty/serial/ifx6x60.c
> > +++ b/drivers/tty/serial/ifx6x60.c
> > @@ -552,7 +552,10 @@ static void ifx_port_shutdown(struct tty_port
> > *port) container_of(port, struct ifx_spi_device, tty_port);
> >
> > mrdy_set_low(ifx_dev);
> > - clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
> > + if (test_and_clear_bit(IFX_SPI_STATE_TIMER_PENDING,
> > + &ifx_dev->flags)) {
> > + del_timer(&ifx_dev->spi_timer);
> > + }
>
> You don't actually need the test here as far as I can see. Providing a
> timer has been initialised (init_timer) then running del_timer is safe
> even if the timer is not currently queued or has completed.
>
> Alan

Yes, thanks. I'll update it.