From: Mark Brown <broonie@kernel.org>
To: Anatolij Gustschin <agust@denx.de>
Cc: linux-usb@vger.kernel.org, linux-spi@vger.kernel.org,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org,
gregkh@linuxfoundation.org, atull@kernel.org, mdf@kernel.org
Subject: Re: [PATCH v2 2/3] spi: add FTDI MPSSE SPI controller driver
Date: Wed, 21 Nov 2018 12:42:37 +0000 [thread overview]
Message-ID: <20181121124237.GC8059@sirena.org.uk> (raw)
In-Reply-To: <20181120002821.12794-3-agust@denx.de>
[-- Attachment #1: Type: text/plain, Size: 2706 bytes --]
On Tue, Nov 20, 2018 at 01:28:20AM +0100, Anatolij Gustschin wrote:
> --- a/drivers/spi/Makefile
> +++ b/drivers/spi/Makefile
> @@ -113,6 +113,7 @@ obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o
> obj-$(CONFIG_SPI_XLP) += spi-xlp.o
> obj-$(CONFIG_SPI_XTENSA_XTFPGA) += spi-xtensa-xtfpga.o
> obj-$(CONFIG_SPI_ZYNQMP_GQSPI) += spi-zynqmp-gqspi.o
> +obj-$(CONFIG_SPI_FTDI_MPSSE) += spi-ftdi-mpsse.o
>
> # SPI slave protocol handlers
> obj-$(CONFIG_SPI_SLAVE_TIME) += spi-slave-time.o
Please keep the Makefile sorted.
> +++ b/drivers/spi/spi-ftdi-mpsse.c
> @@ -0,0 +1,673 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * FTDI FT232H MPSSE SPI controller driver
Please make the entire comment block here a C++ one so it looks more
consistent.
> + struct gpiod_lookup_table *lookup[13];
This magic number for the size of the lookup table is not good.
> +static void ftdi_spi_chipselect(struct ftdi_spi *priv, struct spi_device *spi,
> + bool value)
> +{
> + int cs = spi->chip_select;
> +
> + dev_dbg(&priv->master->dev, "%s: CS %d, cs mode %d, val %d\n",
> + __func__, cs, (spi->mode & SPI_CS_HIGH), value);
> +
> + gpiod_set_raw_value_cansleep(priv->cs_gpios[cs], value);
> +}
This is just a gpio chip select - can't it be handled by the core chip
select code?
> + remaining = len;
> + do {
> + stride = min_t(size_t, remaining, SZ_64K - 3);
Rather than having a magic number for the buffer size it would be better
to either have a driver specific constant that's used consistently or
just use sizeof() when it's referenced in the code. That way if the
buffer size is changed nothing will get missed.
> + /* Last transfer with cs_change set, stop keeping CS */
> + if (list_is_last(&t->transfer_list, &msg->transfers)) {
> + keep_cs = true;
> + break;
> + }
> + ftdi_spi_chipselect(priv, spi, !(spi->mode & SPI_CS_HIGH));
> + usleep_range(10, 15);
> + ftdi_spi_chipselect(priv, spi, spi->mode & SPI_CS_HIGH);
I'm not clear what this is intended to do? It's overall not clear to me
that the driver needs to use transfer_one_message and not transfer_one,
the latter keeps more of the code in common code.
> + /* Find max. slave chipselect number */
> + num_cs = pd->spi_info_len;
> + for (i = 0; i < num_cs; i++) {
> + if (max_cs < pd->spi_info[i].chip_select)
> + max_cs = pd->spi_info[i].chip_select;
> + }
> +
> + if (max_cs > 12) {
> + dev_err(dev, "Invalid max CS in platform data: %d\n", max_cs);
> + return -EINVAL;
> + }
> + dev_dbg(dev, "CS count %d, max CS %d\n", num_cs, max_cs);
> + max_cs += 1; /* including CS0 */
Why not just size the array based on the platform data?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2018-11-21 12:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 0:28 [PATCH v2 0/3] Add support for ARRI FPGA configuration Anatolij Gustschin
2018-11-20 0:28 ` [PATCH v2 1/3] usb: misc: add driver for FT232H based FPGA configuration devices Anatolij Gustschin
2018-11-20 0:56 ` Trent Piepho
2018-11-20 14:49 ` Anatolij Gustschin
2018-11-20 0:28 ` [PATCH v2 2/3] spi: add FTDI MPSSE SPI controller driver Anatolij Gustschin
2018-11-21 12:42 ` Mark Brown [this message]
2018-11-27 0:21 ` Anatolij Gustschin
2018-11-28 9:14 ` Mark Brown
2018-11-20 0:28 ` [PATCH v2 3/3] fpga: Add fpga manager driver for ARRI Altera FPP Anatolij Gustschin
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=20181121124237.GC8059@sirena.org.uk \
--to=broonie@kernel.org \
--cc=agust@denx.de \
--cc=atull@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mdf@kernel.org \
/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).