diff mbox series

[v2,1/4] monitor/att: Simplify CCC decoders

Message ID 20220526205937.4159665-1-luiz.dentz@gmail.com
State New
Headers show
Series [v2,1/4] monitor/att: Simplify CCC decoders | expand

Commit Message

Luiz Augusto von Dentz May 26, 2022, 8:59 p.m. UTC
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(-)

Comments

patchwork-bot+bluetooth@kernel.org May 31, 2022, 7:50 p.m. UTC | #1
Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 26 May 2022 13:59:34 -0700 you wrote:
> 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(-)

Here is the summary with links:
  - [v2,1/4] monitor/att: Simplify CCC decoders
    (no matching commit)
  - [v2,2/4] monitor/att: Add decoding support for PAC Sink/Source
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=13bdb9f3bee1
  - [v2,3/4] monitor/att: Add decoding support for ASE Sink/Source
    (no matching commit)
  - [v2,4/4] monitor/att: Add decoding support for ASE Control Point
    (no matching commit)

You are awesome, thank you!
diff mbox series

Patch

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)