From b8b884d205ac55e326e35c1593a14e9c6446903e Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 27 Mar 2017 18:48:45 +0300 Subject: [PATCH] xpp: correct size for BRI multibyte packets Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/card_bri.c | 4 ++-- drivers/dahdi/xpp/xproto.h | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c index 76ff495..12efecf 100644 --- a/drivers/dahdi/xpp/card_bri.c +++ b/drivers/dahdi/xpp/card_bri.c @@ -564,7 +564,7 @@ static void fill_multibyte(xpd_t *xpd, xpacket_t *pack, char *p; XPACKET_INIT(pack, GLOBAL, REGISTER_REQUEST, xpd->xbus_idx, 0, 0); - XPACKET_LEN(pack) = RPACKET_SIZE(GLOBAL, REGISTER_REQUEST); + XPACKET_LEN(pack) = XFRAME_CMD_LEN(REG); reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd); reg_cmd->h.bytes = len; reg_cmd->h.is_multibyte = 1; @@ -610,7 +610,7 @@ static int tx_dchan(xpd_t *xpd) return -ENOMEM; } for (packet_count = 0, eoframe = 0; !eoframe; packet_count++) { - int packet_len = RPACKET_SIZE(GLOBAL, REGISTER_REQUEST); + int packet_len = XFRAME_CMD_LEN(REG); char buf[MULTIBYTE_MAX_LEN]; int len = MULTIBYTE_MAX_LEN; diff --git a/drivers/dahdi/xpp/xproto.h b/drivers/dahdi/xpp/xproto.h index 534a0cd..ee583df 100644 --- a/drivers/dahdi/xpp/xproto.h +++ b/drivers/dahdi/xpp/xproto.h @@ -222,12 +222,16 @@ typedef struct reg_cmd { #ifdef __KERNEL__ +#define XFRAME_CMD_LEN(variant) \ + ( \ + sizeof(struct xpacket_header) + \ + sizeof(struct reg_cmd_header) + \ + sizeof(struct reg_cmd_ ## variant) \ + ) + #define XFRAME_NEW_REG_CMD(frm, p, xbus, card, variant, to) \ do { \ - int pack_len = \ - sizeof(struct xpacket_header) + \ - sizeof(struct reg_cmd_header) + \ - sizeof(struct reg_cmd_ ## variant); \ + int pack_len = XFRAME_CMD_LEN(variant); \ \ if (!XBUS_FLAGS(xbus, CONNECTED)) \ return -ENODEV; \