Skip to content

Commit

Permalink
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/holtmann/bluetooth-next-2.6
  • Loading branch information
David S. Miller committed Dec 3, 2009
2 parents 424eff9 + 2861453 commit a7fca0c
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 116 deletions.
1 change: 0 additions & 1 deletion drivers/bluetooth/btmrvl_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct btmrvl_debugfs_data {
struct dentry *root_dir, *config_dir, *status_dir;

/* config */
struct dentry *drvdbg;
struct dentry *psmode;
struct dentry *pscmd;
struct dentry *hsmode;
Expand Down
1 change: 1 addition & 0 deletions drivers/bluetooth/btmrvl_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb);
int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb);

int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd);
int btmrvl_enable_ps(struct btmrvl_private *priv);
int btmrvl_prepare_command(struct btmrvl_private *priv);

#ifdef CONFIG_DEBUG_FS
Expand Down
55 changes: 33 additions & 22 deletions drivers/bluetooth/btmrvl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,38 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
}
EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);

int btmrvl_enable_ps(struct btmrvl_private *priv)
{
struct sk_buff *skb;
struct btmrvl_cmd *cmd;

skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
return -ENOMEM;
}

cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
BT_CMD_AUTO_SLEEP_MODE));
cmd->length = 1;

if (priv->btmrvl_dev.psmode)
cmd->data[0] = BT_PS_ENABLE;
else
cmd->data[0] = BT_PS_DISABLE;

bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;

skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb);

BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);

return 0;
}
EXPORT_SYMBOL_GPL(btmrvl_enable_ps);

static int btmrvl_enable_hs(struct btmrvl_private *priv)
{
struct sk_buff *skb;
Expand Down Expand Up @@ -258,28 +290,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)

if (priv->btmrvl_dev.pscmd) {
priv->btmrvl_dev.pscmd = 0;

skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
if (skb == NULL) {
BT_ERR("No free skb");
return -ENOMEM;
}

cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_AUTO_SLEEP_MODE));
cmd->length = 1;

if (priv->btmrvl_dev.psmode)
cmd->data[0] = BT_PS_ENABLE;
else
cmd->data[0] = BT_PS_DISABLE;

bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;

skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb);

BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
btmrvl_enable_ps(priv);
}

if (priv->btmrvl_dev.hscmd) {
Expand Down
4 changes: 4 additions & 0 deletions drivers/bluetooth/btmrvl_sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw;

btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);
priv->btmrvl_dev.psmode = 1;
btmrvl_enable_ps(priv);

return 0;

Expand Down Expand Up @@ -1001,3 +1003,5 @@ MODULE_AUTHOR("Marvell International Ltd.");
MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION);
MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL v2");
MODULE_FIRMWARE("sd8688_helper.bin");
MODULE_FIRMWARE("sd8688.bin");
20 changes: 3 additions & 17 deletions drivers/bluetooth/hci_vhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

#define VERSION "1.3"

static int minor = MISC_DYNAMIC_MINOR;

struct vhci_data {
struct hci_dev *hdev;

Expand Down Expand Up @@ -218,12 +216,6 @@ static unsigned int vhci_poll(struct file *file, poll_table *wait)
return POLLOUT | POLLWRNORM;
}

static int vhci_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
return -EINVAL;
}

static int vhci_open(struct inode *inode, struct file *file)
{
struct vhci_data *data;
Expand Down Expand Up @@ -284,10 +276,10 @@ static int vhci_release(struct inode *inode, struct file *file)
}

static const struct file_operations vhci_fops = {
.owner = THIS_MODULE,
.read = vhci_read,
.write = vhci_write,
.poll = vhci_poll,
.ioctl = vhci_ioctl,
.open = vhci_open,
.release = vhci_release,
};
Expand All @@ -302,18 +294,12 @@ static int __init vhci_init(void)
{
BT_INFO("Virtual HCI driver ver %s", VERSION);

if (misc_register(&vhci_miscdev) < 0) {
BT_ERR("Can't register misc device with minor %d", minor);
return -EIO;
}

return 0;
return misc_register(&vhci_miscdev);
}

static void __exit vhci_exit(void)
{
if (misc_deregister(&vhci_miscdev) < 0)
BT_ERR("Can't unregister misc device with minor %d", minor);
misc_deregister(&vhci_miscdev);
}

module_init(vhci_init);
Expand Down
39 changes: 1 addition & 38 deletions include/net/bluetooth/hci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,22 +367,6 @@ static inline void hci_conn_put(struct hci_conn *conn)
}
}

/* ----- HCI tasks ----- */
static inline void hci_sched_cmd(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->cmd_task);
}

static inline void hci_sched_rx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->rx_task);
}

static inline void hci_sched_tx(struct hci_dev *hdev)
{
tasklet_schedule(&hdev->tx_task);
}

/* ----- HCI Devices ----- */
static inline void __hci_dev_put(struct hci_dev *d)
{
Expand Down Expand Up @@ -437,28 +421,7 @@ int hci_inquiry(void __user *arg);

void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);

/* Receive frame from HCI drivers */
static inline int hci_recv_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
&& !test_bit(HCI_INIT, &hdev->flags))) {
kfree_skb(skb);
return -ENXIO;
}

/* Incomming skb */
bt_cb(skb)->incoming = 1;

/* Time stamp */
__net_timestamp(skb);

/* Queue frame for rx task */
skb_queue_tail(&hdev->rx_q, skb);
hci_sched_rx(hdev);
return 0;
}

int hci_recv_frame(struct sk_buff *skb);
int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);

