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 <tzafrir.cohen@xorcom.com>
This commit is contained in:
Oron Peled 2015-11-16 15:42:21 -05:00 committed by Tzafrir Cohen
parent 9dfc02a38c
commit 3d8d7995d7
2 changed files with 23 additions and 3 deletions

View File

@ -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);

View File

@ -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;