All of lore.kernel.org
 help / color / mirror / Atom feed
From: andy.shevchenko@gmail.com
To: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Cc: Mark Brown <broonie@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>
Subject: Re: [PATCH v2 3/5] spi: Add support for Renesas CSI
Date: Wed, 5 Jul 2023 13:41:37 +0300	[thread overview]
Message-ID: <ZKVI4XPbPXfzQa9J@surfacebook> (raw)
In-Reply-To: <20230622113341.657842-4-fabrizio.castro.jz@renesas.com>

Thu, Jun 22, 2023 at 12:33:39PM +0100, Fabrizio Castro kirjoitti:
> The RZ/V2M SoC comes with the Clocked Serial Interface (CSI)
> IP, which is a master/slave SPI controller.
> 
> This commit adds a driver to support CSI master mode.

Submitting Patches recommends to use imperative voice.

...

+ bits.h

> +#include <linux/clk.h>
> +#include <linux/count_zeros.h>
> +#include <linux/interrupt.h>
> +#include <linux/iopoll.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset.h>
> +#include <linux/spi/spi.h>

...

> +#define CSI_CKS_MAX		0x3FFF

If it's limited by number of bits, i would explicitly use that information as
(BIT(14) - 1).

...

> +#define CSI_MAX_SPI_SCKO	8000000

Units?
Also, HZ_PER_MHZ?

...

> +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
> +};

Why do you need tables? At the first glance these values can be easily
calculated from indexes.

...

> +	rzv2m_csi_reg_write_bit(csi, CSI_CNT, CSI_CNT_CSIRST, assert);
> +
> +	if (assert) {

	If (!assert)
		return 0;

> +		return readl_poll_timeout(csi->base + CSI_MODE, reg,
> +					  !(reg & CSI_MODE_CSOT), 0,
> +					  CSI_EN_DIS_TIMEOUT_US);
> +	}
> +
> +	return 0;

...

> +	rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_CSIE, enable);
> +
> +	if (!enable && wait)

In the similar way.

> +		return readl_poll_timeout(csi->base + CSI_MODE, reg,
> +					  !(reg & CSI_MODE_CSOT), 0,
> +					  CSI_EN_DIS_TIMEOUT_US);
> +
> +	return 0;

...

> +		for (i = 0; i < csi->words_to_transfer; i++)
> +			writel(buf[i], csi->base + CSI_OFIFO);

writesl()?

...

> +		for (i = 0; i < csi->words_to_transfer; i++)
> +			buf[i] = (u16)readl(csi->base + CSI_IFIFO);

readsl()?

...

> +		for (i = 0; i < csi->words_to_transfer; i++)
> +			buf[i] = (u8)readl(csi->base + CSI_IFIFO);

readsl()?

...

Yes, in read cases you would need carefully handle the buffer data.
Or drop the idea if it looks too monsterous.

...

> +	ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_TREND, CSI_CNT_TREND_E);

> +

Unneeded blank line.

> +	if (ret == -ETIMEDOUT)
> +		csi->errors |= TX_TIMEOUT_ERROR;

...

> +	struct rzv2m_csi_priv *csi = (struct rzv2m_csi_priv *)data;

From/to void * does not need an explicit casting in C.

...

> +	/* Setup clock polarity and phase timing */
> +	rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP,
> +				!(spi->mode & SPI_CPOL));
> +	rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP,
> +				!(spi->mode & SPI_CPHA));

Is it a must to do in a sequential writes?

...

> +	bool tx_completed = csi->txbuf ? false : true;
> +	bool rx_completed = csi->rxbuf ? false : true;

Ternaries are redundant in the above.

...

> +	controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;

SPI_MODE_X_MASK

...

> +	controller->dev.of_node = pdev->dev.of_node;

device_set_node();

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2023-07-05 10:41 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-22 11:33 [PATCH v2 0/5] spi: Add CSI support for Renesas RZ/V2M Fabrizio Castro
2023-06-22 11:33 ` Fabrizio Castro
2023-06-22 11:33 ` [PATCH v2 1/5] spi: dt-bindings: Add bindings for RZ/V2M CSI Fabrizio Castro
2023-07-03  9:43   ` Geert Uytterhoeven
2023-06-22 11:33 ` [PATCH v2 2/5] clk: renesas: r9a09g011: Add CSI related clocks Fabrizio Castro
2023-07-03  9:59   ` Geert Uytterhoeven
2023-06-22 11:33 ` [PATCH v2 3/5] spi: Add support for Renesas CSI Fabrizio Castro
2023-07-03 10:19   ` Geert Uytterhoeven
2023-07-05 10:24     ` andy.shevchenko
2023-07-05 11:36       ` Geert Uytterhoeven
2023-07-10 16:23     ` Fabrizio Castro
2023-07-05 10:41   ` andy.shevchenko [this message]
2023-07-13 15:52     ` Fabrizio Castro
2023-07-13 16:37       ` Andy Shevchenko
2023-07-13 22:35         ` Fabrizio Castro
2023-07-14  7:30           ` Geert Uytterhoeven
2023-07-14  9:36             ` Fabrizio Castro
2023-06-22 11:33 ` [PATCH v2 4/5] arm64: dts: renesas: r9a09g011: Add CSI nodes Fabrizio Castro
2023-07-03 11:47   ` Geert Uytterhoeven
2023-06-22 11:33 ` [PATCH v2 5/5] arm64: defconfig: Enable Renesas RZ/V2M CSI driver Fabrizio Castro
2023-06-22 11:33   ` Fabrizio Castro
2023-07-03 11:49   ` Geert Uytterhoeven
2023-07-03 11:49     ` Geert Uytterhoeven
2023-06-23  0:32 ` [PATCH v2 0/5] spi: Add CSI support for Renesas RZ/V2M Mark Brown
2023-06-23  0:32   ` Mark Brown
2023-06-23  6:49   ` Geert Uytterhoeven
2023-06-23  6:49     ` Geert Uytterhoeven
2023-06-23 10:05     ` Mark Brown
2023-06-23 10:05       ` Mark Brown
2023-06-23 15:08 ` (subset) " Mark Brown
2023-06-23 15:08   ` Mark Brown

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=ZKVI4XPbPXfzQa9J@surfacebook \
    --to=andy.shevchenko@gmail.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=biju.das@bp.renesas.com \
    --cc=broonie@kernel.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=p.zabel@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.