Skip to content

Commit 108420f

Browse files
nxpfranklialexandrebelloni
authored andcommitted
i3c: master: svc: Replace bool rnw with union for HDR support
Replace the bool rnw field with a union in preparation for adding HDR support. HDR uses a cmd field instead of the rnw bit to indicate read or write direction. Add helper function svc_cmd_is_read() to check transfer direction. Add a local variable 'rnw' in svc_i3c_master_priv_xfers() to avoid repeatedly accessing xfers[i].rnw. No functional change. Signed-off-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251106-i3c_ddr-v11-3-33a6a66ed095@nxp.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 9280b6e commit 108420f

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

drivers/i3c/master/svc-i3c-master.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@
165165

166166
struct svc_i3c_cmd {
167167
u8 addr;
168-
bool rnw;
168+
union {
169+
bool rnw;
170+
u8 cmd;
171+
u32 rnw_cmd;
172+
};
169173
u8 *in;
170174
const void *out;
171175
unsigned int len;
@@ -383,6 +387,11 @@ svc_i3c_master_dev_from_addr(struct svc_i3c_master *master,
383387
return master->descs[i];
384388
}
385389

390+
static bool svc_cmd_is_read(u32 rnw_cmd, u32 type)
391+
{
392+
return rnw_cmd;
393+
}
394+
386395
static void svc_i3c_master_emit_stop(struct svc_i3c_master *master)
387396
{
388397
writel(SVC_I3C_MCTRL_REQUEST_STOP, master->regs + SVC_I3C_MCTRL);
@@ -1299,10 +1308,11 @@ static int svc_i3c_master_write(struct svc_i3c_master *master,
12991308
}
13001309

13011310
static int svc_i3c_master_xfer(struct svc_i3c_master *master,
1302-
bool rnw, unsigned int xfer_type, u8 addr,
1311+
u32 rnw_cmd, unsigned int xfer_type, u8 addr,
13031312
u8 *in, const u8 *out, unsigned int xfer_len,
13041313
unsigned int *actual_len, bool continued, bool repeat_start)
13051314
{
1315+
bool rnw = svc_cmd_is_read(rnw_cmd, xfer_type);
13061316
int retry = repeat_start ? 1 : 2;
13071317
u32 reg;
13081318
int ret;
@@ -1490,7 +1500,7 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
14901500
for (i = 0; i < xfer->ncmds; i++) {
14911501
struct svc_i3c_cmd *cmd = &xfer->cmds[i];
14921502

1493-
ret = svc_i3c_master_xfer(master, cmd->rnw, xfer->type,
1503+
ret = svc_i3c_master_xfer(master, cmd->rnw_cmd, xfer->type,
14941504
cmd->addr, cmd->in, cmd->out,
14951505
cmd->len, &cmd->actual_len,
14961506
cmd->continued, i > 0);
@@ -1683,14 +1693,15 @@ static int svc_i3c_master_priv_xfers(struct i3c_dev_desc *dev,
16831693

16841694
for (i = 0; i < nxfers; i++) {
16851695
struct svc_i3c_cmd *cmd = &xfer->cmds[i];
1696+
bool rnw = xfers[i].rnw;
16861697

16871698
cmd->xfer = &xfers[i];
16881699
cmd->addr = master->addrs[data->index];
1689-
cmd->rnw = xfers[i].rnw;
1690-
cmd->in = xfers[i].rnw ? xfers[i].data.in : NULL;
1691-
cmd->out = xfers[i].rnw ? NULL : xfers[i].data.out;
1700+
cmd->rnw = rnw;
1701+
cmd->in = rnw ? xfers[i].data.in : NULL;
1702+
cmd->out = rnw ? NULL : xfers[i].data.out;
16921703
cmd->len = xfers[i].len;
1693-
cmd->actual_len = xfers[i].rnw ? xfers[i].len : 0;
1704+
cmd->actual_len = rnw ? xfers[i].len : 0;
16941705
cmd->continued = (i + 1) < nxfers;
16951706
}
16961707

0 commit comments

Comments
 (0)