usbfs: fix deadlock on 'usbfs_mutex', clean up poll
The caller of usbfs_conn_disc_event() in some cases (but not always)
already holds usbfs_mutex, so trying to protect the event counter with
that lock causes nasty deadlocks.
The problem was introduced by commit
554f76962d ("USB: Remove BKL from
poll()") when the BLK protection was turned into using the mutex instead.
So fix this by using an atomic variable instead. And while we're at it,
get rid of the atrocious naming of said variable and the waitqueue it is
associated with.
This also cleans up the unnecessary locking in the poll routine, since
the whole point of how the pollwait table works is that you can just add
yourself to the waiting list, and then check the condition you're
waiting for afterwards - avoiding all races.
It also gets rid of the unnecessary dynamic allocation of the device
status that just contained a single word. We should use f_version for
this, as Dmitry Torokhov points out. That simplifies everything
further.
Reported-and-tested-by: Jeff Chua <jeff.chua.linux@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>