2023-07-18 19:36:01

by Fabrizio Castro

[permalink] [raw]
Subject: [PATCH v2 0/4] spi: rzv2m-csi: Code refactoring

Dear All,

I am sending this series to follow up on the comments received
from the first version of this series.
The first 5 patches of the first series have been taken by Mark
already (thanks Mark), this second version only addresses the
remaining patches.

I would like to highlight that I have dropped patch
"spi: rzv2m-csi: Switch to using {read,write}s{b,w}" for now,
and maybe I will send a follow up patch later on.

Thanks,
Fab

Fabrizio Castro (4):
spi: rzv2m-csi: Squash timing settings into one statement
spi: rzv2m-csi: Improve data types, casting and alignment
spi: rzv2m-csi: Get rid of the x_trg{_words} tables
spi: rzv2m-csi: Make use of device_set_node

drivers/spi/spi-rzv2m-csi.c | 78 +++++++++++++++----------------------
1 file changed, 32 insertions(+), 46 deletions(-)

--
2.34.1



2023-07-18 19:46:20

by Fabrizio Castro

[permalink] [raw]
Subject: [PATCH v2 3/4] spi: rzv2m-csi: Get rid of the x_trg{_words} tables

Table x_trg can be replaced with ilog2(), and table x_trg_words
can be replaced with rounddown_pow_of_two().
Replace the tables usage with the corresponding macros.
While at it, remove a couple of unnecessary empty lines.

Signed-off-by: Fabrizio Castro <[email protected]>
Suggested-by: Andy Shevchenko <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
---

v2: No change.

drivers/spi/spi-rzv2m-csi.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c
index 4dbb8c185a8a..62575a61608a 100644
--- a/drivers/spi/spi-rzv2m-csi.c
+++ b/drivers/spi/spi-rzv2m-csi.c
@@ -10,6 +10,7 @@
#include <linux/count_zeros.h>
#include <linux/interrupt.h>
#include <linux/iopoll.h>
+#include <linux/log2.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/spi/spi.h>
@@ -99,20 +100,6 @@ struct rzv2m_csi_priv {
u32 status;
};

-static const unsigned char x_trg[] = {
- 0, 1, 1, 2, 2, 2, 2, 3,
- 3, 3, 3, 3, 3, 3, 3, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 5
-};
-
-static const unsigned char x_trg_words[] = {
- 1, 2, 2, 4, 4, 4, 4, 8,
- 8, 8, 8, 8, 8, 8, 8, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 32
-};
-
static void rzv2m_csi_reg_write_bit(const struct rzv2m_csi_priv *csi,
int reg_offs, int bit_mask, u32 value)
{
@@ -230,7 +217,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi)
* less than or equal to the number of bytes we need to transfer.
* This may result in multiple smaller transfers.
*/
- csi->words_to_transfer = x_trg_words[to_transfer - 1];
+ csi->words_to_transfer = rounddown_pow_of_two(to_transfer);

if (csi->bytes_per_word == 2)
csi->bytes_to_transfer = csi->words_to_transfer << 1;
@@ -241,7 +228,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi)
static inline void rzv2m_csi_set_rx_fifo_trigger_level(struct rzv2m_csi_priv *csi)
{
rzv2m_csi_reg_write_bit(csi, CSI_FIFOTRG, CSI_FIFOTRG_R_TRG,
- x_trg[csi->words_to_transfer - 1]);
+ ilog2(csi->words_to_transfer));
}

static inline void rzv2m_csi_enable_rx_trigger(struct rzv2m_csi_priv *csi,
@@ -314,7 +301,6 @@ static int rzv2m_csi_wait_for_tx_empty(struct rzv2m_csi_priv *csi)
return 0;

ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_TREND, CSI_CNT_TREND_E);
-
if (ret == -ETIMEDOUT)
csi->errors |= TX_TIMEOUT_ERROR;

@@ -330,7 +316,6 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi)

ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_R_TRGR,
CSI_CNT_R_TRGR_E);
-
if (ret == -ETIMEDOUT)
csi->errors |= RX_TIMEOUT_ERROR;

--
2.34.1


2023-07-18 19:47:09

by Fabrizio Castro

[permalink] [raw]
Subject: [PATCH v2 4/4] spi: rzv2m-csi: Make use of device_set_node

Use device_set_node instead of assigning controller->dev.of_node
directly because it also sets the firmware node.

Signed-off-by: Fabrizio Castro <[email protected]>
Suggested-by: Andy Shevchenko <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---

v2: Edited the changelog and added include of property.h, according
to the feedback received from Andy.

drivers/spi/spi-rzv2m-csi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c
index 62575a61608a..d098aefa370d 100644
--- a/drivers/spi/spi-rzv2m-csi.c
+++ b/drivers/spi/spi-rzv2m-csi.c
@@ -12,6 +12,7 @@
#include <linux/iopoll.h>
#include <linux/log2.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/reset.h>
#include <linux/spi/spi.h>
#include <linux/units.h>
@@ -589,12 +590,13 @@ static int rzv2m_csi_probe(struct platform_device *pdev)
init_waitqueue_head(&csi->wait);

controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
- controller->dev.of_node = pdev->dev.of_node;
controller->bits_per_word_mask = SPI_BPW_MASK(16) | SPI_BPW_MASK(8);
controller->setup = rzv2m_csi_setup;
controller->transfer_one = rzv2m_csi_transfer_one;
controller->use_gpio_descriptors = true;

+ device_set_node(&controller->dev, dev_fwnode(dev));
+
ret = devm_request_irq(dev, irq, rzv2m_csi_irq_handler, 0,
dev_name(dev), csi);
if (ret)
--
2.34.1


2023-07-18 20:29:50

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] spi: rzv2m-csi: Make use of device_set_node

On Tue, Jul 18, 2023 at 10:25 PM Fabrizio Castro
<[email protected]> wrote:
>
> Use device_set_node instead of assigning controller->dev.of_node

device_set_node()

> directly because it also sets the firmware node.

--
With Best Regards,
Andy Shevchenko

2023-07-19 16:24:04

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] spi: rzv2m-csi: Code refactoring

On Tue, 18 Jul 2023 20:24:49 +0100, Fabrizio Castro wrote:
> I am sending this series to follow up on the comments received
> from the first version of this series.
> The first 5 patches of the first series have been taken by Mark
> already (thanks Mark), this second version only addresses the
> remaining patches.
>
> I would like to highlight that I have dropped patch
> "spi: rzv2m-csi: Switch to using {read,write}s{b,w}" for now,
> and maybe I will send a follow up patch later on.
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/4] spi: rzv2m-csi: Squash timing settings into one statement
commit: d5737d12779a171e76ad07635d1ed06a22009da7
[2/4] spi: rzv2m-csi: Improve data types, casting and alignment
commit: 8dc4038a026a79b6222a43ccf7adf070c4ba54ea
[3/4] spi: rzv2m-csi: Get rid of the x_trg{_words} tables
commit: 7b63568fce9cb34cb0ad4caf9231555eb768c8e6
[4/4] spi: rzv2m-csi: Make use of device_set_node
commit: c5a7b66811d22a4901bd358447e59160dbda8f65

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark