[PATCH 1/1 try 2] V4L: rocket, switch sleep_on to completion - Kernel

This is a discussion on [PATCH 1/1 try 2] V4L: rocket, switch sleep_on to completion - Kernel ; rocket, switch sleep_on to completion - sleep_on is deprecated and racy, use completion instead - also check retval of interruptible function and return ERESTARTSYS eventually Signed-off-by: Jiri Slaby --- commit db2ca3cf492a6a8a4578e6adb869e1a20558b84e tree 4f732e546579c3482db61cc6e5e34087d4815a4b parent 9936225b4a065eec6eccd9700a680cc840280fdb author Jiri Slaby Mon, 08 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: [PATCH 1/1 try 2] V4L: rocket, switch sleep_on to completion

  1. [PATCH 1/1 try 2] V4L: rocket, switch sleep_on to completion

    rocket, switch sleep_on to completion

    - sleep_on is deprecated and racy, use completion instead
    - also check retval of interruptible function and return ERESTARTSYS
    eventually

    Signed-off-by: Jiri Slaby

    ---
    commit db2ca3cf492a6a8a4578e6adb869e1a20558b84e
    tree 4f732e546579c3482db61cc6e5e34087d4815a4b
    parent 9936225b4a065eec6eccd9700a680cc840280fdb
    author Jiri Slaby Mon, 08 Oct 2007 14:44:04 +0200
    committer Jiri Slaby Mon, 08 Oct 2007 14:44:04 +0200

    drivers/char/rocket.c | 12 ++++++++----
    drivers/char/rocket_int.h | 7 +------
    2 files changed, 9 insertions(+), 10 deletions(-)

    diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
    index 56cbba7..d790b08 100644
    --- a/drivers/char/rocket.c
    +++ b/drivers/char/rocket.c
    @@ -84,6 +84,7 @@
    #include
    #include
    #include
    +#include
    #include
    #include
    #include
    @@ -650,7 +651,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
    info->closing_wait = 3000;
    info->close_delay = 50;
    init_waitqueue_head(&info->open_wait);
    - init_waitqueue_head(&info->close_wait);
    + init_completion(&info->close_wait);
    info->flags &= ~ROCKET_MODE_MASK;
    switch (pc104[board][line]) {
    case 422:
    @@ -878,7 +879,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    if (tty_hung_up_p(filp))
    return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
    if (info->flags & ROCKET_CLOSING) {
    - interruptible_sleep_on(&info->close_wait);
    + if (wait_for_completion_interruptible(&info->close_wait))
    + return -ERESTARTSYS;
    return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
    }

    @@ -983,8 +985,10 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
    return -ENOMEM;

    if (info->flags & ROCKET_CLOSING) {
    - interruptible_sleep_on(&info->close_wait);
    + retval = wait_for_completion_interruptible(&info->close_wait);
    free_page(page);
    + if (retval)
    + return retval;
    return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
    }

    @@ -1176,7 +1180,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
    }
    info->flags &= ~(ROCKET_INITIALIZED | ROCKET_CLOSING | ROCKET_NORMAL_ACTIVE);
    tty->closing = 0;
    - wake_up_interruptible(&info->close_wait);
    + complete_all(&info->close_wait);
    atomic_dec(&rp_num_ports_open);

    #ifdef ROCKET_DEBUG_OPEN
    diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h
    index b4c53df..55b8f2d 100644
    --- a/drivers/char/rocket_int.h
    +++ b/drivers/char/rocket_int.h
    @@ -1163,13 +1163,8 @@ struct r_port {
    int read_status_mask;
    int cps;

    -#ifdef DECLARE_WAITQUEUE
    wait_queue_head_t open_wait;
    - wait_queue_head_t close_wait;
    -#else
    - struct wait_queue *open_wait;
    - struct wait_queue *close_wait;
    -#endif
    + struct completion close_wait;
    spinlock_t slock;
    struct mutex write_mtx;
    };
    -
    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/

  2. Re: [PATCH 1/1 try 2] V4L: rocket, switch sleep_on to completion

    Hi Jiri,

    The patch might be right, however, AFAIK, this has nothing to do with
    V4L. Better to change the subject

    Cheers,
    Mauro.

    Em Seg, 2007-10-08 *s 08:45 -0400, Jiri Slaby escreveu:
    > rocket, switch sleep_on to completion
    >
    > - sleep_on is deprecated and racy, use completion instead
    > - also check retval of interruptible function and return ERESTARTSYS
    > eventually
    >
    > Signed-off-by: Jiri Slaby
    >
    > ---
    > commit db2ca3cf492a6a8a4578e6adb869e1a20558b84e
    > tree 4f732e546579c3482db61cc6e5e34087d4815a4b
    > parent 9936225b4a065eec6eccd9700a680cc840280fdb
    > author Jiri Slaby Mon, 08 Oct 2007 14:44:04 +0200
    > committer Jiri Slaby Mon, 08 Oct 2007 14:44:04 +0200
    >
    > drivers/char/rocket.c | 12 ++++++++----
    > drivers/char/rocket_int.h | 7 +------
    > 2 files changed, 9 insertions(+), 10 deletions(-)
    >
    > diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
    > index 56cbba7..d790b08 100644
    > --- a/drivers/char/rocket.c
    > +++ b/drivers/char/rocket.c
    > @@ -84,6 +84,7 @@
    > #include
    > #include
    > #include
    > +#include
    > #include
    > #include
    > #include
    > @@ -650,7 +651,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
    > info->closing_wait = 3000;
    > info->close_delay = 50;
    > init_waitqueue_head(&info->open_wait);
    > - init_waitqueue_head(&info->close_wait);
    > + init_completion(&info->close_wait);
    > info->flags &= ~ROCKET_MODE_MASK;
    > switch (pc104[board][line]) {
    > case 422:
    > @@ -878,7 +879,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
    > if (tty_hung_up_p(filp))
    > return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
    > if (info->flags & ROCKET_CLOSING) {
    > - interruptible_sleep_on(&info->close_wait);
    > + if (wait_for_completion_interruptible(&info->close_wait))
    > + return -ERESTARTSYS;
    > return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
    > }
    >
    > @@ -983,8 +985,10 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
    > return -ENOMEM;
    >
    > if (info->flags & ROCKET_CLOSING) {
    > - interruptible_sleep_on(&info->close_wait);
    > + retval = wait_for_completion_interruptible(&info->close_wait);
    > free_page(page);
    > + if (retval)
    > + return retval;
    > return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS);
    > }
    >
    > @@ -1176,7 +1180,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
    > }
    > info->flags &= ~(ROCKET_INITIALIZED | ROCKET_CLOSING | ROCKET_NORMAL_ACTIVE);
    > tty->closing = 0;
    > - wake_up_interruptible(&info->close_wait);
    > + complete_all(&info->close_wait);
    > atomic_dec(&rp_num_ports_open);
    >
    > #ifdef ROCKET_DEBUG_OPEN
    > diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h
    > index b4c53df..55b8f2d 100644
    > --- a/drivers/char/rocket_int.h
    > +++ b/drivers/char/rocket_int.h
    > @@ -1163,13 +1163,8 @@ struct r_port {
    > int read_status_mask;
    > int cps;
    >
    > -#ifdef DECLARE_WAITQUEUE
    > wait_queue_head_t open_wait;
    > - wait_queue_head_t close_wait;
    > -#else
    > - struct wait_queue *open_wait;
    > - struct wait_queue *close_wait;
    > -#endif
    > + struct completion close_wait;
    > spinlock_t slock;
    > struct mutex write_mtx;
    > };
    > -
    > 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/

    --
    Cheers,
    Mauro

    -
    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/

  3. Re: [PATCH 1/1 try 2] V4L: rocket, switch sleep_on to completion

    On 10/08/2007 05:31 PM, Mauro Carvalho Chehab wrote:
    > Hi Jiri,
    >
    > The patch might be right, however, AFAIK, this has nothing to do with
    > V4L. Better to change the subject


    Aha, you're right, forgot to change it to Char after V4L patchset .

    thanks,
    --
    Jiri Slaby (jirislaby@gmail.com)
    Faculty of Informatics, Masaryk University
    -
    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/

+ Reply to Thread