mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-29 15:14:18 +08:00
memory: renesas-rpc-if: Simplify single/double data register access
For manual write and read, factor out the common access to the first data register by keeping track of the current data pointer. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/c3b2a8d1a69f1b1e8d1a460148406cfb83e52eb4.1649857740.git.geert+renesas@glider.be Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
This commit is contained in:
parent
8f0e3af817
commit
1f26a60b55
@ -458,7 +458,7 @@ int rpcif_manual_xfer(struct rpcif *rpc)
|
||||
case RPCIF_DATA_OUT:
|
||||
while (pos < rpc->xferlen) {
|
||||
u32 bytes_left = rpc->xferlen - pos;
|
||||
u32 nbytes, data[2];
|
||||
u32 nbytes, data[2], *p = data;
|
||||
|
||||
smcr = rpc->smcr | RPCIF_SMCR_SPIE;
|
||||
|
||||
@ -471,15 +471,9 @@ int rpcif_manual_xfer(struct rpcif *rpc)
|
||||
regmap_write(rpc->regmap, RPCIF_SMENR, smenr);
|
||||
|
||||
memcpy(data, rpc->buffer + pos, nbytes);
|
||||
if (nbytes == 8) {
|
||||
regmap_write(rpc->regmap, RPCIF_SMWDR1,
|
||||
data[0]);
|
||||
regmap_write(rpc->regmap, RPCIF_SMWDR0,
|
||||
data[1]);
|
||||
} else {
|
||||
regmap_write(rpc->regmap, RPCIF_SMWDR0,
|
||||
data[0]);
|
||||
}
|
||||
if (nbytes == 8)
|
||||
regmap_write(rpc->regmap, RPCIF_SMWDR1, *p++);
|
||||
regmap_write(rpc->regmap, RPCIF_SMWDR0, *p);
|
||||
|
||||
regmap_write(rpc->regmap, RPCIF_SMCR, smcr);
|
||||
ret = wait_msg_xfer_end(rpc);
|
||||
@ -521,7 +515,7 @@ int rpcif_manual_xfer(struct rpcif *rpc)
|
||||
}
|
||||
while (pos < rpc->xferlen) {
|
||||
u32 bytes_left = rpc->xferlen - pos;
|
||||
u32 nbytes, data[2];
|
||||
u32 nbytes, data[2], *p = data;
|
||||
|
||||
/* nbytes may only be 1, 2, 4, or 8 */
|
||||
nbytes = bytes_left >= max ? max : (1 << ilog2(bytes_left));
|
||||
@ -537,15 +531,9 @@ int rpcif_manual_xfer(struct rpcif *rpc)
|
||||
if (ret)
|
||||
goto err_out;
|
||||
|
||||
if (nbytes == 8) {
|
||||
regmap_read(rpc->regmap, RPCIF_SMRDR1,
|
||||
&data[0]);
|
||||
regmap_read(rpc->regmap, RPCIF_SMRDR0,
|
||||
&data[1]);
|
||||
} else {
|
||||
regmap_read(rpc->regmap, RPCIF_SMRDR0,
|
||||
&data[0]);
|
||||
}
|
||||
if (nbytes == 8)
|
||||
regmap_read(rpc->regmap, RPCIF_SMRDR1, p++);
|
||||
regmap_read(rpc->regmap, RPCIF_SMRDR0, p);
|
||||
memcpy(rpc->buffer + pos, data, nbytes);
|
||||
|
||||
pos += nbytes;
|
||||
|
Loading…
Reference in New Issue
Block a user