int hci_register_sysfs(struct hci_dev *hdev);
Expand Down
2 changes: 1 addition & 1 deletion include/net/bluetooth/l2cap.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ struct l2cap_pinfo {

__u8 next_tx_seq;
__u8 expected_ack_seq;
__u8 req_seq;
__u8 expected_tx_seq;
__u8 buffer_seq;
__u8 buffer_seq_srej;
Expand Down Expand Up @@ -375,6 +374,7 @@ struct l2cap_pinfo {
#define L2CAP_CONN_SEND_PBIT 0x10
#define L2CAP_CONN_REMOTE_BUSY 0x20
#define L2CAP_CONN_LOCAL_BUSY 0x40
#define L2CAP_CONN_REJ_ACT 0x80

#define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \
jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO));
Expand Down
5 changes: 4 additions & 1 deletion net/bluetooth/bnep/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len)

switch (cmd) {
case BNEP_CMD_NOT_UNDERSTOOD:
case BNEP_SETUP_CONN_REQ:
case BNEP_SETUP_CONN_RSP:
case BNEP_FILTER_NET_TYPE_RSP:
case BNEP_FILTER_MULTI_ADDR_RSP:
Expand All @@ -245,6 +244,10 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len)
err = bnep_ctrl_set_mcfilter(s, data, len);
break;

case BNEP_SETUP_CONN_REQ:
err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, BNEP_CONN_NOT_ALLOWED);
break;

default: {
u8 pkt[3];
pkt[0] = BNEP_CONTROL;
Expand Down
39 changes: 34 additions & 5 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
while ((skb = skb_dequeue(&hdev->driver_init))) {
bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
skb->dev = (void *) hdev;

skb_queue_tail(&hdev->cmd_q, skb);
hci_sched_cmd(hdev);
tasklet_schedule(&hdev->cmd_task);
}
skb_queue_purge(&hdev->driver_init);

Expand Down Expand Up @@ -987,6 +988,30 @@ int hci_resume_dev(struct hci_dev *hdev)
}
EXPORT_SYMBOL(hci_resume_dev);

/* Receive frame from HCI drivers */
int hci_recv_frame(struct sk_buff *skb)
{
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
if (!hdev || (!test_bit(HCI_UP, &hdev->flags)
&& !test_bit(HCI_INIT, &hdev->flags))) {
kfree_skb(skb);
return -ENXIO;
}

/* Incomming skb */
bt_cb(skb)->incoming = 1;

/* Time stamp */
__net_timestamp(skb);

/* Queue frame for rx task */
skb_queue_tail(&hdev->rx_q, skb);
tasklet_schedule(&hdev->rx_task);

return 0;
}
EXPORT_SYMBOL(hci_recv_frame);

/* Receive packet type fragment */
#define __reassembly(hdev, type) ((hdev)->reassembly[(type) - 2])

Expand Down Expand Up @@ -1193,8 +1218,9 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)

bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
skb->dev = (void *) hdev;

skb_queue_tail(&hdev->cmd_q, skb);
hci_sched_cmd(hdev);
tasklet_schedule(&hdev->cmd_task);

return 0;
}
Expand Down Expand Up @@ -1271,7 +1297,8 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
spin_unlock_bh(&conn->data_q.lock);
}

hci_sched_tx(hdev);
tasklet_schedule(&hdev->tx_task);

return 0;
}
EXPORT_SYMBOL(hci_send_acl);
Expand All @@ -1298,8 +1325,10 @@ int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)

skb->dev = (void *) hdev;
bt_cb(skb)->pkt_type = HCI_SCODATA_PKT;

skb_queue_tail(&conn->data_q, skb);
hci_sched_tx(hdev);
tasklet_schedule(&hdev->tx_task);

return 0;
}
EXPORT_SYMBOL(hci_send_sco);
Expand Down Expand Up @@ -1612,7 +1641,7 @@ static void hci_cmd_task(unsigned long arg)
hdev->cmd_last_tx = jiffies;
} else {
skb_queue_head(&hdev->cmd_q, skb);
hci_sched_cmd(hdev);
tasklet_schedule(&hdev->cmd_task);
}
}
}
6 changes: 3 additions & 3 deletions net/bluetooth/hci_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
if (ev->ncmd) {
atomic_set(&hdev->cmd_cnt, 1);
if (!skb_queue_empty(&hdev->cmd_q))
hci_sched_cmd(hdev);
tasklet_schedule(&hdev->cmd_task);
}
}

Expand Down Expand Up @@ -1386,7 +1386,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (ev->ncmd) {
atomic_set(&hdev->cmd_cnt, 1);
if (!skb_queue_empty(&hdev->cmd_q))
hci_sched_cmd(hdev);
tasklet_schedule(&hdev->cmd_task);
}
}

Expand Down Expand Up @@ -1454,7 +1454,7 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
}
}

hci_sched_tx(hdev);
tasklet_schedule(&hdev->tx_task);

tasklet_enable(&hdev->tx_task);
}
Expand Down
11 changes: 8 additions & 3 deletions net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
goto done;
}

if (!test_bit(HCI_UP, &hdev->flags)) {
err = -ENETDOWN;
goto done;
}

if (!(skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err)))
goto done;

Expand All @@ -440,10 +445,10 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,

if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) {
skb_queue_tail(&hdev->raw_q, skb);
hci_sched_tx(hdev);
tasklet_schedule(&hdev->tx_task);
} else {
skb_queue_tail(&hdev->cmd_q, skb);
hci_sched_cmd(hdev);
tasklet_schedule(&hdev->cmd_task);
}
} else {
if (!capable(CAP_NET_RAW)) {
Expand All @@ -452,7 +457,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
}

skb_queue_tail(&hdev->raw_q, skb);
hci_sched_tx(hdev);
tasklet_schedule(&hdev->tx_task);
}

err = len;
Expand Down
Loading

0 comments on commit a7fca0c

Please sign in to comment.