Bluetooth: Add controller types for BR/EDR and 802.11 AMP
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 13 Feb 2010 01:28:41 +0000 (02:28 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 27 Feb 2010 13:05:38 +0000 (14:05 +0100)
With the Bluetooth 3.0 specification and the introduction of alternate
MAC/PHY (AMP) support, it is required to differentiate between primary
BR/EDR controllers and 802.11 AMP controllers. So introduce a special
type inside HCI device for differentiation.

For now all AMP controllers will be treated as raw devices until an
AMP manager has been implemented.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci.h
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c
net/bluetooth/hci_sysfs.c

index 3350a665180fc24e4bb9776e0143aef8435c0220..fc0c502d9fd186f95585220bb14217aa50252330 100644 (file)
 #define HCI_PCI                5
 #define HCI_SDIO       6
 
+/* HCI controller types */
+#define HCI_BREDR      0x00
+#define HCI_80211      0x01
+
 /* HCI device quirks */
 enum {
        HCI_QUIRK_NO_RESET,
index 4c94c1e233a2ad874a79ad6819ea72f1777db7f8..ce3c99e5fa25d984a9be0ef2b30adb5b9262c008 100644 (file)
@@ -71,6 +71,7 @@ struct hci_dev {
        unsigned long   flags;
        __u16           id;
        __u8            bus;
+       __u8            dev_type;
        bdaddr_t        bdaddr;
        __u8            dev_name[248];
        __u8            dev_class[3];
index 4b62ed01ddc619763bee5c0432b6dd8dd2a50579..4ad23192c7a52dfd5ce76734c12d6541b8295c5d 100644 (file)
@@ -491,6 +491,10 @@ int hci_dev_open(__u16 dev)
        if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
                set_bit(HCI_RAW, &hdev->flags);
 
+       /* Treat all non BR/EDR controllers as raw devices for now */
+       if (hdev->dev_type != HCI_BREDR)
+               set_bit(HCI_RAW, &hdev->flags);
+
        if (hdev->open(hdev)) {
                ret = -EIO;
                goto done;
@@ -797,7 +801,7 @@ int hci_get_dev_info(void __user *arg)
 
        strcpy(di.name, hdev->name);
        di.bdaddr   = hdev->bdaddr;
-       di.type     = hdev->bus;
+       di.type     = (hdev->bus & 0x0f) | (hdev->dev_type << 4);
        di.flags    = hdev->flags;
        di.pkt_type = hdev->pkt_type;
        di.acl_mtu  = hdev->acl_mtu;
index f9d93f9cbcd2d261e9c300e39df971a72dc5995e..1a79a6c7e30ef82fc0d84aea20a677d506e85200 100644 (file)
@@ -192,12 +192,30 @@ static inline char *host_bustostr(int bus)
        }
 }
 
+static inline char *host_typetostr(int type)
+{
+       switch (type) {
+       case HCI_BREDR:
+               return "BR/EDR";
+       case HCI_80211:
+               return "802.11";
+       default:
+               return "UNKNOWN";
+       }
+}
+
 static ssize_t show_bus(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct hci_dev *hdev = dev_get_drvdata(dev);
        return sprintf(buf, "%s\n", host_bustostr(hdev->bus));
 }
 
+static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct hci_dev *hdev = dev_get_drvdata(dev);
+       return sprintf(buf, "%s\n", host_typetostr(hdev->dev_type));
+}
+
 static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct hci_dev *hdev = dev_get_drvdata(dev);
@@ -334,6 +352,7 @@ static ssize_t store_sniff_min_interval(struct device *dev, struct device_attrib
 }
 
 static DEVICE_ATTR(bus, S_IRUGO, show_bus, NULL);
+static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
 static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
 static DEVICE_ATTR(class, S_IRUGO, show_class, NULL);
 static DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
@@ -351,6 +370,7 @@ static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR,
 
 static struct attribute *bt_host_attrs[] = {
        &dev_attr_bus.attr,
+       &dev_attr_type.attr,
        &dev_attr_name.attr,
        &dev_attr_class.attr,
        &dev_attr_address.attr,