Skip to content

Commit 5c91249

Browse files
committed
Bluetooth: Introduce hci_dev_do_reset helper function
Split the hci_dev_reset ioctl handling into using hci_dev_do_reset helper function. Similar to what has been done with hci_dev_do_open and hci_dev_do_close. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
1 parent 8f502f8 commit 5c91249

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

net/bluetooth/hci_core.c

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,32 +1719,14 @@ int hci_dev_close(__u16 dev)
17191719
return err;
17201720
}
17211721

1722-
int hci_dev_reset(__u16 dev)
1722+
static int hci_dev_do_reset(struct hci_dev *hdev)
17231723
{
1724-
struct hci_dev *hdev;
1725-
int ret = 0;
1724+
int ret;
17261725

1727-
hdev = hci_dev_get(dev);
1728-
if (!hdev)
1729-
return -ENODEV;
1726+
BT_DBG("%s %p", hdev->name, hdev);
17301727

17311728
hci_req_lock(hdev);
17321729

1733-
if (!test_bit(HCI_UP, &hdev->flags)) {
1734-
ret = -ENETDOWN;
1735-
goto done;
1736-
}
1737-
1738-
if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1739-
ret = -EBUSY;
1740-
goto done;
1741-
}
1742-
1743-
if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) {
1744-
ret = -EOPNOTSUPP;
1745-
goto done;
1746-
}
1747-
17481730
/* Drop queues */
17491731
skb_queue_purge(&hdev->rx_q);
17501732
skb_queue_purge(&hdev->cmd_q);
@@ -1767,12 +1749,41 @@ int hci_dev_reset(__u16 dev)
17671749

17681750
ret = __hci_req_sync(hdev, hci_reset_req, 0, HCI_INIT_TIMEOUT);
17691751

1770-
done:
17711752
hci_req_unlock(hdev);
1772-
hci_dev_put(hdev);
17731753
return ret;
17741754
}
17751755

1756+
int hci_dev_reset(__u16 dev)
1757+
{
1758+
struct hci_dev *hdev;
1759+
int err;
1760+
1761+
hdev = hci_dev_get(dev);
1762+
if (!hdev)
1763+
return -ENODEV;
1764+
1765+
if (!test_bit(HCI_UP, &hdev->flags)) {
1766+
err = -ENETDOWN;
1767+
goto done;
1768+
}
1769+
1770+
if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) {
1771+
err = -EBUSY;
1772+
goto done;
1773+
}
1774+
1775+
if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) {
1776+
err = -EOPNOTSUPP;
1777+
goto done;
1778+
}
1779+
1780+
err = hci_dev_do_reset(hdev);
1781+
1782+
done:
1783+
hci_dev_put(hdev);
1784+
return err;
1785+
}
1786+
17761787
int hci_dev_reset_stat(__u16 dev)
17771788
{
17781789
struct hci_dev *hdev;

0 commit comments

Comments
 (0)