51
51
conn->features[6], conn->features[7]);
54
#define LINK_ATTR(_name,_mode,_show,_store) \
55
struct device_attribute link_attr_##_name = __ATTR(_name,_mode,_show,_store)
54
#define LINK_ATTR(_name, _mode, _show, _store) \
55
struct device_attribute link_attr_##_name = __ATTR(_name, _mode, _show, _store)
57
57
static LINK_ATTR(type, S_IRUGO, show_link_type, NULL);
58
58
static LINK_ATTR(address, S_IRUGO, show_link_address, NULL);
216
216
static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
218
218
struct hci_dev *hdev = dev_get_drvdata(dev);
219
char name[HCI_MAX_NAME_LENGTH + 1];
222
for (i = 0; i < 248; i++)
222
for (i = 0; i < HCI_MAX_NAME_LENGTH; i++)
223
223
name[i] = hdev->dev_name[i];
225
name[HCI_MAX_NAME_LENGTH] = '\0';
226
226
return sprintf(buf, "%s\n", name);
277
277
static ssize_t store_idle_timeout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
279
279
struct hci_dev *hdev = dev_get_drvdata(dev);
282
if (strict_strtoul(buf, 0, &val) < 0)
283
rv = kstrtouint(buf, 0, &val);
285
287
if (val != 0 && (val < 500 || val > 3600000))
299
301
static ssize_t store_sniff_max_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
301
303
struct hci_dev *hdev = dev_get_drvdata(dev);
304
if (strict_strtoul(buf, 0, &val) < 0)
307
if (val < 0x0002 || val > 0xFFFE || val % 2)
310
if (val < hdev->sniff_min_interval)
307
rv = kstrtou16(buf, 0, &val);
311
if (val == 0 || val % 2 || val < hdev->sniff_min_interval)
313
314
hdev->sniff_max_interval = val;
324
325
static ssize_t store_sniff_min_interval(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
326
327
struct hci_dev *hdev = dev_get_drvdata(dev);
329
if (strict_strtoul(buf, 0, &val) < 0)
332
if (val < 0x0002 || val > 0xFFFE || val % 2)
335
if (val > hdev->sniff_max_interval)
331
rv = kstrtou16(buf, 0, &val);
335
if (val == 0 || val % 2 || val > hdev->sniff_max_interval)
338
338
hdev->sniff_min_interval = val;
461
461
.llseek = seq_lseek,
462
462
.release = single_release,
465
static void print_bt_uuid(struct seq_file *f, u8 *uuid)
468
u16 data1, data2, data3, data5;
470
memcpy(&data0, &uuid[0], 4);
471
memcpy(&data1, &uuid[4], 2);
472
memcpy(&data2, &uuid[6], 2);
473
memcpy(&data3, &uuid[8], 2);
474
memcpy(&data4, &uuid[10], 4);
475
memcpy(&data5, &uuid[14], 2);
477
seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x\n",
478
ntohl(data0), ntohs(data1), ntohs(data2),
479
ntohs(data3), ntohl(data4), ntohs(data5));
482
static int uuids_show(struct seq_file *f, void *p)
484
struct hci_dev *hdev = f->private;
487
hci_dev_lock_bh(hdev);
489
list_for_each(l, &hdev->uuids) {
490
struct bt_uuid *uuid;
492
uuid = list_entry(l, struct bt_uuid, list);
494
print_bt_uuid(f, uuid->uuid);
497
hci_dev_unlock_bh(hdev);
502
static int uuids_open(struct inode *inode, struct file *file)
504
return single_open(file, uuids_show, inode->i_private);
507
static const struct file_operations uuids_fops = {
511
.release = single_release,
514
static int auto_accept_delay_set(void *data, u64 val)
516
struct hci_dev *hdev = data;
518
hci_dev_lock_bh(hdev);
520
hdev->auto_accept_delay = val;
522
hci_dev_unlock_bh(hdev);
527
static int auto_accept_delay_get(void *data, u64 *val)
529
struct hci_dev *hdev = data;
531
hci_dev_lock_bh(hdev);
533
*val = hdev->auto_accept_delay;
535
hci_dev_unlock_bh(hdev);
540
DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get,
541
auto_accept_delay_set, "%llu\n");
464
543
int hci_register_sysfs(struct hci_dev *hdev)
466
545
struct device *dev = &hdev->dev;
493
572
debugfs_create_file("blacklist", 0444, hdev->debugfs,
494
573
hdev, &blacklist_fops);
575
debugfs_create_file("uuids", 0444, hdev->debugfs, hdev, &uuids_fops);
577
debugfs_create_file("auto_accept_delay", 0444, hdev->debugfs, hdev,
578
&auto_accept_delay_fops);