2005-04-16 15:20:36 -07:00
|
|
|
/* Bluetooth HCI driver model support. */
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
2006-07-03 01:02:37 -07:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <net/bluetooth/bluetooth.h>
|
|
|
|
#include <net/bluetooth/hci_core.h>
|
|
|
|
|
|
|
|
#ifndef CONFIG_BT_HCI_CORE_DEBUG
|
|
|
|
#undef BT_DBG
|
|
|
|
#define BT_DBG(D...)
|
|
|
|
#endif
|
|
|
|
|
2006-07-06 03:34:41 -07:00
|
|
|
static inline char *typetostr(int type)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-07-06 03:34:41 -07:00
|
|
|
switch (type) {
|
2006-07-08 04:57:15 -07:00
|
|
|
case HCI_VIRTUAL:
|
2006-07-06 03:34:41 -07:00
|
|
|
return "VIRTUAL";
|
|
|
|
case HCI_USB:
|
|
|
|
return "USB";
|
|
|
|
case HCI_PCCARD:
|
|
|
|
return "PCCARD";
|
|
|
|
case HCI_UART:
|
|
|
|
return "UART";
|
|
|
|
case HCI_RS232:
|
|
|
|
return "RS232";
|
|
|
|
case HCI_PCI:
|
|
|
|
return "PCI";
|
2006-07-08 04:57:15 -07:00
|
|
|
case HCI_SDIO:
|
|
|
|
return "SDIO";
|
2006-07-06 03:34:41 -07:00
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-06 03:34:41 -07:00
|
|
|
return sprintf(buf, "%s\n", typetostr(hdev->type));
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-10-20 04:33:56 -07:00
|
|
|
static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
|
|
|
char name[249];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 248; i++)
|
|
|
|
name[i] = hdev->dev_name[i];
|
|
|
|
|
|
|
|
name[248] = '\0';
|
|
|
|
return sprintf(buf, "%s\n", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t show_class(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
|
|
|
return sprintf(buf, "0x%.2x%.2x%.2x\n",
|
|
|
|
hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]);
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t show_address(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
bdaddr_t bdaddr;
|
|
|
|
baswap(&bdaddr, &hdev->bdaddr);
|
|
|
|
return sprintf(buf, "%s\n", batostr(&bdaddr));
|
|
|
|
}
|
|
|
|
|
2007-10-20 04:33:56 -07:00
|
|
|
static ssize_t show_features(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
|
|
|
|
hdev->features[0], hdev->features[1],
|
|
|
|
hdev->features[2], hdev->features[3],
|
|
|
|
hdev->features[4], hdev->features[5],
|
|
|
|
hdev->features[6], hdev->features[7]);
|
|
|
|
}
|
|
|
|
|
2006-09-23 00:57:20 -07:00
|
|
|
static ssize_t show_manufacturer(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
|
|
|
return sprintf(buf, "%d\n", hdev->manufacturer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t show_hci_version(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
|
|
|
return sprintf(buf, "%d\n", hdev->hci_ver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t show_hci_revision(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
|
|
|
return sprintf(buf, "%d\n", hdev->hci_rev);
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t show_inquiry_cache(struct device *dev, struct device_attribute *attr, char *buf)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
struct inquiry_cache *cache = &hdev->inq_cache;
|
|
|
|
struct inquiry_entry *e;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
hci_dev_lock_bh(hdev);
|
|
|
|
|
|
|
|
for (e = cache->list; e; e = e->next) {
|
|
|
|
struct inquiry_data *data = &e->data;
|
|
|
|
bdaddr_t bdaddr;
|
|
|
|
baswap(&bdaddr, &data->bdaddr);
|
|
|
|
n += sprintf(buf + n, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %u\n",
|
|
|
|
batostr(&bdaddr),
|
|
|
|
data->pscan_rep_mode, data->pscan_period_mode, data->pscan_mode,
|
|
|
|
data->dev_class[2], data->dev_class[1], data->dev_class[0],
|
|
|
|
__le16_to_cpu(data->clock_offset), data->rssi, e->timestamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
hci_dev_unlock_bh(hdev);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t show_idle_timeout(struct device *dev, struct device_attribute *attr, char *buf)
|
2006-07-03 01:02:33 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-03 01:02:33 -07:00
|
|
|
return sprintf(buf, "%d\n", hdev->idle_timeout);
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
2006-07-03 01:02:33 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-03 01:02:33 -07:00
|
|
|
char *ptr;
|
|
|
|
__u32 val;
|
|
|
|
|
|
|
|
val = simple_strtoul(buf, &ptr, 10);
|
|
|
|
if (ptr == buf)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (val != 0 && (val < 500 || val > 3600000))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
hdev->idle_timeout = val;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t show_sniff_max_interval(struct device *dev, struct device_attribute *attr, char *buf)
|
2006-07-03 01:02:33 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-03 01:02:33 -07:00
|
|
|
return sprintf(buf, "%d\n", hdev->sniff_max_interval);
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
2006-07-03 01:02:33 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-03 01:02:33 -07:00
|
|
|
char *ptr;
|
|
|
|
__u16 val;
|
|
|
|
|
|
|
|
val = simple_strtoul(buf, &ptr, 10);
|
|
|
|
if (ptr == buf)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (val < 0x0002 || val > 0xFFFE || val % 2)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (val < hdev->sniff_min_interval)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
hdev->sniff_max_interval = val;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t show_sniff_min_interval(struct device *dev, struct device_attribute *attr, char *buf)
|
2006-07-03 01:02:33 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-03 01:02:33 -07:00
|
|
|
return sprintf(buf, "%d\n", hdev->sniff_min_interval);
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
2006-07-03 01:02:33 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct hci_dev *hdev = dev_get_drvdata(dev);
|
2006-07-03 01:02:33 -07:00
|
|
|
char *ptr;
|
|
|
|
__u16 val;
|
|
|
|
|
|
|
|
val = simple_strtoul(buf, &ptr, 10);
|
|
|
|
if (ptr == buf)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (val < 0x0002 || val > 0xFFFE || val % 2)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (val > hdev->sniff_max_interval)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
hdev->sniff_min_interval = val;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
|
2007-10-20 04:33:56 -07:00
|
|
|
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
|
|
|
|
static DEVICE_ATTR(class, S_IRUGO, show_class, NULL);
|
2006-07-03 01:02:41 -07:00
|
|
|
static DEVICE_ATTR(address, S_IRUGO, show_address, NULL);
|
2007-10-20 04:33:56 -07:00
|
|
|
static DEVICE_ATTR(features, S_IRUGO, show_features, NULL);
|
2006-09-23 00:57:20 -07:00
|
|
|
static DEVICE_ATTR(manufacturer, S_IRUGO, show_manufacturer, NULL);
|
|
|
|
static DEVICE_ATTR(hci_version, S_IRUGO, show_hci_version, NULL);
|
|
|
|
static DEVICE_ATTR(hci_revision, S_IRUGO, show_hci_revision, NULL);
|
2006-07-03 01:02:41 -07:00
|
|
|
static DEVICE_ATTR(inquiry_cache, S_IRUGO, show_inquiry_cache, NULL);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static DEVICE_ATTR(idle_timeout, S_IRUGO | S_IWUSR,
|
2006-07-03 01:02:33 -07:00
|
|
|
show_idle_timeout, store_idle_timeout);
|
2006-07-03 01:02:41 -07:00
|
|
|
static DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR,
|
2006-07-03 01:02:33 -07:00
|
|
|
show_sniff_max_interval, store_sniff_max_interval);
|
2006-07-03 01:02:41 -07:00
|
|
|
static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR,
|
2006-07-03 01:02:33 -07:00
|
|
|
show_sniff_min_interval, store_sniff_min_interval);
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static struct device_attribute *bt_attrs[] = {
|
|
|
|
&dev_attr_type,
|
2007-10-20 04:33:56 -07:00
|
|
|
&dev_attr_name,
|
|
|
|
&dev_attr_class,
|
2006-07-03 01:02:41 -07:00
|
|
|
&dev_attr_address,
|
2007-10-20 04:33:56 -07:00
|
|
|
&dev_attr_features,
|
2006-09-23 00:57:20 -07:00
|
|
|
&dev_attr_manufacturer,
|
|
|
|
&dev_attr_hci_version,
|
|
|
|
&dev_attr_hci_revision,
|
2006-07-03 01:02:41 -07:00
|
|
|
&dev_attr_inquiry_cache,
|
|
|
|
&dev_attr_idle_timeout,
|
|
|
|
&dev_attr_sniff_max_interval,
|
|
|
|
&dev_attr_sniff_min_interval,
|
2005-04-16 15:20:36 -07:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2006-07-06 03:38:46 -07:00
|
|
|
static ssize_t show_conn_type(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_conn *conn = dev_get_drvdata(dev);
|
|
|
|
return sprintf(buf, "%s\n", conn->type == ACL_LINK ? "ACL" : "SCO");
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t show_conn_address(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct hci_conn *conn = dev_get_drvdata(dev);
|
|
|
|
bdaddr_t bdaddr;
|
|
|
|
baswap(&bdaddr, &conn->dst);
|
|
|
|
return sprintf(buf, "%s\n", batostr(&bdaddr));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CONN_ATTR(_name,_mode,_show,_store) \
|
|
|
|
struct device_attribute conn_attr_##_name = __ATTR(_name,_mode,_show,_store)
|
|
|
|
|
|
|
|
static CONN_ATTR(type, S_IRUGO, show_conn_type, NULL);
|
|
|
|
static CONN_ATTR(address, S_IRUGO, show_conn_address, NULL);
|
|
|
|
|
|
|
|
static struct device_attribute *conn_attrs[] = {
|
|
|
|
&conn_attr_type,
|
|
|
|
&conn_attr_address,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
struct class *bt_class = NULL;
|
2005-11-08 10:57:38 -07:00
|
|
|
EXPORT_SYMBOL_GPL(bt_class);
|
|
|
|
|
2006-07-03 01:02:37 -07:00
|
|
|
static struct bus_type bt_bus = {
|
|
|
|
.name = "bluetooth",
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device *bt_platform;
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
static void bt_release(struct device *dev)
|
|
|
|
{
|
2006-07-06 03:38:46 -07:00
|
|
|
void *data = dev_get_drvdata(dev);
|
|
|
|
kfree(data);
|
|
|
|
}
|
|
|
|
|
2006-11-22 07:57:56 -07:00
|
|
|
static void add_conn(struct work_struct *work)
|
2006-07-06 03:38:46 -07:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct hci_conn *conn = container_of(work, struct hci_conn, work);
|
2006-07-06 03:38:46 -07:00
|
|
|
int i;
|
|
|
|
|
2007-01-07 18:16:38 -07:00
|
|
|
if (device_add(&conn->dev) < 0) {
|
2006-10-15 08:30:45 -07:00
|
|
|
BT_ERR("Failed to register connection device");
|
|
|
|
return;
|
|
|
|
}
|
2006-07-06 03:38:46 -07:00
|
|
|
|
|
|
|
for (i = 0; conn_attrs[i]; i++)
|
2006-10-15 08:30:45 -07:00
|
|
|
if (device_create_file(&conn->dev, conn_attrs[i]) < 0)
|
|
|
|
BT_ERR("Failed to create connection attribute");
|
2006-07-06 03:38:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void hci_conn_add_sysfs(struct hci_conn *conn)
|
|
|
|
{
|
|
|
|
struct hci_dev *hdev = conn->hdev;
|
|
|
|
bdaddr_t *ba = &conn->dst;
|
|
|
|
|
|
|
|
BT_DBG("conn %p", conn);
|
|
|
|
|
2006-11-18 14:14:05 -07:00
|
|
|
conn->dev.bus = &bt_bus;
|
|
|
|
conn->dev.parent = &hdev->dev;
|
|
|
|
|
2006-07-06 03:38:46 -07:00
|
|
|
conn->dev.release = bt_release;
|
|
|
|
|
|
|
|
snprintf(conn->dev.bus_id, BUS_ID_SIZE,
|
|
|
|
"%s%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
|
|
|
|
conn->type == ACL_LINK ? "acl" : "sco",
|
|
|
|
ba->b[5], ba->b[4], ba->b[3],
|
|
|
|
ba->b[2], ba->b[1], ba->b[0]);
|
|
|
|
|
|
|
|
dev_set_drvdata(&conn->dev, conn);
|
|
|
|
|
2007-01-07 18:16:38 -07:00
|
|
|
device_initialize(&conn->dev);
|
|
|
|
|
2006-11-22 07:57:56 -07:00
|
|
|
INIT_WORK(&conn->work, add_conn);
|
2006-07-06 03:38:46 -07:00
|
|
|
|
|
|
|
schedule_work(&conn->work);
|
|
|
|
}
|
|
|
|
|
2006-11-22 07:57:56 -07:00
|
|
|
static void del_conn(struct work_struct *work)
|
2006-07-06 03:38:46 -07:00
|
|
|
{
|
2006-11-22 07:57:56 -07:00
|
|
|
struct hci_conn *conn = container_of(work, struct hci_conn, work);
|
2006-07-06 03:38:46 -07:00
|
|
|
device_del(&conn->dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hci_conn_del_sysfs(struct hci_conn *conn)
|
|
|
|
{
|
|
|
|
BT_DBG("conn %p", conn);
|
|
|
|
|
2007-01-07 18:16:38 -07:00
|
|
|
if (!device_is_registered(&conn->dev))
|
|
|
|
return;
|
|
|
|
|
2006-11-22 07:57:56 -07:00
|
|
|
INIT_WORK(&conn->work, del_conn);
|
2006-07-06 03:38:46 -07:00
|
|
|
|
|
|
|
schedule_work(&conn->work);
|
2006-07-03 01:02:41 -07:00
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
int hci_register_sysfs(struct hci_dev *hdev)
|
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
struct device *dev = &hdev->dev;
|
2005-04-16 15:20:36 -07:00
|
|
|
unsigned int i;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
|
|
|
|
|
2007-05-04 15:36:03 -07:00
|
|
|
dev->bus = &bt_bus;
|
2006-10-15 08:30:50 -07:00
|
|
|
dev->parent = hdev->parent;
|
2006-07-03 01:02:41 -07:00
|
|
|
|
|
|
|
strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
dev->release = bt_release;
|
2006-07-03 01:02:37 -07:00
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
dev_set_drvdata(dev, hdev);
|
2006-07-03 01:02:37 -07:00
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
err = device_register(dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
for (i = 0; bt_attrs[i]; i++)
|
2006-10-15 08:30:45 -07:00
|
|
|
if (device_create_file(dev, bt_attrs[i]) < 0)
|
|
|
|
BT_ERR("Failed to create device attribute");
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-05-07 17:32:08 -07:00
|
|
|
if (sysfs_create_link(&bt_class->subsys.kobj,
|
2007-05-04 15:36:03 -07:00
|
|
|
&dev->kobj, kobject_name(&dev->kobj)) < 0)
|
|
|
|
BT_ERR("Failed to create class symlink");
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hci_unregister_sysfs(struct hci_dev *hdev)
|
|
|
|
{
|
|
|
|
BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
|
|
|
|
|
2007-05-07 17:32:08 -07:00
|
|
|
sysfs_remove_link(&bt_class->subsys.kobj,
|
2007-05-04 15:36:03 -07:00
|
|
|
kobject_name(&hdev->dev.kobj));
|
|
|
|
|
2006-07-06 03:34:41 -07:00
|
|
|
device_del(&hdev->dev);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int __init bt_sysfs_init(void)
|
|
|
|
{
|
2006-07-03 01:02:37 -07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
bt_platform = platform_device_register_simple("bluetooth", -1, NULL, 0);
|
|
|
|
if (IS_ERR(bt_platform))
|
|
|
|
return PTR_ERR(bt_platform);
|
|
|
|
|
|
|
|
err = bus_register(&bt_bus);
|
|
|
|
if (err < 0) {
|
|
|
|
platform_device_unregister(bt_platform);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2006-07-03 01:02:41 -07:00
|
|
|
bt_class = class_create(THIS_MODULE, "bluetooth");
|
|
|
|
if (IS_ERR(bt_class)) {
|
2006-07-03 01:02:37 -07:00
|
|
|
bus_unregister(&bt_bus);
|
|
|
|
platform_device_unregister(bt_platform);
|
2006-07-03 01:02:41 -07:00
|
|
|
return PTR_ERR(bt_class);
|
2006-07-03 01:02:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2006-09-28 15:29:37 -07:00
|
|
|
void bt_sysfs_cleanup(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2006-07-03 01:02:41 -07:00
|
|
|
class_destroy(bt_class);
|
2006-07-03 01:02:37 -07:00
|
|
|
|
|
|
|
bus_unregister(&bt_bus);
|
|
|
|
|
|
|
|
platform_device_unregister(bt_platform);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|