Skip to content

Commit

Permalink
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…padovan/bluetooth
  • Loading branch information
John W. Linville committed Aug 22, 2011
2 parents 16a9d06 + 687beaa commit 4475a0a
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 89 deletions.
1 change: 1 addition & 0 deletions drivers/bluetooth/ath3k.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static struct usb_device_id ath3k_table[] = {
/* Atheros AR3011 with sflash firmware*/
{ USB_DEVICE(0x0CF3, 0x3002) },
{ USB_DEVICE(0x13d3, 0x3304) },
{ USB_DEVICE(0x0930, 0x0215) },

/* Atheros AR9285 Malbec with sflash firmware */
{ USB_DEVICE(0x03F0, 0x311D) },
Expand Down
13 changes: 10 additions & 3 deletions drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static struct usb_device_id blacklist_table[] = {
/* Atheros 3011 with sflash firmware */
{ USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
{ USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
{ USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },

/* Atheros AR9285 Malbec with sflash firmware */
{ USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
Expand Down Expand Up @@ -256,7 +257,9 @@ static void btusb_intr_complete(struct urb *urb)

err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) {
if (err != -EPERM)
/* -EPERM: urb is being killed;
* -ENODEV: device got disconnected */
if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)",
hdev->name, urb, -err);
usb_unanchor_urb(urb);
Expand Down Expand Up @@ -341,7 +344,9 @@ static void btusb_bulk_complete(struct urb *urb)

err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) {
if (err != -EPERM)
/* -EPERM: urb is being killed;
* -ENODEV: device got disconnected */
if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)",
hdev->name, urb, -err);
usb_unanchor_urb(urb);
Expand Down Expand Up @@ -431,7 +436,9 @@ static void btusb_isoc_complete(struct urb *urb)

err = usb_submit_urb(urb, GFP_ATOMIC);
if (err < 0) {
if (err != -EPERM)
/* -EPERM: urb is being killed;
* -ENODEV: device got disconnected */
if (err != -EPERM && err != -ENODEV)
BT_ERR("%s urb %p failed to resubmit (%d)",
hdev->name, urb, -err);
usb_unanchor_urb(urb);
Expand Down
6 changes: 3 additions & 3 deletions net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,8 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
BT_DBG("sk %p", sk);

add_wait_queue(sk_sleep(sk), &wait);
set_current_state(TASK_INTERRUPTIBLE);
while (sk->sk_state != state) {
set_current_state(TASK_INTERRUPTIBLE);

if (!timeo) {
err = -EINPROGRESS;
break;
Expand All @@ -510,12 +509,13 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
release_sock(sk);
timeo = schedule_timeout(timeo);
lock_sock(sk);
set_current_state(TASK_INTERRUPTIBLE);

err = sock_error(sk);
if (err)
break;
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);
return err;
}
Expand Down
1 change: 1 addition & 0 deletions net/bluetooth/bnep/bnep.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct bnep_session {
unsigned int role;
unsigned long state;
unsigned long flags;
atomic_t terminate;
struct task_struct *task;

struct ethhdr eh;
Expand Down
13 changes: 8 additions & 5 deletions net/bluetooth/bnep/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,11 @@ static int bnep_session(void *arg)

init_waitqueue_entry(&wait, current);
add_wait_queue(sk_sleep(sk), &wait);
while (!kthread_should_stop()) {
while (1) {
set_current_state(TASK_INTERRUPTIBLE);

if (atomic_read(&s->terminate))
break;
/* RX */
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
skb_orphan(skb);
Expand All @@ -504,7 +506,7 @@ static int bnep_session(void *arg)

schedule();
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);

/* Cleanup session */
Expand Down Expand Up @@ -640,9 +642,10 @@ int bnep_del_connection(struct bnep_conndel_req *req)
down_read(&bnep_session_sem);

s = __bnep_get_session(req->dst);
if (s)
kthread_stop(s->task);
else
if (s) {
atomic_inc(&s->terminate);
wake_up_process(s->task);
} else
err = -ENOENT;

up_read(&bnep_session_sem);
Expand Down
3 changes: 2 additions & 1 deletion net/bluetooth/cmtp/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ static void cmtp_reset_ctr(struct capi_ctr *ctrl)

capi_ctr_down(ctrl);

kthread_stop(session->task);
atomic_inc(&session->terminate);
wake_up_process(session->task);
}

static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_params *rp)
Expand Down
1 change: 1 addition & 0 deletions net/bluetooth/cmtp/cmtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct cmtp_session {

char name[BTNAMSIZ];

atomic_t terminate;
struct task_struct *task;

wait_queue_head_t wait;
Expand Down
20 changes: 12 additions & 8 deletions net/bluetooth/cmtp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,11 @@ static int cmtp_session(void *arg)

init_waitqueue_entry(&wait, current);
add_wait_queue(sk_sleep(sk), &wait);
while (!kthread_should_stop()) {
while (1) {
set_current_state(TASK_INTERRUPTIBLE);

if (atomic_read(&session->terminate))
break;
if (sk->sk_state != BT_CONNECTED)
break;

Expand All @@ -307,7 +309,7 @@ static int cmtp_session(void *arg)

schedule();
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);

down_write(&cmtp_session_sem);
Expand Down Expand Up @@ -380,16 +382,17 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)

if (!(session->flags & (1 << CMTP_LOOPBACK))) {
err = cmtp_attach_device(session);
if (err < 0)
goto detach;
if (err < 0) {
atomic_inc(&session->terminate);
wake_up_process(session->task);
up_write(&cmtp_session_sem);
return err;
}
}

up_write(&cmtp_session_sem);
return 0;

detach:
cmtp_detach_device(session);

unlink:
__cmtp_unlink_session(session);

Expand All @@ -414,7 +417,8 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
skb_queue_purge(&session->transmit);

/* Stop session thread */
kthread_stop(session->task);
atomic_inc(&session->terminate);
wake_up_process(session->task);
} else
err = -ENOENT;

Expand Down
8 changes: 5 additions & 3 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,6 @@ static void hci_cmd_timer(unsigned long arg)

BT_ERR("%s command tx timeout", hdev->name);
atomic_set(&hdev->cmd_cnt, 1);
clear_bit(HCI_RESET, &hdev->flags);
tasklet_schedule(&hdev->cmd_task);
}

Expand Down Expand Up @@ -1327,7 +1326,7 @@ int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr)

entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
if (!entry) {
return -ENOMEM;
err = -ENOMEM;
goto err;
}

Expand Down Expand Up @@ -2408,7 +2407,10 @@ static void hci_cmd_task(unsigned long arg)
if (hdev->sent_cmd) {
atomic_dec(&hdev->cmd_cnt);
hci_send_frame(skb);
mod_timer(&hdev->cmd_timer,
if (test_bit(HCI_RESET, &hdev->flags))
del_timer(&hdev->cmd_timer);
else
mod_timer(&hdev->cmd_timer,
jiffies + msecs_to_jiffies(HCI_CMD_TIMEOUT));
} else {
skb_queue_head(&hdev->cmd_q, skb);
Expand Down
19 changes: 9 additions & 10 deletions net/bluetooth/hidp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ static int hidp_session(void *arg)

up_write(&hidp_session_sem);

kfree(session->rd_data);
kfree(session);
return 0;
}
Expand Down Expand Up @@ -841,7 +842,8 @@ static int hidp_setup_input(struct hidp_session *session,

err = input_register_device(input);
if (err < 0) {
hci_conn_put_device(session->conn);
input_free_device(input);
session->input = NULL;
return err;
}

Expand Down Expand Up @@ -1044,8 +1046,12 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
}

err = hid_add_device(session->hid);
if (err < 0)
goto err_add_device;
if (err < 0) {
atomic_inc(&session->terminate);
wake_up_process(session->task);
up_write(&hidp_session_sem);
return err;
}

if (session->input) {
hidp_send_ctrl_message(session,
Expand All @@ -1059,12 +1065,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
up_write(&hidp_session_sem);
return 0;

err_add_device:
hid_destroy_device(session->hid);
session->hid = NULL;
atomic_inc(&session->terminate);
wake_up_process(session->task);

unlink:
hidp_del_timer(session);

Expand All @@ -1090,7 +1090,6 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
failed:
up_write(&hidp_session_sem);

input_free_device(session->input);
kfree(session);
return err;
}
Expand Down
6 changes: 3 additions & 3 deletions net/bluetooth/l2cap_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,9 +1159,8 @@ int __l2cap_wait_ack(struct sock *sk)
int timeo = HZ/5;

add_wait_queue(sk_sleep(sk), &wait);
while ((chan->unacked_frames > 0 && chan->conn)) {
set_current_state(TASK_INTERRUPTIBLE);

set_current_state(TASK_INTERRUPTIBLE);
while (chan->unacked_frames > 0 && chan->conn) {
if (!timeo)
timeo = HZ/5;

Expand All @@ -1173,6 +1172,7 @@ int __l2cap_wait_ack(struct sock *sk)
release_sock(sk);
timeo = schedule_timeout(timeo);
lock_sock(sk);
set_current_state(TASK_INTERRUPTIBLE);

err = sock_error(sk);
if (err)
Expand Down
30 changes: 15 additions & 15 deletions net/bluetooth/l2cap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,39 +235,39 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl

lock_sock_nested(sk, SINGLE_DEPTH_NESTING);

if (sk->sk_state != BT_LISTEN) {
err = -EBADFD;
goto done;
}

timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);

BT_DBG("sk %p timeo %ld", sk, timeo);

/* Wait for an incoming connection. (wake-one). */
add_wait_queue_exclusive(sk_sleep(sk), &wait);
while (!(nsk = bt_accept_dequeue(sk, newsock))) {
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
if (!timeo) {
err = -EAGAIN;

if (sk->sk_state != BT_LISTEN) {
err = -EBADFD;
break;
}

release_sock(sk);
timeo = schedule_timeout(timeo);
lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
nsk = bt_accept_dequeue(sk, newsock);
if (nsk)
break;

if (sk->sk_state != BT_LISTEN) {
err = -EBADFD;
if (!timeo) {
err = -EAGAIN;
break;
}

if (signal_pending(current)) {
err = sock_intr_errno(timeo);
break;
}

release_sock(sk);
timeo = schedule_timeout(timeo);
lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
}
set_current_state(TASK_RUNNING);
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);

if (err)
Expand Down Expand Up @@ -993,7 +993,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p
INIT_LIST_HEAD(&bt_sk(sk)->accept_q);

sk->sk_destruct = l2cap_sock_destruct;
sk->sk_sndtimeo = msecs_to_jiffies(L2CAP_CONN_TIMEOUT);
sk->sk_sndtimeo = L2CAP_CONN_TIMEOUT;

sock_reset_flag(sk, SOCK_ZAPPED);

Expand Down
Loading

0 comments on commit 4475a0a

Please sign in to comment.