linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Ivan Bornyakov <i.bornyakov@metrotek.ru>
Cc: "Conor Dooley" <conor.dooley@microchip.com>,
	"Moritz Fischer" <mdf@kernel.org>, "Wu Hao" <hao.wu@intel.com>,
	"Xu Yilun" <yilun.xu@intel.com>, "Tom Rix" <trix@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org,
	system@metrotek.ru
Subject: Re: [PATCH v3 3/3] fpga: microchip-spi: separate data frame write routine
Date: Wed, 28 Dec 2022 14:54:37 +0000	[thread overview]
Message-ID: <Y6xYrYgaapspY/md@spud> (raw)
In-Reply-To: <20221227100450.2257-4-i.bornyakov@metrotek.ru>

[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]

On Tue, Dec 27, 2022 at 01:04:50PM +0300, Ivan Bornyakov wrote:
> mpf_ops_write() function writes bitstream data to the FPGA by a smaller
> frames. Introduce mpf_spi_frame_write() function which is for writing a
> single data frame and use it in mpf_ops_write().
> 
> No functional changes intended.
> 
> Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>

Acked-by: Conor Dooley <conor.dooley@microchip.com>

Without another user for the new function I'm not super pushed, but I
suppose it does make things a little more readable.

Thanks,
Conor.

> ---
>  drivers/fpga/microchip-spi.c | 36 +++++++++++++++++++++++-------------
>  1 file changed, 23 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/fpga/microchip-spi.c b/drivers/fpga/microchip-spi.c
> index 8d1d9476d0cc..ea92e5d106fa 100644
> --- a/drivers/fpga/microchip-spi.c
> +++ b/drivers/fpga/microchip-spi.c
> @@ -274,9 +274,30 @@ static int mpf_ops_write_init(struct fpga_manager *mgr,
>  	return 0;
>  }
>  
> +static int mpf_spi_frame_write(struct mpf_priv *priv, const char *buf)
> +{
> +	struct spi_transfer xfers[2] = {
> +		{
> +			.tx_buf = &priv->tx,
> +			.len = 1,
> +		}, {
> +			.tx_buf = buf,
> +			.len = MPF_SPI_FRAME_SIZE,
> +		},
> +	};
> +	int ret;
> +
> +	ret = mpf_poll_status(priv, 0);
> +	if (ret < 0)
> +		return ret;
> +
> +	priv->tx = MPF_SPI_FRAME;
> +
> +	return spi_sync_transfer(priv->spi, xfers, ARRAY_SIZE(xfers));
> +}
> +
>  static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t count)
>  {
> -	struct spi_transfer xfers[2] = { 0 };
>  	struct mpf_priv *priv = mgr->priv;
>  	struct device *dev = &mgr->dev;
>  	int ret, i;
> @@ -287,19 +308,8 @@ static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t count
>  		return -EINVAL;
>  	}
>  
> -	xfers[0].tx_buf = &priv->tx;
> -	xfers[0].len = 1;
> -
>  	for (i = 0; i < count / MPF_SPI_FRAME_SIZE; i++) {
> -		xfers[1].tx_buf = buf + i * MPF_SPI_FRAME_SIZE;
> -		xfers[1].len = MPF_SPI_FRAME_SIZE;
> -
> -		ret = mpf_poll_status(priv, 0);
> -		if (ret >= 0) {
> -			priv->tx = MPF_SPI_FRAME;
> -			ret = spi_sync_transfer(priv->spi, xfers, ARRAY_SIZE(xfers));
> -		}
> -
> +		ret = mpf_spi_frame_write(priv, buf + i * MPF_SPI_FRAME_SIZE);
>  		if (ret) {
>  			dev_err(dev, "Failed to write bitstream frame %d/%zu\n",
>  				i, count / MPF_SPI_FRAME_SIZE);
> -- 
> 2.38.2
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2022-12-28 14:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27 10:04 [PATCH v3 0/3] Reliability improvements for Microchip MPF FPGA manager Ivan Bornyakov
2022-12-27 10:04 ` [PATCH v3 1/3] fpga: microchip-spi: move SPI I/O buffers out of stack Ivan Bornyakov
2022-12-28 14:42   ` Conor Dooley
2022-12-27 10:04 ` [PATCH v3 2/3] fpga: microchip-spi: rewrite status polling in a time measurable way Ivan Bornyakov
2022-12-27 10:22   ` Ilpo Järvinen
2022-12-28 14:50   ` Conor Dooley
2022-12-27 10:04 ` [PATCH v3 3/3] fpga: microchip-spi: separate data frame write routine Ivan Bornyakov
2022-12-28 14:54   ` Conor Dooley [this message]

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=Y6xYrYgaapspY/md@spud \
    --to=conor@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=hao.wu@intel.com \
    --cc=i.bornyakov@metrotek.ru \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=system@metrotek.ru \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.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;
as well as URLs for NNTP newsgroup(s).