linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sonny Sasaka <sonnysasaka@chromium.org>
To: linux-bluetooth@vger.kernel.org
Cc: Sonny Sasaka <sonnysasaka@chromium.org>
Subject: [PATCH BlueZ] profile: Add exception from being claimed internally
Date: Wed, 15 Jul 2020 15:28:12 -0700	[thread overview]
Message-ID: <20200715222812.238172-1-sonnysasaka@chromium.org> (raw)

This adds a flag to give exception to profiles that are considered safe
to be both handled internally and externally via GATT API. Currently
this includes the battery profile.

---
 profiles/battery/battery.c | 1 +
 src/device.c               | 2 +-
 src/profile.h              | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
index 4da4355a1..20aa47727 100644
--- a/profiles/battery/battery.c
+++ b/profiles/battery/battery.c
@@ -354,6 +354,7 @@ static struct btd_profile batt_profile = {
 	.device_remove	= batt_remove,
 	.accept		= batt_accept,
 	.disconnect	= batt_disconnect,
+	.claim_service_exception = true,
 };
 
 static int batt_init(void)
diff --git a/src/device.c b/src/device.c
index 0deee2707..cfa52461f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3818,7 +3818,7 @@ done:
 	profile = btd_service_get_profile(service);
 
 	/* Claim attributes of internal profiles */
-	if (!profile->external) {
+	if (!profile->external && !profile->claim_service_exception) {
 		/* Mark the service as claimed by the existing profile. */
 		gatt_db_service_set_claimed(attr, true);
 	}
diff --git a/src/profile.h b/src/profile.h
index 4448a2a6d..25e83381b 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -36,6 +36,11 @@ struct btd_profile {
 
 	bool auto_connect;
 	bool external;
+	/* Some profiles are considered safe to be handled internally and also
+	 * be exposed in the GATT API. This flag give such profiles exception
+	 * from being claimed internally.
+	 */
+	bool claim_service_exception;
 
 	int (*device_probe) (struct btd_service *service);
 	void (*device_remove) (struct btd_service *service);
-- 
2.26.2


             reply	other threads:[~2020-07-15 22:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 22:28 Sonny Sasaka [this message]
2020-07-15 22:39 ` [PATCH BlueZ] profile: Add exception from being claimed internally Luiz Augusto von Dentz
2020-07-15 22:47   ` [PATCH BlueZ v2] profile: Add exception to battery profile for external access Sonny Sasaka
2020-07-17 20:13     ` Sonny Sasaka
2020-07-17 20:33       ` Luiz Augusto von Dentz
2020-07-17 20:38         ` Luiz Augusto von Dentz
2020-07-17 21:36           ` Sonny Sasaka
2020-07-15 22:49   ` [PATCH BlueZ] profile: Add exception from being claimed internally Sonny Sasaka

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=20200715222812.238172-1-sonnysasaka@chromium.org \
    --to=sonnysasaka@chromium.org \
    --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;
as well as URLs for NNTP newsgroup(s).