Bluetooth: Add Three-wire header value convenience macros
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 16 Jul 2012 13:12:07 +0000 (16:12 +0300)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Tue, 17 Jul 2012 17:48:22 +0000 (14:48 -0300)
This patch adds convenience macros for reading Three-wire header values.
This will help make the code more readable.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
drivers/bluetooth/hci_h5.c

index 6df4c07..f50afb2 100644 (file)
  */
 #define H5_MAX_LEN (4 + 0xfff + 2)
 
+/* Convenience macros for reading Three-wire header values */
+#define H5_HDR_SEQ(hdr)                ((hdr)[0] & 0x07)
+#define H5_HDR_ACK(hdr)                (((hdr)[0] >> 3) & 0x07)
+#define H5_HDR_CRC(hdr)                (((hdr)[0] >> 6) & 0x01)
+#define H5_HDR_RELIABLE(hdr)   (((hdr)[0] >> 7) & 0x01)
+#define H5_HDR_PKT_TYPE(hdr)   ((hdr)[1] & 0x0f)
+#define H5_HDR_LEN(hdr)                ((((hdr)[1] >> 4) & 0xff) + ((hdr)[2] << 4))
+
 #define SLIP_DELIMITER 0xc0
 #define SLIP_ESC       0xdb
 #define SLIP_ESC_DELIM 0xdc