Commit e5b3fa15 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

isdn: pcbit: fix interruptible_sleep_on race

interruptible_sleep_on is racy and going away. In case of pcbit,
the driver would run into a timeout if the card is initialized
before we start waiting for it. This uses wait_event to fix the
race. In order to do this, the state machine handling for the
timeout case has to get trivially reorganized so we actually know
whether the timeout has occorred or not.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c73b1f6a
...@@ -796,6 +796,7 @@ static void set_running_timeout(unsigned long ptr) ...@@ -796,6 +796,7 @@ static void set_running_timeout(unsigned long ptr)
#endif #endif
dev = (struct pcbit_dev *) ptr; dev = (struct pcbit_dev *) ptr;
dev->l2_state = L2_DOWN;
wake_up_interruptible(&dev->set_running_wq); wake_up_interruptible(&dev->set_running_wq);
} }
...@@ -818,7 +819,8 @@ static int set_protocol_running(struct pcbit_dev *dev) ...@@ -818,7 +819,8 @@ static int set_protocol_running(struct pcbit_dev *dev)
add_timer(&dev->set_running_timer); add_timer(&dev->set_running_timer);
interruptible_sleep_on(&dev->set_running_wq); wait_event(dev->set_running_wq, dev->l2_state == L2_RUNNING ||
dev->l2_state == L2_DOWN);
del_timer(&dev->set_running_timer); del_timer(&dev->set_running_timer);
...@@ -842,8 +844,6 @@ static int set_protocol_running(struct pcbit_dev *dev) ...@@ -842,8 +844,6 @@ static int set_protocol_running(struct pcbit_dev *dev)
printk(KERN_DEBUG "pcbit: initialization failed\n"); printk(KERN_DEBUG "pcbit: initialization failed\n");
printk(KERN_DEBUG "pcbit: firmware not loaded\n"); printk(KERN_DEBUG "pcbit: firmware not loaded\n");
dev->l2_state = L2_DOWN;
#ifdef DEBUG #ifdef DEBUG
printk(KERN_DEBUG "Bank3 = %02x\n", printk(KERN_DEBUG "Bank3 = %02x\n",
readb(dev->sh_mem + BANK3)); readb(dev->sh_mem + BANK3));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment