From 3d8d7995d78689ad675348c0ffa74a860ad07e7f Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Mon, 16 Nov 2015 15:42:21 -0500 Subject: [PATCH] xpp: XFRAME_NEW_REG_CMD Prepare for different types of commands: replace XFRAME_NEW_CMD with XFRAME_NEW_REG_CMD in some places. Signed-off-by: Tzafrir Cohen --- drivers/dahdi/xpp/card_global.c | 5 ++--- drivers/dahdi/xpp/xproto.h | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/dahdi/xpp/card_global.c b/drivers/dahdi/xpp/card_global.c index 7e34231..f0c0ba4 100644 --- a/drivers/dahdi/xpp/card_global.c +++ b/drivers/dahdi/xpp/card_global.c @@ -56,7 +56,7 @@ static int send_magic_request(xbus_t *xbus, unsigned unit, xportno_t portno, * eoftx==1: Start sending us D-channel packets. * eoftx==0: Stop sending us D-channel packets. */ - XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, unit); + XFRAME_NEW_REG_CMD(xframe, pack, xbus, GLOBAL, REG, unit); reg_cmd = &RPACKET_FIELD(pack, GLOBAL, REGISTER_REQUEST, reg_cmd); reg_cmd->h.bytes = 0; reg_cmd->h.is_multibyte = 1; @@ -373,8 +373,7 @@ int xpp_register_request(xbus_t *xbus, xpd_t *xpd, xportno_t portno, DBG(REGS, "NO XBUS\n"); return -EINVAL; } - XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, REGISTER_REQUEST, - xpd->xbus_idx); + XFRAME_NEW_REG_CMD(xframe, pack, xbus, GLOBAL, REG, xpd->xbus_idx); LINE_DBG(REGS, xpd, portno, "%c%c %02X %02X %02X %02X\n", (writing) ? 'W' : 'R', (do_subreg) ? 'S' : 'D', regnum, subreg, data_low, data_high); diff --git a/drivers/dahdi/xpp/xproto.h b/drivers/dahdi/xpp/xproto.h index f88b4ed..0e0287f 100644 --- a/drivers/dahdi/xpp/xproto.h +++ b/drivers/dahdi/xpp/xproto.h @@ -204,6 +204,27 @@ typedef struct reg_cmd { #define REG_XDATA(regptr) ((regptr)->alt.d.xdata) #ifdef __KERNEL__ + +#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); \ + \ + if (!XBUS_FLAGS(xbus, CONNECTED)) \ + return -ENODEV; \ + (frm) = ALLOC_SEND_XFRAME(xbus); \ + if (!(frm)) \ + return -ENOMEM; \ + (p) = xframe_next_packet(frm, pack_len); \ + if (!(p)) \ + return -ENOMEM; \ + XPACKET_INIT(p, card, REGISTER_REQUEST, to, 0, 0); \ + XPACKET_LEN(p) = pack_len; \ + (frm)->usec_towait = 0; \ + } while (0) + /*----------------- protocol tables ----------------------------------*/ typedef struct xproto_entry xproto_entry_t;