All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] monitor/att: Simplify CCC decoders
@ 2022-05-26 20:59 Luiz Augusto von Dentz
  2022-05-26 20:59 ` [PATCH v2 2/4] monitor/att: Add decoding support for PAC Sink/Source Luiz Augusto von Dentz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2022-05-26 20:59 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This simplify callbacks moving the decoding of the value to
print_ccc_value.
---
 monitor/att.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/monitor/att.c b/monitor/att.c
index df3e65057..0223af210 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -221,9 +221,15 @@ static const struct bitfield_data ccc_value_table[] = {
 	{ }
 };
 
-static void print_ccc_value(uint8_t value)
+static void print_ccc_value(const struct l2cap_frame *frame)
 {
-	uint8_t mask = value;
+	uint8_t value;
+	uint8_t mask;
+
+	if (!l2cap_frame_get_u8((void *)frame, &value)) {
+		print_text(COLOR_ERROR, "invalid size");
+		return;
+	}
 
 	mask = print_bitfield(4, value, ccc_value_table);
 	if (mask)
@@ -231,28 +237,14 @@ static void print_ccc_value(uint8_t value)
 								mask);
 }
 
-static void gatt_ccc_read(const struct l2cap_frame *frame)
+static void ccc_read(const struct l2cap_frame *frame)
 {
-	uint8_t value;
-
-	if (!l2cap_frame_get_u8((void *)frame, &value)) {
-		print_text(COLOR_ERROR, "invalid size");
-		return;
-	}
-
-	print_ccc_value(value);
+	print_ccc_value(frame);
 }
 
-static void gatt_ccc_write(const struct l2cap_frame *frame)
+static void ccc_write(const struct l2cap_frame *frame)
 {
-	uint8_t value;
-
-	if (!l2cap_frame_get_u8((void *)frame, &value)) {
-		print_text(COLOR_ERROR, "invalid size");
-		return;
-	}
-
-	print_ccc_value(value);
+	print_ccc_value(frame);
 }
 
 #define GATT_HANDLER(_uuid, _read, _write, _notify) \
@@ -272,8 +264,7 @@ struct gatt_handler {
 	void (*write)(const struct l2cap_frame *frame);
 	void (*notify)(const struct l2cap_frame *frame);
 } gatt_handlers[] = {
-	GATT_HANDLER(GATT_CLIENT_CHARAC_CFG_UUID, gatt_ccc_read,
-					gatt_ccc_write, NULL)
+	GATT_HANDLER(0x2902, ccc_read, ccc_write, NULL),
 };
 
 static struct gatt_handler *get_handler(struct gatt_db_attribute *attr)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-31 19:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 20:59 [PATCH v2 1/4] monitor/att: Simplify CCC decoders Luiz Augusto von Dentz
2022-05-26 20:59 ` [PATCH v2 2/4] monitor/att: Add decoding support for PAC Sink/Source Luiz Augusto von Dentz
2022-05-26 20:59 ` [PATCH v2 3/4] monitor/att: Add decoding support for ASE Sink/Source Luiz Augusto von Dentz
2022-05-26 20:59 ` [PATCH v2 4/4] monitor/att: Add decoding support for ASE Control Point Luiz Augusto von Dentz
2022-05-27  0:31 ` [v2,1/4] monitor/att: Simplify CCC decoders bluez.test.bot
2022-05-31 19:50 ` [PATCH v2 1/4] " patchwork-bot+bluetooth

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.