linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: lei liu <leilk.liu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
To: Nicolas Boichat <drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Matthias Brugger
	<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH v2] spi: mediatek: single device does not require cs_gpios
Date: Sat, 14 Nov 2015 10:27:19 +0800	[thread overview]
Message-ID: <1447468039.27169.1.camel@mhfsdcap03> (raw)
In-Reply-To: <1447042491-1199-1-git-send-email-drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

On Mon, 2015-11-09 at 12:14 +0800, Nicolas Boichat wrote:
> When only one device is present, it is not necessary to specify
> cs_gpios, as the CS line can be controlled by the hardware
> module.
> 
> Without this patch, older device tree bindings used before
> 37457607 "spi: mediatek: mt8173 spi multiple devices support"
> would cause a panic on boot. This fixes the crash, and
> re-introduces backward compatibility.
> 
> Signed-off-by: Nicolas Boichat <drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Acked-by: Leilk Liu <leilk.liu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

> ---
> 
> v2: Use gpio_is_valid()
> 
> Applies on top of broonie/spi.git/for-next.
> 
>  drivers/spi/spi-mt65xx.c | 26 ++++++++++++++++++--------
>  1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
> index 563954a..7840067 100644
> --- a/drivers/spi/spi-mt65xx.c
> +++ b/drivers/spi/spi-mt65xx.c
> @@ -410,7 +410,7 @@ static int mtk_spi_setup(struct spi_device *spi)
>  	if (!spi->controller_data)
>  		spi->controller_data = (void *)&mtk_default_chip_info;
>  
> -	if (mdata->dev_comp->need_pad_sel)
> +	if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio))
>  		gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
>  
>  	return 0;
> @@ -632,13 +632,23 @@ static int mtk_spi_probe(struct platform_device *pdev)
>  			goto err_put_master;
>  		}
>  
> -		for (i = 0; i < master->num_chipselect; i++) {
> -			ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i],
> -						dev_name(&pdev->dev));
> -			if (ret) {
> -				dev_err(&pdev->dev,
> -					"can't get CS GPIO %i\n", i);
> -				goto err_put_master;
> +		if (!master->cs_gpios && master->num_chipselect > 1) {
> +			dev_err(&pdev->dev,
> +				"cs_gpios not specified and num_chipselect > 1\n");
> +			ret = -EINVAL;
> +			goto err_put_master;
> +		}
> +
> +		if (master->cs_gpios) {
> +			for (i = 0; i < master->num_chipselect; i++) {
> +				ret = devm_gpio_request(&pdev->dev,
> +							master->cs_gpios[i],
> +							dev_name(&pdev->dev));
> +				if (ret) {
> +					dev_err(&pdev->dev,
> +						"can't get CS GPIO %i\n", i);
> +					goto err_put_master;
> +				}
>  			}
>  		}
>  	}

  parent reply	other threads:[~2015-11-14  2:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  4:14 [PATCH v2] spi: mediatek: single device does not require cs_gpios Nicolas Boichat
     [not found] ` <1447042491-1199-1-git-send-email-drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-11-14  2:27   ` lei liu [this message]
2015-11-17 10:49     ` Matthias Brugger
2015-11-16 17:51   ` Applied "spi: mediatek: single device does not require cs_gpios" to the spi tree 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=1447468039.27169.1.camel@mhfsdcap03 \
    --to=leilk.liu-nus5lvnupcjwk0htik3j/w@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).