linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access
@ 2022-04-13 13:49 Geert Uytterhoeven
  2022-04-14  7:28 ` Krzysztof Kozlowski
  2022-04-14  7:46 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2022-04-13 13:49 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Wolfram Sang, Sergey Shtylyov, Lad Prabhakar, Andrew Gabbasov,
	linux-renesas-soc, linux-mtd, linux-kernel, Geert Uytterhoeven

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>
---
v2:
  - Add Tested-by, Reviewed-by,
  - Remove unneeded pointer post-increments from final dereferences.
---
 drivers/memory/renesas-rpc-if.c | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c
index 019a0822bde0e413..ba9c526833c0f4da 100644
--- a/drivers/memory/renesas-rpc-if.c
+++ b/drivers/memory/renesas-rpc-if.c
@@ -488,7 +488,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;
 
@@ -502,15 +502,9 @@ int rpcif_manual_xfer(struct rpcif *rpc)
 			rpc->xfer_size = nbytes;
 
 			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);
@@ -552,7 +546,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));
@@ -569,15 +563,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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access
  2022-04-13 13:49 [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access Geert Uytterhoeven
@ 2022-04-14  7:28 ` Krzysztof Kozlowski
  2022-04-14  7:41   ` Geert Uytterhoeven
  2022-04-14  7:46 ` Krzysztof Kozlowski
  1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-04-14  7:28 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Wolfram Sang, Sergey Shtylyov, Lad Prabhakar, Andrew Gabbasov,
	linux-renesas-soc, linux-mtd, linux-kernel

On 13/04/2022 15:49, Geert Uytterhoeven wrote:
> 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>

This does not apply on a next branch. Maybe because I put "memory:
renesas-rpc-if: Fix HF/OSPI data transfer in Manual Mode" for fixes?
Does this patch depend on that fix?


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access
  2022-04-14  7:28 ` Krzysztof Kozlowski
@ 2022-04-14  7:41   ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2022-04-14  7:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Wolfram Sang, Sergey Shtylyov, Lad Prabhakar, Andrew Gabbasov,
	Linux-Renesas, MTD Maling List, Linux Kernel Mailing List

Hi Krzysztof,

On Thu, Apr 14, 2022 at 9:28 AM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
> On 13/04/2022 15:49, Geert Uytterhoeven wrote:
> > 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>
>
> This does not apply on a next branch. Maybe because I put "memory:
> renesas-rpc-if: Fix HF/OSPI data transfer in Manual Mode" for fixes?
> Does this patch depend on that fix?

There is no functional dependency, but a slight contextual one.
It should apply with some fuzz:

$ git am --show-current-patch | patch -p1
patching file drivers/memory/renesas-rpc-if.c
Hunk #1 succeeded at 458 (offset -30 lines).
Hunk #2 succeeded at 471 with fuzz 1 (offset -31 lines).
Hunk #3 succeeded at 515 (offset -31 lines).
Hunk #4 succeeded at 531 (offset -32 lines).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access
  2022-04-13 13:49 [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access Geert Uytterhoeven
  2022-04-14  7:28 ` Krzysztof Kozlowski
@ 2022-04-14  7:46 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-04-14  7:46 UTC (permalink / raw)
  To: Geert Uytterhoeven, Krzysztof Kozlowski
  Cc: Krzysztof Kozlowski, linux-mtd, Sergey Shtylyov, linux-kernel,
	Andrew Gabbasov, linux-renesas-soc, Lad Prabhakar, Wolfram Sang

On Wed, 13 Apr 2022 15:49:21 +0200, Geert Uytterhoeven wrote:
> For manual write and read, factor out the common access to the first
> data register by keeping track of the current data pointer.
> 
> 

Applied, thanks!

[1/1] memory: renesas-rpc-if: Simplify single/double data register access
      commit: 1f26a60b55aa654c73b5b9eb9eab8a7d687d429d


You can double check if hunks matched correctly:

https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-mem-ctrl.git/commit/?h=mem-ctrl-next&id=1f26a60b55aa654c73b5b9eb9eab8a7d687d429d

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-14  7:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 13:49 [PATCH v2] memory: renesas-rpc-if: Simplify single/double data register access Geert Uytterhoeven
2022-04-14  7:28 ` Krzysztof Kozlowski
2022-04-14  7:41   ` Geert Uytterhoeven
2022-04-14  7:46 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).