diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-05-29 15:33:48 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2018-05-30 08:16:04 +0200 |
commit | 3bf5e97d7bbd175248da02efca2b265d13fb6041 (patch) | |
tree | c52acb227090112c167fc5ceff3c5a3fb1d32d7d /net/bluetooth/hci_debugfs.c | |
parent | Bluetooth: hci_qca: Fix "Sleep inside atomic section" warning (diff) | |
download | linux-3bf5e97d7bbd175248da02efca2b265d13fb6041.tar.xz linux-3bf5e97d7bbd175248da02efca2b265d13fb6041.zip |
Bluetooth: Re-use kstrtobool_from_user()
Re-use kstrtobool_from_user() instead of open coded variant.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_debugfs.c')
-rw-r--r-- | net/bluetooth/hci_debugfs.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c index 418b76e557b0..0d8ab5b3c177 100644 --- a/net/bluetooth/hci_debugfs.c +++ b/net/bluetooth/hci_debugfs.c @@ -47,19 +47,15 @@ static ssize_t __name ## _write(struct file *file, \ size_t count, loff_t *ppos) \ { \ struct hci_dev *hdev = file->private_data; \ - char buf[32]; \ - size_t buf_size = min(count, (sizeof(buf) - 1)); \ bool enable; \ + int err; \ \ if (test_bit(HCI_UP, &hdev->flags)) \ return -EBUSY; \ \ - if (copy_from_user(buf, user_buf, buf_size)) \ - return -EFAULT; \ - \ - buf[buf_size] = '\0'; \ - if (strtobool(buf, &enable)) \ - return -EINVAL; \ + err = kstrtobool_from_user(user_buf, count, &enable); \ + if (err) \ + return err; \ \ if (enable == test_bit(__quirk, &hdev->quirks)) \ return -EALREADY; \ @@ -658,19 +654,15 @@ static ssize_t force_static_address_write(struct file *file, size_t count, loff_t *ppos) { struct hci_dev *hdev = file->private_data; - char buf[32]; - size_t buf_size = min(count, (sizeof(buf)-1)); bool enable; + int err; if (test_bit(HCI_UP, &hdev->flags)) return -EBUSY; - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - buf[buf_size] = '\0'; - if (strtobool(buf, &enable)) - return -EINVAL; + err = kstrtobool_from_user(user_buf, count, &enable); + if (err) + return err; if (enable == hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR)) return -EALREADY; |