From: Dylan MacKenzie <ecstaticmorse@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Dylan MacKenzie <ecstaticmorse@gmail.com>
Subject: [PATCH BlueZ 1/2] device: Add btd_device_get_disconnect_reason
Date: Sat, 21 Nov 2026 12:58:34 -0800 [thread overview]
Message-ID: <20261121205835.381239-2-ecstaticmorse@gmail.com> (raw)
In-Reply-To: <20261121205835.381239-1-ecstaticmorse@gmail.com>
Keep the reason of the last disconnection in the bearer state and add
btd_device_get_disconnect_reason so it can be queried per bearer. The
new field takes the place of padding so struct bearer_state does not
grow.
Assisted-by: Claude:claude-fable-5-2
---
src/device.c | 7 +++++++
src/device.h | 1 +
2 files changed, 8 insertions(+)
diff --git a/src/device.c b/src/device.c
index 36a980d1e..720b4af69 100644
--- a/src/device.c
+++ b/src/device.c
@@ -155,6 +155,7 @@ struct bearer_state {
bool svc_resolved;
bool initiator;
bool connectable;
+ uint8_t disconn_reason;
time_t last_seen;
time_t last_used;
};
@@ -3864,6 +3865,11 @@ bool btd_device_bdaddr_type_connected(struct btd_device *dev, uint8_t type)
return dev->le_state.connected;
}
+uint8_t btd_device_get_disconnect_reason(struct btd_device *dev, uint8_t type)
+{
+ return get_state(dev, type)->disconn_reason;
+}
+
bool btd_device_bdaddr_type_connectable(struct btd_device *dev, uint8_t type)
{
if (type == BDADDR_BREDR)
@@ -4071,6 +4077,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type,
state->connected = false;
state->initiator = false;
+ state->disconn_reason = reason;
device->general_connect = FALSE;
device_set_svc_refreshed(device, false);
diff --git a/src/device.h b/src/device.h
index 047a894c3..4527c16d1 100644
--- a/src/device.h
+++ b/src/device.h
@@ -127,6 +127,7 @@ void device_set_flags(struct btd_device *device, uint8_t flags);
bool btd_device_is_connected(struct btd_device *dev);
bool btd_device_bearer_is_connected(struct btd_device *dev);
bool btd_device_bdaddr_type_connected(struct btd_device *dev, uint8_t type);
+uint8_t btd_device_get_disconnect_reason(struct btd_device *dev, uint8_t type);
bool btd_device_bdaddr_type_connectable(struct btd_device *dev, uint8_t type);
bool btd_device_bdaddr_type_seen(struct btd_device *dev, uint8_t type);
bool btd_device_bdaddr_type_initiator(struct btd_device *dev, uint8_t type);
--
2.56.0
next prev parent reply other threads:[~2026-11-21 20:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 20:58 [PATCH BlueZ 0/2] input: Do not re-page HID devices that disconnected on purpose Dylan MacKenzie
2026-11-21 20:58 ` Dylan MacKenzie [this message]
2026-11-21 23:18 ` bluez.test.bot
2026-11-21 20:58 ` [PATCH BlueZ 2/2] input/device: Only auto-reconnect on link loss Dylan MacKenzie
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=20261121205835.381239-2-ecstaticmorse@gmail.com \
--to=ecstaticmorse@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox