From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 2/3] Bluetooth: debugfs: Add force_suspend entry
Date: Mon, 27 Sep 2021 13:06:10 -0700 [thread overview]
Message-ID: <20210927200611.2722757-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20210927200611.2722757-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds force_suspend which can be used to force the controller into
suspend/resume state.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
net/bluetooth/hci_debugfs.c | 48 +++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
index 902b40a90b91..53b39cc73cd7 100644
--- a/net/bluetooth/hci_debugfs.c
+++ b/net/bluetooth/hci_debugfs.c
@@ -305,6 +305,51 @@ static const struct file_operations sc_only_mode_fops = {
.llseek = default_llseek,
};
+static ssize_t force_suspend_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct hci_dev *hdev = file->private_data;
+ char buf[3];
+
+ buf[0] = hdev->suspended ? 'Y' : 'N';
+ buf[1] = '\n';
+ buf[2] = '\0';
+ return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+}
+
+static ssize_t force_suspend_write(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct hci_dev *hdev = file->private_data;
+ bool enable;
+ int err;
+
+ err = kstrtobool_from_user(user_buf, count, &enable);
+ if (err)
+ return err;
+
+ if (hdev->suspended == enable)
+ return -EALREADY;
+
+ if (enable)
+ err = hci_suspend_dev(hdev);
+ else
+ err = hci_resume_dev(hdev);
+
+ if (err)
+ return err;
+
+ return count;
+}
+
+static const struct file_operations force_suspend_fops = {
+ .open = simple_open,
+ .read = force_suspend_read,
+ .write = force_suspend_write,
+ .llseek = default_llseek,
+};
+
DEFINE_INFO_ATTRIBUTE(hardware_info, hw_info);
DEFINE_INFO_ATTRIBUTE(firmware_info, fw_info);
@@ -336,6 +381,9 @@ void hci_debugfs_create_common(struct hci_dev *hdev)
debugfs_create_file("conn_info_max_age", 0644, hdev->debugfs, hdev,
&conn_info_max_age_fops);
+ debugfs_create_file("force_suspend", 0644, hdev->debugfs, hdev,
+ &force_suspend_fops);
+
if (lmp_ssp_capable(hdev) || lmp_le_capable(hdev))
debugfs_create_file("use_debug_keys", 0444, hdev->debugfs,
hdev, &use_debug_keys_fops);
--
2.31.1
next prev parent reply other threads:[~2021-09-27 20:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-27 20:06 [PATCH 1/3] Bluetooth: Make use of hci_{suspend,resume}_dev on suspend notifier Luiz Augusto von Dentz
2021-09-27 20:06 ` Luiz Augusto von Dentz [this message]
2021-09-27 20:06 ` [PATCH 3/3] Bluetooth: debugfs: Add force_prevent_wake entry Luiz Augusto von Dentz
2021-09-27 23:09 ` [1/3] Bluetooth: Make use of hci_{suspend,resume}_dev on suspend notifier bluez.test.bot
2021-09-28 8:06 ` [PATCH 1/3] " Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210927200611.2722757-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.