* [PATCH v2] spi: mediatek: single device does not require cs_gpios @ 2015-11-09 4:14 Nicolas Boichat [not found] ` <1447042491-1199-1-git-send-email-drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Nicolas Boichat @ 2015-11-09 4:14 UTC (permalink / raw) To: Mark Brown Cc: Leilk Liu, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-spi-u79uwXL29TY76Z2rM5mHXA, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Matthias Brugger, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r 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> --- 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; + } } } } -- 2.6.0.rc2.230.g3dd15c0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1447042491-1199-1-git-send-email-drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>]
* Re: [PATCH v2] spi: mediatek: single device does not require cs_gpios [not found] ` <1447042491-1199-1-git-send-email-drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> @ 2015-11-14 2:27 ` lei liu 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 1 sibling, 1 reply; 4+ messages in thread From: lei liu @ 2015-11-14 2:27 UTC (permalink / raw) To: Nicolas Boichat Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Matthias Brugger, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r 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; > + } > } > } > } ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] spi: mediatek: single device does not require cs_gpios 2015-11-14 2:27 ` lei liu @ 2015-11-17 10:49 ` Matthias Brugger 0 siblings, 0 replies; 4+ messages in thread From: Matthias Brugger @ 2015-11-17 10:49 UTC (permalink / raw) To: lei liu, Nicolas Boichat Cc: Mark Brown, linux-spi, linux-kernel, linux-arm-kernel, linux-mediatek On 14/11/15 03:27, lei liu wrote: > 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@chromium.org> > > Acked-by: Leilk Liu <leilk.liu@mediatek.com> > Please make sure this fix get applied to v4.3 as well. Thanks, Matthias ^ permalink raw reply [flat|nested] 4+ messages in thread
* Applied "spi: mediatek: single device does not require cs_gpios" to the spi tree [not found] ` <1447042491-1199-1-git-send-email-drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> 2015-11-14 2:27 ` lei liu @ 2015-11-16 17:51 ` Mark Brown 1 sibling, 0 replies; 4+ messages in thread From: Mark Brown @ 2015-11-16 17:51 UTC (permalink / raw) To: Nicolas Boichat, Leilk Liu, Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA The patch spi: mediatek: single device does not require cs_gpios has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 98c8dccf2b2771fb622d449b2ec1604fc5d260e5 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat <drinkcat-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> Date: Mon, 9 Nov 2015 12:14:51 +0800 Subject: [PATCH] spi: mediatek: single device does not require cs_gpios 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> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> --- 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 563954a61424..7840067062a8 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; + } } } } -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-17 10:49 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
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).