From: Pavel Machek <pavel@nabladev.com>
To: ovidiu.panait.rb@renesas.com
Cc: cip-dev@lists.cip-project.org, pavel@nabladev.com,
nobuhiro.iwamatsu.x90@mail.toshiba
Subject: Re: [cip-dev] [PATCH 6.1.y-cip 2/8] spi: Add driver for the RZ/V2H(P) RSPI IP
Date: Thu, 16 Apr 2026 22:51:42 +0200 [thread overview]
Message-ID: <aeFL3nqhdtOk6cQm@duo.ucw.cz> (raw)
In-Reply-To: <20260415131919.95486-3-ovidiu.panait.rb@renesas.com>
[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]
Hi!
> new file mode 100644
> index 000000000000..cf4272f99378
> --- /dev/null
> +++ b/drivers/spi/spi-rzv2h-rspi.c
> +
> +#define RZV2H_RSPI_TX(func, type) \
> +static inline void rzv2h_rspi_tx_##type(struct rzv2h_rspi_priv *rspi, \
> + const void *txbuf, \
> + unsigned int index) { \
> + type buf = 0; \
> + \
> + if (txbuf) \
> + buf = ((type *)txbuf)[index]; \
> + \
> + func(buf, rspi->base + RSPI_SPDR); \
> +}
> +
> +#define RZV2H_RSPI_RX(func, type) \
> +static inline void rzv2h_rspi_rx_##type(struct rzv2h_rspi_priv *rspi, \
> + void *rxbuf, \
> + unsigned int index) { \
> + type buf = func(rspi->base + RSPI_SPDR); \
> + \
> + if (rxbuf) \
> + ((type *)rxbuf)[index] = buf; \
> +}
> +
> +RZV2H_RSPI_TX(writel, u32)
> +RZV2H_RSPI_TX(writew, u16)
> +RZV2H_RSPI_TX(writeb, u8)
> +RZV2H_RSPI_RX(readl, u32)
> +RZV2H_RSPI_RX(readw, u16)
> +RZV2H_RSPI_RX(readl, u8)
This is quite ... complex system for generating functions that are
then only used once. I suspect that if you just inlined the functions
by hand, code would be easier to read, and not really longer.
Thanks and best regards,
Pavel
> +static void rzv2h_rspi_send(struct rzv2h_rspi_priv *rspi, const void *txbuf,
> + unsigned int index)
> +{
> + switch (rspi->bytes_per_word) {
> + case 4:
> + rzv2h_rspi_tx_u32(rspi, txbuf, index);
> + break;
> + case 2:
> + rzv2h_rspi_tx_u16(rspi, txbuf, index);
> + break;
> + default:
> + rzv2h_rspi_tx_u8(rspi, txbuf, index);
> + }
> +}
> +
> +static int rzv2h_rspi_receive(struct rzv2h_rspi_priv *rspi, void *rxbuf,
> + unsigned int index)
> +{
> + int ret;
> +
> + ret = rzv2h_rspi_wait_for_interrupt(rspi, RSPI_SPSR_SPRF);
> + if (ret)
> + return ret;
> +
> + switch (rspi->bytes_per_word) {
> + case 4:
> + rzv2h_rspi_rx_u32(rspi, rxbuf, index);
> + break;
> + case 2:
> + rzv2h_rspi_rx_u16(rspi, rxbuf, index);
> + break;
> + default:
> + rzv2h_rspi_rx_u8(rspi, rxbuf, index);
> + }
> +
> + return 0;
> +}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2026-04-16 20:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 13:19 [PATCH 6.1.y-cip 0/8] Add RSPI support for RZ/V2H and RZ/V2N Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 1/8] spi: dt-bindings: Document the RZ/V2H(P) RSPI Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 2/8] spi: Add driver for the RZ/V2H(P) RSPI IP Ovidiu Panait
2026-04-16 20:51 ` Pavel Machek [this message]
2026-04-15 13:19 ` [PATCH 6.1.y-cip 3/8] arm64: defconfig: Enable the RZ/V2H(P) RSPI driver Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 4/8] spi: dt-bindings: renesas,rzv2h-rspi: Document RZ/V2N SoC support Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 5/8] clk: renesas: r9a09g056: Add entries for the RSPIs Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 6/8] clk: renesas: r9a09g057: " Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 7/8] arm64: dts: renesas: r9a09g056: Add RSPI nodes Ovidiu Panait
2026-04-15 13:19 ` [PATCH 6.1.y-cip 8/8] arm64: dts: renesas: r9a09g057: " Ovidiu Panait
2026-04-16 20:52 ` [cip-dev] [PATCH 6.1.y-cip 0/8] Add RSPI support for RZ/V2H and RZ/V2N Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aeFL3nqhdtOk6cQm@duo.ucw.cz \
--to=pavel@nabladev.com \
--cc=cip-dev@lists.cip-project.org \
--cc=nobuhiro.iwamatsu.x90@mail.toshiba \
--cc=ovidiu.panait.rb@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox