Skip to content

Commit

Permalink
Bluetooth: Allow reset via sysfs
Browse files Browse the repository at this point in the history
Allow sysfs to trigger hdev reset. This is required to recover devices
that are not responsive from userspace.

Signed-off-by: Hsin-chen Chuang <chharry@chromium.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Hsin-chen Chuang authored and Luiz Augusto von Dentz committed Jan 15, 2025
1 parent f07d478 commit 0f8a001
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions net/bluetooth/hci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,28 @@ static void bt_host_release(struct device *dev)
module_put(THIS_MODULE);
}

static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct hci_dev *hdev = to_hci_dev(dev);

if (hdev->reset)
hdev->reset(hdev);

return count;
}
static DEVICE_ATTR_WO(reset);

static struct attribute *bt_host_attrs[] = {
&dev_attr_reset.attr,
NULL,
};
ATTRIBUTE_GROUPS(bt_host);

static const struct device_type bt_host = {
.name = "host",
.release = bt_host_release,
.groups = bt_host_groups,
};

void hci_init_sysfs(struct hci_dev *hdev)
Expand Down

0 comments on commit 0f8a001

Please sign in to comment.