From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] adapter: Check flags are supported
Date: Mon, 15 Aug 2022 16:20:06 -0700 [thread overview]
Message-ID: <20220815232006.1252933-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes sure the flags are supported before attempting to set it.
---
src/adapter.c | 4 +++-
src/device.c | 5 +++++
src/device.h | 1 +
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 3fa3018093b3..d33fc9bd661c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5428,10 +5428,12 @@ void adapter_set_device_flags(struct btd_adapter *adapter,
mgmt_request_func_t func, void *user_data)
{
struct mgmt_cp_set_device_flags cp;
+ uint32_t supported = btd_device_get_supported_flags(device);
const bdaddr_t *bdaddr;
uint8_t bdaddr_type;
- if (!btd_has_kernel_features(KERNEL_CONN_CONTROL))
+ if (!btd_has_kernel_features(KERNEL_CONN_CONTROL) ||
+ (supported | flags) != supported)
return;
bdaddr = device_get_address(device);
diff --git a/src/device.c b/src/device.c
index bc99420228d2..698c668b5420 100644
--- a/src/device.c
+++ b/src/device.c
@@ -6821,6 +6821,11 @@ uint32_t btd_device_get_current_flags(struct btd_device *dev)
return dev->current_flags;
}
+uint32_t btd_device_get_supported_flags(struct btd_device *dev)
+{
+ return dev->supported_flags;
+}
+
/* This event is sent immediately after add device on all mgmt sockets.
* Afterwards, it is only sent to mgmt sockets other than the one which called
* set_device_flags.
diff --git a/src/device.h b/src/device.h
index cc474bd889ec..9e81fda9e948 100644
--- a/src/device.h
+++ b/src/device.h
@@ -177,6 +177,7 @@ int device_discover_services(struct btd_device *device);
int btd_device_connect_services(struct btd_device *dev, GSList *services);
uint32_t btd_device_get_current_flags(struct btd_device *dev);
+uint32_t btd_device_get_supported_flags(struct btd_device *dev);
void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags,
uint32_t current_flags);
--
2.37.2
next reply other threads:[~2022-08-16 2:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 23:20 Luiz Augusto von Dentz [this message]
2022-08-16 4:39 ` [BlueZ] adapter: Check flags are supported bluez.test.bot
2022-08-16 23:20 ` [PATCH BlueZ] " patchwork-bot+bluetooth
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=20220815232006.1252933-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox