lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACRpkdZcO0er7+7FjiyV9xtLgcybguoy3SAM_gh8c8u6UotDfQ@mail.gmail.com>
Date:	Wed, 22 Aug 2012 13:09:27 +0200
From:	Linus Walleij <linus.walleij@...aro.org>
To:	Roland Stigge <stigge@...com.de>
Cc:	aletes.xgr@...il.com, broonie@...nsource.wolfsonmicro.com,
	grant.likely@...retlab.ca, rob.herring@...xeda.com,
	rob@...dley.net, devicetree-discuss@...ts.ozlabs.org,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	spi-devel-general@...ts.sourceforge.net,
	gabriel.fernandez@...ricsson.com, lee.jones@...aro.org,
	viresh.kumar@...aro.org, sachin.verma@...co
Subject: Re: [PATCH v5 1/2] spi/pl022: Add chip select handling via GPIO

On Tue, Aug 21, 2012 at 6:00 PM, Roland Stigge <stigge@...com.de> wrote:

> This patch adds the ability for the driver to control the chip select directly.
> This enables independence from cs_control callbacks.  Configurable via
> platform_data, to be extended as DT in the following patch.
>
> Based on the initial patch by Alexandre Pereira da Silva <aletes.xgr@...il.com>
>
> Signed-off-by: Roland Stigge <stigge@...com.de>

(...)
>  /*
>   * This macro is used to define some register default values.
> @@ -356,6 +357,8 @@ struct vendor_data {
>   * @sgt_rx: scattertable for the RX transfer
>   * @sgt_tx: scattertable for the TX transfer
>   * @dummypage: a dummy page used for driving data on the bus with DMA
> + * @cur_cs: current chip select (gpio)
> + * @chipselect: list of chipselects (gpios)
>   */
>  struct pl022 {
>         struct amba_device              *adev;
> @@ -389,6 +392,8 @@ struct pl022 {
>         char                            *dummypage;
>         bool                            dma_running;
>  #endif
> +       int cur_cs;
> +       int *chipselect;

Since this is an array, it should be named "chipselects" (plural).

(...)
> @@ -1840,8 +1852,9 @@ static int pl022_setup(struct spi_device
>         chip->xfer_type = chip_info->com_mode;
>         if (!chip_info->cs_control) {
>                 chip->cs_control = null_cs_control;
> -               dev_warn(&spi->dev,
> -                        "chip select function is NULL for this chip\n");
> +               if (!gpio_is_valid(pl022->chipselect[spi->chip_select]))
> +                       dev_warn(&spi->dev,
> +                                "chip select function is NULL for this chip\n");

This dev_warn() is wrong. Alter to a proper warning message.

> @@ -2016,6 +2030,7 @@ pl022_probe(struct amba_device *adev, co
>         pl022->master_info = platform_info;
>         pl022->adev = adev;
>         pl022->vendor = id->data;
> +       pl022->chipselect = (int *)&master[1];

That last thing looks pretty awkward, atleast a comment
explaining what is going on is necessary. I would have done
it like this:

/* Point chipselects to allocated memory beyond the main struct */
pl022->chipselects = (int *) pl022 + sizeof(struct pl022);

Maybe it's simpler to just devm_kzalloc() this array.

Thanks,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