From ba4d161345176c1cc551ca3fbaaab8ebc790d49c Mon Sep 17 00:00:00 2001 From: Maksim Krasnyanskiy Date: Sun, 13 Oct 2002 16:23:01 -0700 Subject: Consistent naming for Bluetooth function and constants. Some of them were named like BT_XXX and bt_xxx others BLUEZ_XXX and bluez_xxx. From now on use BT_XXX and bt_xxx throughout Bluetooth code, including CONFIG_ defines. Clean up small typos and misspelling along the way. --- include/net/bluetooth/bluetooth.h | 76 +++++++++++++++------------------------ include/net/bluetooth/hci.h | 2 +- 2 files changed, 29 insertions(+), 49 deletions(-) (limited to 'include/net/bluetooth') diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 3253f7e9e06a..a7202d48b57c 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -40,7 +40,7 @@ #endif /* Reserv for core and drivers use */ -#define BLUEZ_SKB_RESERVE 8 +#define BT_SKB_RESERVE 8 #ifndef MIN #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -57,29 +57,12 @@ #define SOL_SCO 17 #define SOL_RFCOMM 18 -/* Debugging */ -#ifdef CONFIG_BLUEZ_DEBUG - -#define HCI_CORE_DEBUG 1 -#define HCI_SOCK_DEBUG 1 -#define HCI_UART_DEBUG 1 -#define HCI_USB_DEBUG 1 -//#define HCI_DATA_DUMP 1 - -#define L2CAP_DEBUG 1 -#define SCO_DEBUG 1 -#define AF_BLUETOOTH_DEBUG 1 - -#endif /* CONFIG_BLUEZ_DEBUG */ - -extern void bluez_dump(char *pref, __u8 *buf, int count); - #define BT_INFO(fmt, arg...) printk(KERN_INFO fmt "\n" , ## arg) #define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg) #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg) #ifdef HCI_DATA_DUMP -#define BT_DMP(buf, len) bluez_dump(__FUNCTION__, buf, len) +#define BT_DMP(buf, len) bt_dump(__FUNCTION__, buf, len) #else #define BT_DMP(D...) #endif @@ -127,9 +110,9 @@ bdaddr_t *strtoba(char *str); /* Common socket structures and functions */ -#define bluez_sk(__sk) ((struct bluez_sock *) __sk) +#define bt_sk(__sk) ((struct bt_sock *) __sk) -struct bluez_sock { +struct bt_sock { struct sock sk; bdaddr_t src; bdaddr_t dst; @@ -137,48 +120,48 @@ struct bluez_sock { struct sock *parent; }; -struct bluez_sock_list { +struct bt_sock_list { struct sock *head; rwlock_t lock; }; -int bluez_sock_register(int proto, struct net_proto_family *ops); -int bluez_sock_unregister(int proto); -struct sock *bluez_sock_alloc(struct socket *sock, int proto, int pi_size, int prio); -void bluez_sock_link(struct bluez_sock_list *l, struct sock *s); -void bluez_sock_unlink(struct bluez_sock_list *l, struct sock *s); -int bluez_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len, int flags, struct scm_cookie *scm); -uint bluez_sock_poll(struct file * file, struct socket *sock, poll_table *wait); -int bluez_sock_w4_connect(struct sock *sk, int flags); +int bt_sock_register(int proto, struct net_proto_family *ops); +int bt_sock_unregister(int proto); +struct sock *bt_sock_alloc(struct socket *sock, int proto, int pi_size, int prio); +void bt_sock_link(struct bt_sock_list *l, struct sock *s); +void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); +int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, int len, int flags, struct scm_cookie *scm); +uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); +int bt_sock_w4_connect(struct sock *sk, int flags); -void bluez_accept_enqueue(struct sock *parent, struct sock *sk); -struct sock *bluez_accept_dequeue(struct sock *parent, struct socket *newsock); +void bt_accept_enqueue(struct sock *parent, struct sock *sk); +struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); /* Skb helpers */ -struct bluez_skb_cb { - int incomming; +struct bt_skb_cb { + int incoming; }; -#define bluez_cb(skb) ((struct bluez_skb_cb *)(skb->cb)) +#define bt_cb(skb) ((struct bt_skb_cb *)(skb->cb)) -static inline struct sk_buff *bluez_skb_alloc(unsigned int len, int how) +static inline struct sk_buff *bt_skb_alloc(unsigned int len, int how) { struct sk_buff *skb; - if ((skb = alloc_skb(len + BLUEZ_SKB_RESERVE, how))) { - skb_reserve(skb, BLUEZ_SKB_RESERVE); - bluez_cb(skb)->incomming = 0; + if ((skb = alloc_skb(len + BT_SKB_RESERVE, how))) { + skb_reserve(skb, BT_SKB_RESERVE); + bt_cb(skb)->incoming = 0; } return skb; } -static inline struct sk_buff *bluez_skb_send_alloc(struct sock *sk, unsigned long len, +static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, unsigned long len, int nb, int *err) { struct sk_buff *skb; - if ((skb = sock_alloc_send_skb(sk, len + BLUEZ_SKB_RESERVE, nb, err))) { - skb_reserve(skb, BLUEZ_SKB_RESERVE); - bluez_cb(skb)->incomming = 0; + if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) { + skb_reserve(skb, BT_SKB_RESERVE); + bt_cb(skb)->incoming = 0; } return skb; @@ -193,11 +176,8 @@ static inline int skb_frags_no(struct sk_buff *skb) return n; } -int hci_core_init(void); -int hci_core_cleanup(void); -int hci_sock_init(void); -int hci_sock_cleanup(void); +void bt_dump(char *pref, __u8 *buf, int count); -int bterr(__u16 code); +int bt_err(__u16 code); #endif /* __BLUETOOTH_H */ diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index b58ebef5397b..d67d9721e091 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -582,7 +582,7 @@ typedef struct { } __attribute__ ((packed)) evt_read_remote_version_complete; #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8 -/* Internal events generated by BlueZ stack */ +/* Internal events generated by Bluetooth stack */ #define EVT_STACK_INTERNAL 0xfd typedef struct { __u16 type; -- cgit v1.2.3 From 63d902f71914cbbbedc5745bc48a1c23b4e5e2ba Mon Sep 17 00:00:00 2001 From: Maksim Krasnyanskiy Date: Sun, 13 Oct 2002 18:17:53 -0700 Subject: Get rid of the MIN() thing in Bluetooth code and use min_t() instead. --- drivers/bluetooth/hci_h4.c | 2 +- drivers/bluetooth/hci_usb.c | 2 +- drivers/bluetooth/hci_vhci.c | 2 +- include/net/bluetooth/bluetooth.h | 4 ---- net/bluetooth/hci_sock.c | 4 ++-- net/bluetooth/l2cap.c | 14 +++++++------- net/bluetooth/sco.c | 6 +++--- 7 files changed, 15 insertions(+), 19 deletions(-) (limited to 'include/net/bluetooth') diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index b1ba694cf524..521eb19442be 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c @@ -160,7 +160,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ptr = data; while (count) { if (h4->rx_count) { - len = MIN(h4->rx_count, count); + len = min_t(unsigned int, h4->rx_count, count); memcpy(skb_put(h4->rx_skb, len), ptr, len); h4->rx_count -= len; count -= len; ptr += len; diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 65248e1df44f..027b4463f3c9 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c @@ -639,7 +639,7 @@ int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) /* Find endpoints that we need */ - ifn = MIN(udev->actconfig->bNumInterfaces, HCI_MAX_IFACE_NUM); + ifn = min_t(unsigned int, udev->actconfig->bNumInterfaces, HCI_MAX_IFACE_NUM); for (i = 0; i < ifn; i++) { iface = &udev->actconfig->interface[i]; for (a = 0; a < iface->num_altsetting; a++) { diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index aab1aca475d7..a70eef0fd4d9 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c @@ -172,7 +172,7 @@ static inline ssize_t hci_vhci_put_user(struct hci_vhci_struct *hci_vhci, int len = count, total = 0; char *ptr = buf; - len = MIN(skb->len, len); + len = min_t(unsigned int, skb->len, len); if (copy_to_user(ptr, skb->data, len)) return -EFAULT; total += len; diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index a7202d48b57c..d8e54c8f4daf 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -42,10 +42,6 @@ /* Reserv for core and drivers use */ #define BT_SKB_RESERVE 8 -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - #define BTPROTO_L2CAP 0 #define BTPROTO_HCI 1 #define BTPROTO_SCO 2 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index e9379c7f2014..0398bb045b4c 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -454,7 +454,7 @@ int hci_sock_setsockopt(struct socket *sock, int level, int optname, char *optva break; case HCI_FILTER: - len = MIN(len, sizeof(uf)); + len = min_t(unsigned int, len, sizeof(uf)); if (copy_from_user(&uf, optval, len)) { err = -EFAULT; break; @@ -525,7 +525,7 @@ int hci_sock_getsockopt(struct socket *sock, int level, int optname, char *optva uf.event_mask[1] = *((u32 *) f->event_mask + 1); } - len = MIN(len, sizeof(uf)); + len = min_t(unsigned int, len, sizeof(uf)); if (copy_to_user(optval, &uf, len)) return -EFAULT; break; diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index cb47e43234e9..28f06d39daab 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c @@ -682,7 +682,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch switch (optname) { case L2CAP_OPTIONS: - len = MIN(sizeof(opts), optlen); + len = min_t(unsigned int, sizeof(opts), optlen); if (copy_from_user((char *)&opts, optval, len)) { err = -EFAULT; break; @@ -727,7 +727,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch opts.omtu = l2cap_pi(sk)->omtu; opts.flush_to = l2cap_pi(sk)->flush_to; - len = MIN(len, sizeof(opts)); + len = min_t(unsigned int, len, sizeof(opts)); if (copy_to_user(optval, (char *)&opts, len)) err = -EFAULT; @@ -746,7 +746,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch cinfo.hci_handle = l2cap_pi(sk)->conn->hcon->handle; - len = MIN(len, sizeof(cinfo)); + len = min_t(unsigned int, len, sizeof(cinfo)); if (copy_to_user(optval, (char *)&cinfo, len)) err = -EFAULT; @@ -1017,7 +1017,7 @@ static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len) else hlen = L2CAP_HDR_SIZE; - count = MIN(conn->mtu - hlen, len); + count = min_t(unsigned int, (conn->mtu - hlen), len); skb = bt_skb_send_alloc(sk, hlen + count, msg->msg_flags & MSG_DONTWAIT, &err); @@ -1043,7 +1043,7 @@ static int l2cap_chan_send(struct sock *sk, struct msghdr *msg, int len) /* Continuation fragments (no L2CAP header) */ frag = &skb_shinfo(skb)->frag_list; while (len) { - count = MIN(conn->mtu, len); + count = min_t(unsigned int, conn->mtu, len); *frag = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err); if (!*frag) @@ -1103,7 +1103,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d", conn, code, ident, dlen); len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; - count = MIN(conn->mtu, len); + count = min_t(unsigned int, conn->mtu, len); skb = bt_skb_alloc(count, GFP_ATOMIC); if (!skb) @@ -1129,7 +1129,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, /* Continuation fragments (no L2CAP header) */ frag = &skb_shinfo(skb)->frag_list; while (len) { - count = MIN(conn->mtu, len); + count = min_t(unsigned int, conn->mtu, len); *frag = bt_skb_alloc(count, GFP_ATOMIC); if (!*frag) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index e9b04be730ca..defa54f0afc3 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -258,7 +258,7 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len) BT_DBG("sk %p len %d", sk, len); - count = MIN(conn->mtu, len); + count = min_t(unsigned int, conn->mtu, len); if (!(skb = bt_skb_send_alloc(sk, count, msg->msg_flags & MSG_DONTWAIT, &err))) return err; @@ -699,7 +699,7 @@ int sco_sock_getsockopt(struct socket *sock, int level, int optname, char *optva BT_INFO("mtu %d", opts.mtu); - len = MIN(len, sizeof(opts)); + len = min_t(unsigned int, len, sizeof(opts)); if (copy_to_user(optval, (char *)&opts, len)) err = -EFAULT; @@ -713,7 +713,7 @@ int sco_sock_getsockopt(struct socket *sock, int level, int optname, char *optva cinfo.hci_handle = sco_pi(sk)->conn->hcon->handle; - len = MIN(len, sizeof(cinfo)); + len = min_t(unsigned int, len, sizeof(cinfo)); if (copy_to_user(optval, (char *)&cinfo, len)) err = -EFAULT; -- cgit v1.2.3 From 4c9eb495b27f5939dc0a9ed4ed30200e91d960e5 Mon Sep 17 00:00:00 2001 From: Maksim Krasnyanskiy Date: Sun, 13 Oct 2002 18:36:42 -0700 Subject: Support for suspend/resume interface for the HCI devices. --- include/net/bluetooth/hci.h | 2 ++ include/net/bluetooth/hci_core.h | 2 ++ net/bluetooth/hci_core.c | 16 ++++++++++++++++ net/bluetooth/syms.c | 3 +++ 4 files changed, 23 insertions(+) (limited to 'include/net/bluetooth') diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index d67d9721e091..a8832055d170 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -39,6 +39,8 @@ #define HCI_DEV_UNREG 2 #define HCI_DEV_UP 3 #define HCI_DEV_DOWN 4 +#define HCI_DEV_SUSPEND 5 +#define HCI_DEV_RESUME 6 /* HCI device types */ #define HCI_VHCI 0 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 1740cde1287d..adf5558f660a 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -302,6 +302,8 @@ struct hci_dev *hci_dev_get(int index); struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); int hci_register_dev(struct hci_dev *hdev); int hci_unregister_dev(struct hci_dev *hdev); +int hci_suspend_dev(struct hci_dev *hdev); +int hci_resume_dev(struct hci_dev *hdev); int hci_dev_open(__u16 dev); int hci_dev_close(__u16 dev); int hci_dev_reset(__u16 dev); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f013113f34ec..1ad3339ed38d 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -863,6 +863,22 @@ int hci_unregister_dev(struct hci_dev *hdev) return 0; } +/* Suspend HCI device */ +int hci_suspend_dev(struct hci_dev *hdev) +{ + hci_notify(hdev, HCI_DEV_SUSPEND); + hci_run_hotplug(hdev->name, "suspend"); + return 0; +} + +/* Resume HCI device */ +int hci_resume_dev(struct hci_dev *hdev) +{ + hci_notify(hdev, HCI_DEV_RESUME); + hci_run_hotplug(hdev->name, "resume"); + return 0; +} + /* Receive frame from HCI drivers */ int hci_recv_frame(struct sk_buff *skb) { diff --git a/net/bluetooth/syms.c b/net/bluetooth/syms.c index a1d3c0e6d384..779d82130924 100644 --- a/net/bluetooth/syms.c +++ b/net/bluetooth/syms.c @@ -44,6 +44,9 @@ /* HCI Core */ EXPORT_SYMBOL(hci_register_dev); EXPORT_SYMBOL(hci_unregister_dev); +EXPORT_SYMBOL(hci_suspend_dev); +EXPORT_SYMBOL(hci_resume_dev); + EXPORT_SYMBOL(hci_register_proto); EXPORT_SYMBOL(hci_unregister_proto); -- cgit v1.2.3