SPI GPIO improvements
cover SPI GPIO improvements
Everyone:
This series contains a fix ("spi: Don't call spi_get_gpio_descs() before device name is set) and improvements for SPI GPIO and driver I made while looking at that code recently. Hopefully each patch is self-explanatory.
Feedback is welcome!
Thanks,
Andrey Smirnov
Andrey Smirnov (12):
spi: gpio: Drop unused spi_to_pdata()
spi: gpio: Add local struct device pointer in spi_gpio_probe()
spi: gpio: Add local struct spi_bitbang pointer in spi_gpio_probe()
spi: gpio: Simplify SPI_MASTER_NO_TX check in spi_gpio_probe()
spi: gpio: Drop unused pdata copy in struct spi_gpio
spi: gpio: Don't request CS GPIO in DT use-case
spi: Don't call spi_get_gpio_descs() before device name is set
spi: gpio: Drop mflags argument from spi_gpio_request()
spi: gpio: Drop unused pdev field in struct spi_gpio
spi: gpio: Make sure spi_master_put() is called in every error path
spi: bitbang: Introduce spi_bitbang_init()
spi: gpio: Use devm_spi_register_master()
drivers/spi/spi-bitbang.c | 66 ++++++---- drivers/spi/spi-gpio.c | 226 ++++++++++++++------------------ drivers/spi/spi.c | 37 +++--- include/linux/spi/spi_bitbang.h | 1 + 4 files changed, 154 insertions(+), 176 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/12 spi: gpio: Drop unused spi_to_pdata()
Spi_to_pdata() is not used anywhere in the code. Drop it.
--- drivers/spi/spi-gpio.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/spi/spi-gpio.c +0 -6
@@ -96,12 +96,6 @@ spi_to_spi_gpio(const struct spi_device *spi)return spi_gpio; } -static inline struct spi_gpio_platform_data *__pure -spi_to_pdata (const struct spi_device *spi) -{ -return &spi_to_spi_gpio (spi)->pdata; -} -/* These helpers are in turn called by the bitbang inlines */ static inline void setsck (const struct spi_device *spi,int is_on) {
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Drop unused spi_to_pdata()" to the spi tree
The patch
spi: gpio: Drop unused spi_to_pdata()
has been applied to the spi tree at
https://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
Quoted 1 line
From
4d9f8fed42694016b015cbfe201effe8aff0d1b3Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:22 -0700
Subject: [PATCH] spi: gpio: Drop unused spi_to_pdata()
Spi_to_pdata() is not used anywhere in the code. Drop it.
--- drivers/spi/spi-gpio.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/spi/spi-gpio.c +0 -6
@@ -96,12 +96,6 @@ spi_to_spi_gpio(const struct spi_device *spi)return spi_gpio; } -static inline struct spi_gpio_platform_data *__pure -spi_to_pdata (const struct spi_device *spi) -{ -return &spi_to_spi_gpio (spi)->pdata; -} -/* These helpers are in turn called by the bitbang inlines */ static inline void setsck (const struct spi_device *spi,int is_on) {
Signature · 1 line
2.20.1
PATCH 2/12 spi: gpio: Add local struct device pointer in spi_gpio_probe()
In reply to Andrey SmirnovUse a local "struct device *dev" in spi_gpio_probe() for brevity. No functional change intended.
--- drivers/spi/spi-gpio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/spi/spi-gpio.c +6 -5
@@ -379,6 +379,7 @@ static int spi_gpio_probe(struct platform_device *pdev)struct spi_master *master;struct spi_gpio *spi_gpio;struct spi_gpio_platform_data *pdata; +struct device *dev = &pdev->dev;u16 master_flags =0 ;bool use_of =0 ;
@@ -388,19 +389,19 @@ static int spi_gpio_probe(struct platform_device *pdev)if (status >0 ) use_of =1 ; - pdata =dev_get_platdata (&pdev->dev); + pdata =dev_get_platdata (dev);#ifdef GENERIC_BITBANG if (!pdata || (!use_of && !pdata->num_chipselect))return -ENODEV ;#endif - master =spi_alloc_master (&pdev->dev,sizeof (*spi_gpio)); + master =spi_alloc_master (dev,sizeof (*spi_gpio));if (!master)return -ENOMEM ; spi_gpio =spi_master_get_devdata (master); - spi_gpio->cs_gpios =devm_kcalloc (&pdev->dev, + spi_gpio->cs_gpios =devm_kcalloc (dev, pdata->num_chipselect,sizeof (*spi_gpio->cs_gpios),GFP_KERNEL );
@@ -416,7 +417,7 @@ static int spi_gpio_probe(struct platform_device *pdev)if (pdata) spi_gpio->pdata = *pdata; - status =spi_gpio_request (&pdev->dev, spi_gpio, + status =spi_gpio_request (dev, spi_gpio, pdata->num_chipselect, &master_flags);if (status)return status;
@@ -431,7 +432,7 @@ static int spi_gpio_probe(struct platform_device *pdev) master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup;#ifdef CONFIG_OF - master->dev.of_node = pdev->dev.of_node; + master->dev.of_node = dev->of_node;#endif spi_gpio->bitbang.master = master;
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Add local struct device pointer in spi_gpio_probe()" to the spi tree
The patch
spi: gpio: Add local struct device pointer in spi_gpio_probe()
has been applied to the spi tree at
https://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
Quoted 1 line
From
96cad6d78f7f8feac456002020971cba6073bff9Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:23 -0700
Subject: [PATCH] spi: gpio: Add local struct device pointer in
spi_gpio_probe()
Use a local "struct device *dev" in spi_gpio_probe() for brevity. No functional change intended.
--- drivers/spi/spi-gpio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/spi/spi-gpio.c +6 -5
@@ -379,6 +379,7 @@ static int spi_gpio_probe(struct platform_device *pdev)struct spi_master *master;struct spi_gpio *spi_gpio;struct spi_gpio_platform_data *pdata; +struct device *dev = &pdev->dev;u16 master_flags =0 ;bool use_of =0 ;
@@ -388,19 +389,19 @@ static int spi_gpio_probe(struct platform_device *pdev)if (status >0 ) use_of =1 ; - pdata =dev_get_platdata (&pdev->dev); + pdata =dev_get_platdata (dev);#ifdef GENERIC_BITBANG if (!pdata || (!use_of && !pdata->num_chipselect))return -ENODEV ;#endif - master =spi_alloc_master (&pdev->dev,sizeof (*spi_gpio)); + master =spi_alloc_master (dev,sizeof (*spi_gpio));if (!master)return -ENOMEM ; spi_gpio =spi_master_get_devdata (master); - spi_gpio->cs_gpios =devm_kcalloc (&pdev->dev, + spi_gpio->cs_gpios =devm_kcalloc (dev, pdata->num_chipselect,sizeof (*spi_gpio->cs_gpios),GFP_KERNEL );
@@ -416,7 +417,7 @@ static int spi_gpio_probe(struct platform_device *pdev)if (pdata) spi_gpio->pdata = *pdata; - status =spi_gpio_request (&pdev->dev, spi_gpio, + status =spi_gpio_request (dev, spi_gpio, pdata->num_chipselect, &master_flags);if (status)return status;
@@ -431,7 +432,7 @@ static int spi_gpio_probe(struct platform_device *pdev) master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup;#ifdef CONFIG_OF - master->dev.of_node = pdev->dev.of_node; + master->dev.of_node = dev->of_node;#endif spi_gpio->bitbang.master = master;
Signature · 1 line
2.20.1
PATCH 3/12 spi: gpio: Add local struct spi_bitbang pointer in spi_gpio_probe()
In reply to Andrey SmirnovUse a local "struct spi_bitbang *bb" in spi_gpio_probe() for brevity. No functional change intended.
--- drivers/spi/spi-gpio.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/spi/spi-gpio.c +14 -13
@@ -380,6 +380,7 @@ static int spi_gpio_probe(struct platform_device *pdev)struct spi_gpio *spi_gpio;struct spi_gpio_platform_data *pdata;struct device *dev = &pdev->dev; +struct spi_bitbang *bb;u16 master_flags =0 ;bool use_of =0 ;
@@ -434,23 +435,23 @@ static int spi_gpio_probe(struct platform_device *pdev)#ifdef CONFIG_OF master->dev.of_node = dev->of_node;#endif - - spi_gpio->bitbang.master = master; - spi_gpio->bitbang.chipselect = spi_gpio_chipselect; - spi_gpio->bitbang.set_line_direction = spi_gpio_set_direction; + bb = &spi_gpio->bitbang; + bb->master = master; + bb->chipselect = spi_gpio_chipselect; + bb->set_line_direction = spi_gpio_set_direction;if ((master_flags &SPI_MASTER_NO_TX ) ==0 ) { - spi_gpio->bitbang.txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; - spi_gpio->bitbang.txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; - spi_gpio->bitbang.txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; - spi_gpio->bitbang.txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; + bb->txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; + bb->txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; + bb->txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; + bb->txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; }else { - spi_gpio->bitbang.txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; - spi_gpio->bitbang.txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; - spi_gpio->bitbang.txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2; - spi_gpio->bitbang.txrx_word[SPI_MODE_3 ] = spi_gpio_spec_txrx_word_mode3; + bb->txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; + bb->txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; + bb->txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2; + bb->txrx_word[SPI_MODE_3 ] = spi_gpio_spec_txrx_word_mode3; } - spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer; + bb->setup_transfer = spi_bitbang_setup_transfer; status =spi_bitbang_start (&spi_gpio->bitbang);if (status)
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Add local struct spi_bitbang pointer in spi_gpio_probe()" to the spi tree
The patch
spi: gpio: Add local struct spi_bitbang pointer in spi_gpio_probe()
has been applied to the spi tree at
https://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
Quoted 1 line
From
15dd0e9e002ad39d93a0ff6935bc619d42ce3551Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:24 -0700
Subject: [PATCH] spi: gpio: Add local struct spi_bitbang pointer in
spi_gpio_probe()
Use a local "struct spi_bitbang *bb" in spi_gpio_probe() for brevity. No functional change intended.
--- drivers/spi/spi-gpio.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/spi/spi-gpio.c +14 -13
@@ -380,6 +380,7 @@ static int spi_gpio_probe(struct platform_device *pdev)struct spi_gpio *spi_gpio;struct spi_gpio_platform_data *pdata;struct device *dev = &pdev->dev; +struct spi_bitbang *bb;u16 master_flags =0 ;bool use_of =0 ;
@@ -434,23 +435,23 @@ static int spi_gpio_probe(struct platform_device *pdev)#ifdef CONFIG_OF master->dev.of_node = dev->of_node;#endif - - spi_gpio->bitbang.master = master; - spi_gpio->bitbang.chipselect = spi_gpio_chipselect; - spi_gpio->bitbang.set_line_direction = spi_gpio_set_direction; + bb = &spi_gpio->bitbang; + bb->master = master; + bb->chipselect = spi_gpio_chipselect; + bb->set_line_direction = spi_gpio_set_direction;if ((master_flags &SPI_MASTER_NO_TX ) ==0 ) { - spi_gpio->bitbang.txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; - spi_gpio->bitbang.txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; - spi_gpio->bitbang.txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; - spi_gpio->bitbang.txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; + bb->txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; + bb->txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; + bb->txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; + bb->txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; }else { - spi_gpio->bitbang.txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; - spi_gpio->bitbang.txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; - spi_gpio->bitbang.txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2; - spi_gpio->bitbang.txrx_word[SPI_MODE_3 ] = spi_gpio_spec_txrx_word_mode3; + bb->txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; + bb->txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; + bb->txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2; + bb->txrx_word[SPI_MODE_3 ] = spi_gpio_spec_txrx_word_mode3; } - spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer; + bb->setup_transfer = spi_bitbang_setup_transfer; status =spi_bitbang_start (&spi_gpio->bitbang);if (status)
Signature · 1 line
2.20.1
PATCH 4/12 spi: gpio: Simplify SPI_MASTER_NO_TX check in spi_gpio_probe()
In reply to Andrey SmirnovSwap branches of the if statement in order to simplify it's logical condition being checked. No functional change intended.
--- drivers/spi/spi-gpio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/spi/spi-gpio.c +6 -6
@@ -440,16 +440,16 @@ static int spi_gpio_probe(struct platform_device *pdev) bb->chipselect = spi_gpio_chipselect; bb->set_line_direction = spi_gpio_set_direction; -if ((master_flags &SPI_MASTER_NO_TX ) ==0 ) { - bb->txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; - bb->txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; - bb->txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; - bb->txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; - }else { +if (master_flags &SPI_MASTER_NO_TX ) { bb->txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; bb->txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; bb->txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2; bb->txrx_word[SPI_MODE_3 ] = spi_gpio_spec_txrx_word_mode3; + }else { + bb->txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; + bb->txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; + bb->txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; + bb->txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; } bb->setup_transfer = spi_bitbang_setup_transfer;
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Simplify SPI_MASTER_NO_TX check in spi_gpio_probe()" to the spi tree
The patch
spi: gpio: Simplify SPI_MASTER_NO_TX check in spi_gpio_probe()
has been applied to the spi tree at
https://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
Quoted 1 line
From
68cd9dc2cc00b2ab0dbcdbbec446d5bdc56fea4bMon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:25 -0700
Subject: [PATCH] spi: gpio: Simplify SPI_MASTER_NO_TX check in
spi_gpio_probe()
Swap branches of the if statement in order to simplify it's logical condition being checked. No functional change intended.
--- drivers/spi/spi-gpio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/spi/spi-gpio.c +6 -6
@@ -440,16 +440,16 @@ static int spi_gpio_probe(struct platform_device *pdev) bb->chipselect = spi_gpio_chipselect; bb->set_line_direction = spi_gpio_set_direction; -if ((master_flags &SPI_MASTER_NO_TX ) ==0 ) { - bb->txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; - bb->txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; - bb->txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; - bb->txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; - }else { +if (master_flags &SPI_MASTER_NO_TX ) { bb->txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; bb->txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; bb->txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2; bb->txrx_word[SPI_MODE_3 ] = spi_gpio_spec_txrx_word_mode3; + }else { + bb->txrx_word[SPI_MODE_0 ] = spi_gpio_txrx_word_mode0; + bb->txrx_word[SPI_MODE_1 ] = spi_gpio_txrx_word_mode1; + bb->txrx_word[SPI_MODE_2 ] = spi_gpio_txrx_word_mode2; + bb->txrx_word[SPI_MODE_3 ] = spi_gpio_txrx_word_mode3; } bb->setup_transfer = spi_bitbang_setup_transfer;
Signature · 1 line
2.20.1
PATCH 5/12 spi: gpio: Drop unused pdata copy in struct spi_gpio
In reply to Andrey SmirnovDrop unused pdata copy in struct spi_gpio. No functional change intended.
--- drivers/spi/spi-gpio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/spi/spi-gpio.c +0 -3
@@ -42,7 +42,6 @@struct spi_gpio {struct spi_bitbang bitbang; -struct spi_gpio_platform_data pdata;struct platform_device *pdev;struct gpio_desc *sck;struct gpio_desc *miso;
@@ -415,8 +414,6 @@ static int spi_gpio_probe(struct platform_device *pdev) spi_gpio->has_cs = !!pdata->num_chipselect; spi_gpio->pdev = pdev; -if (pdata) - spi_gpio->pdata = *pdata; status =spi_gpio_request (dev, spi_gpio, pdata->num_chipselect, &master_flags);
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Drop unused pdata copy in struct spi_gpio" to the spi tree
The patch
spi: gpio: Drop unused pdata copy in struct spi_gpio
has been applied to the spi tree at
https://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
Quoted 1 line
From
703b476695237dda54233d2dadb37d2d49de23cfMon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:26 -0700
Subject: [PATCH] spi: gpio: Drop unused pdata copy in struct spi_gpio
Drop unused pdata copy in struct spi_gpio. No functional change intended.
--- drivers/spi/spi-gpio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/spi/spi-gpio.c +0 -3
@@ -42,7 +42,6 @@struct spi_gpio {struct spi_bitbang bitbang; -struct spi_gpio_platform_data pdata;struct platform_device *pdev;struct gpio_desc *sck;struct gpio_desc *miso;
@@ -415,8 +414,6 @@ static int spi_gpio_probe(struct platform_device *pdev) spi_gpio->has_cs = !!pdata->num_chipselect; spi_gpio->pdev = pdev; -if (pdata) - spi_gpio->pdata = *pdata; status =spi_gpio_request (dev, spi_gpio, pdata->num_chipselect, &master_flags);
Signature · 1 line
2.20.1
PATCH 6/12 spi: gpio: Don't request CS GPIO in DT use-case
In reply to Andrey SmirnovDT use-case already relies on SPI core to control CS (requested by of_spi_register_master() and controlled spi_set_cs()), so there's no need to try to request those GPIO in spi-gpio code. Change the code such that spi-gpio's CS related code is only used if device is probed via pdata.
--- drivers/spi/spi-gpio.c | 134 ++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 75 deletions(-)
drivers/spi/spi-gpio.c +59 -75
@@ -47,7 +47,6 @@ struct spi_gpio {struct gpio_desc *miso;struct gpio_desc *mosi;struct gpio_desc **cs_gpios; -bool has_cs; };/*----------------------------------------------------------------------*/
@@ -217,7 +216,7 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active)gpiod_set_value_cansleep (spi_gpio->sck, spi->mode &SPI_CPOL );/* Drive chip select line, if we have one */ -if (spi_gpio->has_cs) { +if (spi_gpio->cs_gpios) {struct gpio_desc *cs = spi_gpio->cs_gpios[spi->chip_select];/* SPI chip selects are normally active-low */
@@ -235,10 +234,12 @@ static int spi_gpio_setup(struct spi_device *spi)* The CS GPIOs have already been * initialized from the descriptor lookup. */ - cs = spi_gpio->cs_gpios[spi->chip_select]; -if (!spi->controller_state && cs) - status =gpiod_direction_output (cs, - !(spi->mode &SPI_CS_HIGH )); +if (spi_gpio->cs_gpios) { + cs = spi_gpio->cs_gpios[spi->chip_select]; +if (!spi->controller_state && cs) + status =gpiod_direction_output (cs, + !(spi->mode &SPI_CS_HIGH )); + }if (!status) status =spi_bitbang_setup (spi);
@@ -291,11 +292,8 @@ static void spi_gpio_cleanup(struct spi_device *spi)*/ static int spi_gpio_request (struct device *dev,struct spi_gpio *spi_gpio, -unsigned int num_chipselects,u16 *mflags) { -int i; - spi_gpio->mosi =devm_gpiod_get_optional (dev,"mosi" ,GPIOD_OUT_LOW );if (IS_ERR (spi_gpio->mosi))return PTR_ERR (spi_gpio->mosi);
@@ -316,13 +314,6 @@ static int spi_gpio_request(struct device *dev,if (IS_ERR (spi_gpio->sck))return PTR_ERR (spi_gpio->sck); -for (i =0 ; i < num_chipselects; i++) { - spi_gpio->cs_gpios[i] =devm_gpiod_get_index (dev,"cs" , - i,GPIOD_OUT_HIGH ); -if (IS_ERR (spi_gpio->cs_gpios[i])) -return PTR_ERR (spi_gpio->cs_gpios[i]); - } -return 0 ; }
@@ -333,90 +324,87 @@ static const struct of_device_id spi_gpio_dt_ids[] = { };MODULE_DEVICE_TABLE (of, spi_gpio_dt_ids); -static int spi_gpio_probe_dt (struct platform_device *pdev) +static int spi_gpio_probe_dt (struct platform_device *pdev, +struct spi_master *master) { -int ret; -u32 tmp; -struct spi_gpio_platform_data *pdata; -struct device_node *np = pdev->dev.of_node; -const struct of_device_id *of_id = -of_match_device (spi_gpio_dt_ids, &pdev->dev); - -if (!of_id) -return 0 ; + master->dev.of_node = pdev->dev.of_node; + master->use_gpio_descriptors = true; - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; +return 0 ; +} +#else +static inline int spi_gpio_probe_dt (struct platform_device *pdev, +struct spi_master *master) +{ +return 0 ; +} +#endif +static int spi_gpio_probe_pdata (struct platform_device *pdev, +struct spi_master *master) +{ +struct device *dev = &pdev->dev; +struct spi_gpio_platform_data *pdata =dev_get_platdata (dev); +struct spi_gpio *spi_gpio =spi_master_get_devdata (master); +int i; - ret =of_property_read_u32 (np,"num-chipselects" , &tmp); -if (ret <0 ) { -dev_err (&pdev->dev,"num-chipselects property not found\n" ); - goto error_free; - } +#ifdef GENERIC_BITBANG +if (!pdata || !pdata->num_chipselect) +return -ENODEV ; +#endif +/* +* The master needs to think there is a chipselect even if not +* connected +*/ + master->num_chipselect = pdata->num_chipselect ?:1 ; - pdata->num_chipselect = tmp; - pdev->dev.platform_data = pdata; + spi_gpio->cs_gpios =devm_kcalloc (dev, master->num_chipselect, +sizeof (*spi_gpio->cs_gpios), +GFP_KERNEL ); +if (!spi_gpio->cs_gpios) +return -ENOMEM ; -return 1 ; +for (i =0 ; i < master->num_chipselect; i++) { + spi_gpio->cs_gpios[i] =devm_gpiod_get_index (dev,"cs" , i, +GPIOD_OUT_HIGH ); +if (IS_ERR (spi_gpio->cs_gpios[i])) +return PTR_ERR (spi_gpio->cs_gpios[i]); + } -error_free: -devm_kfree (&pdev->dev, pdata); -return ret; -} -#else -static inline int spi_gpio_probe_dt (struct platform_device *pdev) -{return 0 ; } -#endif static int spi_gpio_probe (struct platform_device *pdev) {int status;struct spi_master *master;struct spi_gpio *spi_gpio; -struct spi_gpio_platform_data *pdata;struct device *dev = &pdev->dev;struct spi_bitbang *bb; +const struct of_device_id *of_id;u16 master_flags =0 ; -bool use_of =0 ; - - status =spi_gpio_probe_dt (pdev); -if (status <0 ) -return status; -if (status >0 ) - use_of =1 ; - pdata =dev_get_platdata (dev); -#ifdef GENERIC_BITBANG -if (!pdata || (!use_of && !pdata->num_chipselect)) -return -ENODEV ; -#endif + of_id =of_match_device (spi_gpio_dt_ids, &pdev->dev); master =spi_alloc_master (dev,sizeof (*spi_gpio));if (!master)return -ENOMEM ; - spi_gpio =spi_master_get_devdata (master); +if (of_id) + status =spi_gpio_probe_dt (pdev, master); +else + status =spi_gpio_probe_pdata (pdev, master); - spi_gpio->cs_gpios =devm_kcalloc (dev, - pdata->num_chipselect, -sizeof (*spi_gpio->cs_gpios), -GFP_KERNEL ); -if (!spi_gpio->cs_gpios) -return -ENOMEM ; +if (status) +return status; -platform_set_drvdata (pdev, spi_gpio); + spi_gpio =spi_master_get_devdata (master); -/* Determine if we have chip selects connected */ - spi_gpio->has_cs = !!pdata->num_chipselect; +platform_set_drvdata (pdev, spi_gpio); spi_gpio->pdev = pdev; - status =spi_gpio_request (dev, spi_gpio, - pdata->num_chipselect, &master_flags); + status =spi_gpio_request (dev, spi_gpio, &master_flags);if (status)return status;
@@ -425,13 +413,9 @@ static int spi_gpio_probe(struct platform_device *pdev)SPI_CS_HIGH ; master->flags = master_flags; master->bus_num = pdev->id; -/* The master needs to think there is a chipselect even if not connected */ - master->num_chipselect = spi_gpio->has_cs ? pdata->num_chipselect :1 ; master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup; -#ifdef CONFIG_OF - master->dev.of_node = dev->of_node; -#endif + bb = &spi_gpio->bitbang; bb->master = master; bb->chipselect = spi_gpio_chipselect;
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Don't request CS GPIO in DT use-case" to the spi tree
The patch
spi: gpio: Don't request CS GPIO in DT use-case
has been applied to the spi tree at
https://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
Quoted 1 line
From
249e2632dcd0509b8f8f296f5aabf4d48dfd6da8Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:27 -0700
Subject: [PATCH] spi: gpio: Don't request CS GPIO in DT use-case
DT use-case already relies on SPI core to control CS (requested by of_spi_register_master() and controlled spi_set_cs()), so there's no need to try to request those GPIO in spi-gpio code. Change the code such that spi-gpio's CS related code is only used if device is probed via pdata.
--- drivers/spi/spi-gpio.c | 134 ++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 75 deletions(-)
drivers/spi/spi-gpio.c +59 -75
@@ -46,7 +46,6 @@ struct spi_gpio {struct gpio_desc *miso;struct gpio_desc *mosi;struct gpio_desc **cs_gpios; -bool has_cs; };/*----------------------------------------------------------------------*/
@@ -216,7 +215,7 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active)gpiod_set_value_cansleep (spi_gpio->sck, spi->mode &SPI_CPOL );/* Drive chip select line, if we have one */ -if (spi_gpio->has_cs) { +if (spi_gpio->cs_gpios) {struct gpio_desc *cs = spi_gpio->cs_gpios[spi->chip_select];/* SPI chip selects are normally active-low */
@@ -234,10 +233,12 @@ static int spi_gpio_setup(struct spi_device *spi)* The CS GPIOs have already been * initialized from the descriptor lookup. */ - cs = spi_gpio->cs_gpios[spi->chip_select]; -if (!spi->controller_state && cs) - status =gpiod_direction_output (cs, - !(spi->mode &SPI_CS_HIGH )); +if (spi_gpio->cs_gpios) { + cs = spi_gpio->cs_gpios[spi->chip_select]; +if (!spi->controller_state && cs) + status =gpiod_direction_output (cs, + !(spi->mode &SPI_CS_HIGH )); + }if (!status) status =spi_bitbang_setup (spi);
@@ -290,11 +291,8 @@ static void spi_gpio_cleanup(struct spi_device *spi)*/ static int spi_gpio_request (struct device *dev,struct spi_gpio *spi_gpio, -unsigned int num_chipselects,u16 *mflags) { -int i; - spi_gpio->mosi =devm_gpiod_get_optional (dev,"mosi" ,GPIOD_OUT_LOW );if (IS_ERR (spi_gpio->mosi))return PTR_ERR (spi_gpio->mosi);
@@ -315,13 +313,6 @@ static int spi_gpio_request(struct device *dev,if (IS_ERR (spi_gpio->sck))return PTR_ERR (spi_gpio->sck); -for (i =0 ; i < num_chipselects; i++) { - spi_gpio->cs_gpios[i] =devm_gpiod_get_index (dev,"cs" , - i,GPIOD_OUT_HIGH ); -if (IS_ERR (spi_gpio->cs_gpios[i])) -return PTR_ERR (spi_gpio->cs_gpios[i]); - } -return 0 ; }
@@ -332,90 +323,87 @@ static const struct of_device_id spi_gpio_dt_ids[] = { };MODULE_DEVICE_TABLE (of, spi_gpio_dt_ids); -static int spi_gpio_probe_dt (struct platform_device *pdev) +static int spi_gpio_probe_dt (struct platform_device *pdev, +struct spi_master *master) { -int ret; -u32 tmp; -struct spi_gpio_platform_data *pdata; -struct device_node *np = pdev->dev.of_node; -const struct of_device_id *of_id = -of_match_device (spi_gpio_dt_ids, &pdev->dev); - -if (!of_id) -return 0 ; + master->dev.of_node = pdev->dev.of_node; + master->use_gpio_descriptors = true; - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); -if (!pdata) -return -ENOMEM ; +return 0 ; +} +#else +static inline int spi_gpio_probe_dt (struct platform_device *pdev, +struct spi_master *master) +{ +return 0 ; +} +#endif +static int spi_gpio_probe_pdata (struct platform_device *pdev, +struct spi_master *master) +{ +struct device *dev = &pdev->dev; +struct spi_gpio_platform_data *pdata =dev_get_platdata (dev); +struct spi_gpio *spi_gpio =spi_master_get_devdata (master); +int i; - ret =of_property_read_u32 (np,"num-chipselects" , &tmp); -if (ret <0 ) { -dev_err (&pdev->dev,"num-chipselects property not found\n" ); - goto error_free; - } +#ifdef GENERIC_BITBANG +if (!pdata || !pdata->num_chipselect) +return -ENODEV ; +#endif +/* +* The master needs to think there is a chipselect even if not +* connected +*/ + master->num_chipselect = pdata->num_chipselect ?:1 ; - pdata->num_chipselect = tmp; - pdev->dev.platform_data = pdata; + spi_gpio->cs_gpios =devm_kcalloc (dev, master->num_chipselect, +sizeof (*spi_gpio->cs_gpios), +GFP_KERNEL ); +if (!spi_gpio->cs_gpios) +return -ENOMEM ; -return 1 ; +for (i =0 ; i < master->num_chipselect; i++) { + spi_gpio->cs_gpios[i] =devm_gpiod_get_index (dev,"cs" , i, +GPIOD_OUT_HIGH ); +if (IS_ERR (spi_gpio->cs_gpios[i])) +return PTR_ERR (spi_gpio->cs_gpios[i]); + } -error_free: -devm_kfree (&pdev->dev, pdata); -return ret; -} -#else -static inline int spi_gpio_probe_dt (struct platform_device *pdev) -{return 0 ; } -#endif static int spi_gpio_probe (struct platform_device *pdev) {int status;struct spi_master *master;struct spi_gpio *spi_gpio; -struct spi_gpio_platform_data *pdata;struct device *dev = &pdev->dev;struct spi_bitbang *bb; +const struct of_device_id *of_id;u16 master_flags =0 ; -bool use_of =0 ; - - status =spi_gpio_probe_dt (pdev); -if (status <0 ) -return status; -if (status >0 ) - use_of =1 ; - pdata =dev_get_platdata (dev); -#ifdef GENERIC_BITBANG -if (!pdata || (!use_of && !pdata->num_chipselect)) -return -ENODEV ; -#endif + of_id =of_match_device (spi_gpio_dt_ids, &pdev->dev); master =spi_alloc_master (dev,sizeof (*spi_gpio));if (!master)return -ENOMEM ; - spi_gpio =spi_master_get_devdata (master); +if (of_id) + status =spi_gpio_probe_dt (pdev, master); +else + status =spi_gpio_probe_pdata (pdev, master); - spi_gpio->cs_gpios =devm_kcalloc (dev, - pdata->num_chipselect, -sizeof (*spi_gpio->cs_gpios), -GFP_KERNEL ); -if (!spi_gpio->cs_gpios) -return -ENOMEM ; +if (status) +return status; -platform_set_drvdata (pdev, spi_gpio); + spi_gpio =spi_master_get_devdata (master); -/* Determine if we have chip selects connected */ - spi_gpio->has_cs = !!pdata->num_chipselect; +platform_set_drvdata (pdev, spi_gpio); spi_gpio->pdev = pdev; - status =spi_gpio_request (dev, spi_gpio, - pdata->num_chipselect, &master_flags); + status =spi_gpio_request (dev, spi_gpio, &master_flags);if (status)return status;
@@ -424,13 +412,9 @@ static int spi_gpio_probe(struct platform_device *pdev)SPI_CS_HIGH ; master->flags = master_flags; master->bus_num = pdev->id; -/* The master needs to think there is a chipselect even if not connected */ - master->num_chipselect = spi_gpio->has_cs ? pdata->num_chipselect :1 ; master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup; -#ifdef CONFIG_OF - master->dev.of_node = dev->of_node; -#endif + bb = &spi_gpio->bitbang; bb->master = master; bb->chipselect = spi_gpio_chipselect;
Signature · 1 line
2.20.1
PATCH 7/12 spi: Don't call spi_get_gpio_descs() before device name is set
In reply to Andrey SmirnovMove code calling spi_get_gpio_descs() to happen after ctlr->dev's name is set in order to have proper GPIO consumer names.
Before:
cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/40049000.gpio, vf610-gpio:
gpio-6 ( |regulator-usb0-vbus ) out lo
gpiochip1: GPIOs 32-63, parent: platform/4004a000.gpio, vf610-gpio:
gpio-36 ( |scl ) in hi gpio-37 ( |sda ) in hi gpio-40 ( |(null) CS1 ) out lo gpio-41 ( |(null) CS0 ) out lo ACTIVE LOW gpio-42 ( |miso ) in hi gpio-43 ( |mosi ) in lo gpio-44 ( |sck ) out lo
After:
cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/40049000.gpio, vf610-gpio:
gpio-6 ( |regulator-usb0-vbus ) out lo
gpiochip1: GPIOs 32-63, parent: platform/4004a000.gpio, vf610-gpio:
gpio-36 ( |scl ) in hi gpio-37 ( |sda ) in hi gpio-40 ( |spi0 CS1 ) out lo gpio-41 ( |spi0 CS0 ) out lo ACTIVE LOW gpio-42 ( |miso ) in hi gpio-43 ( |mosi ) in lo gpio-44 ( |sck ) out lo
--- drivers/spi/spi.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/spi/spi.c +19 -18
@@ -2279,24 +2279,6 @@ int spi_register_controller(struct spi_controller *ctlr)if (status)return status; -if (!spi_controller_is_slave (ctlr)) { -if (ctlr->use_gpio_descriptors) { - status =spi_get_gpio_descs (ctlr); -if (status) -return status; -/* -* A controller using GPIO descriptors always -* supports SPI_CS_HIGH if need be. -*/ - ctlr->mode_bits |=SPI_CS_HIGH ; - }else { -/* Legacy code path for GPIOs from DT */ - status =of_spi_register_master (ctlr); -if (status) -return status; - } - } -/* even if it's just one always-selected device, there must * be at least one chipselect */
@@ -2353,6 +2335,25 @@ int spi_register_controller(struct spi_controller *ctlr)* registration fails if the bus ID is in use. */ dev_set_name (&ctlr->dev,"spi%u" , ctlr->bus_num); + +if (!spi_controller_is_slave (ctlr)) { +if (ctlr->use_gpio_descriptors) { + status =spi_get_gpio_descs (ctlr); +if (status) +return status; +/* +* A controller using GPIO descriptors always +* supports SPI_CS_HIGH if need be. +*/ + ctlr->mode_bits |=SPI_CS_HIGH ; + }else { +/* Legacy code path for GPIOs from DT */ + status =of_spi_register_master (ctlr); +if (status) +return status; + } + } + status =device_add (&ctlr->dev);if (status <0 ) {/* free bus id */
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: Don't call spi_get_gpio_descs() before device name is set" to the spi tree
The patch
spi: Don't call spi_get_gpio_descs() before device name is set
has been applied to the spi tree at
https://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
Quoted 1 line
From
0a919ae49223d32ac0e8be3494547fcd1e4aa0aaMon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:28 -0700
Subject: [PATCH] spi: Don't call spi_get_gpio_descs() before device name is
set
Move code calling spi_get_gpio_descs() to happen after ctlr->dev's name is set in order to have proper GPIO consumer names.
Before:
cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/40049000.gpio, vf610-gpio:
gpio-6 ( |regulator-usb0-vbus ) out lo
gpiochip1: GPIOs 32-63, parent: platform/4004a000.gpio, vf610-gpio:
gpio-36 ( |scl ) in hi gpio-37 ( |sda ) in hi gpio-40 ( |(null) CS1 ) out lo gpio-41 ( |(null) CS0 ) out lo ACTIVE LOW gpio-42 ( |miso ) in hi gpio-43 ( |mosi ) in lo gpio-44 ( |sck ) out lo
After:
cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/40049000.gpio, vf610-gpio:
gpio-6 ( |regulator-usb0-vbus ) out lo
gpiochip1: GPIOs 32-63, parent: platform/4004a000.gpio, vf610-gpio:
gpio-36 ( |scl ) in hi gpio-37 ( |sda ) in hi gpio-40 ( |spi0 CS1 ) out lo gpio-41 ( |spi0 CS0 ) out lo ACTIVE LOW gpio-42 ( |miso ) in hi gpio-43 ( |mosi ) in lo gpio-44 ( |sck ) out lo
--- drivers/spi/spi.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/spi/spi.c +19 -18
@@ -2281,24 +2281,6 @@ int spi_register_controller(struct spi_controller *ctlr)if (status)return status; -if (!spi_controller_is_slave (ctlr)) { -if (ctlr->use_gpio_descriptors) { - status =spi_get_gpio_descs (ctlr); -if (status) -return status; -/* -* A controller using GPIO descriptors always -* supports SPI_CS_HIGH if need be. -*/ - ctlr->mode_bits |=SPI_CS_HIGH ; - }else { -/* Legacy code path for GPIOs from DT */ - status =of_spi_register_master (ctlr); -if (status) -return status; - } - } -/* even if it's just one always-selected device, there must * be at least one chipselect */
@@ -2355,6 +2337,25 @@ int spi_register_controller(struct spi_controller *ctlr)* registration fails if the bus ID is in use. */ dev_set_name (&ctlr->dev,"spi%u" , ctlr->bus_num); + +if (!spi_controller_is_slave (ctlr)) { +if (ctlr->use_gpio_descriptors) { + status =spi_get_gpio_descs (ctlr); +if (status) +return status; +/* +* A controller using GPIO descriptors always +* supports SPI_CS_HIGH if need be. +*/ + ctlr->mode_bits |=SPI_CS_HIGH ; + }else { +/* Legacy code path for GPIOs from DT */ + status =of_spi_register_master (ctlr); +if (status) +return status; + } + } + status =device_add (&ctlr->dev);if (status <0 ) {/* free bus id */
Signature · 1 line
2.20.1
PATCH 8/12 spi: gpio: Drop mflags argument from spi_gpio_request()
In reply to Andrey SmirnovThe logic of setting mflags in spi_gpio_request() is very simple and there isn't much benefit in having it in that function. Move all of that code outside into spi_gpio_probe() in order to simplify things.
--- drivers/spi/spi-gpio.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/spi/spi-gpio.c +13 -15
@@ -290,25 +290,15 @@ static void spi_gpio_cleanup(struct spi_device *spi)* floating signals. (A weak pulldown would save power too, but many * drivers expect to see all-ones data as the no slave "response".) */ -static int spi_gpio_request (struct device *dev, -struct spi_gpio *spi_gpio, -u16 *mflags) +static int spi_gpio_request (struct device *dev,struct spi_gpio *spi_gpio) { spi_gpio->mosi =devm_gpiod_get_optional (dev,"mosi" ,GPIOD_OUT_LOW );if (IS_ERR (spi_gpio->mosi))return PTR_ERR (spi_gpio->mosi); -if (!spi_gpio->mosi) -/* HW configuration without MOSI pin */ - *mflags |=SPI_MASTER_NO_TX ; spi_gpio->miso =devm_gpiod_get_optional (dev,"miso" ,GPIOD_IN );if (IS_ERR (spi_gpio->miso))return PTR_ERR (spi_gpio->miso); -/* -* No setting SPI_MASTER_NO_RX here - if there is only a MOSI -* pin connected the host can still do RX by changing the -* direction of the line. -*/ spi_gpio->sck =devm_gpiod_get (dev,"sck" ,GPIOD_OUT_LOW );if (IS_ERR (spi_gpio->sck))
@@ -382,7 +372,6 @@ static int spi_gpio_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct spi_bitbang *bb;const struct of_device_id *of_id; -u16 master_flags =0 ; of_id =of_match_device (spi_gpio_dt_ids, &pdev->dev);
@@ -404,14 +393,23 @@ static int spi_gpio_probe(struct platform_device *pdev) spi_gpio->pdev = pdev; - status =spi_gpio_request (dev, spi_gpio, &master_flags); + status =spi_gpio_request (dev, spi_gpio);if (status)return status; master->bits_per_word_mask =SPI_BPW_RANGE_MASK (1 ,32 ); master->mode_bits =SPI_3WIRE |SPI_3WIRE_HIZ |SPI_CPHA |SPI_CPOL |SPI_CS_HIGH ; - master->flags = master_flags; +if (!spi_gpio->mosi) { +/* HW configuration without MOSI pin +* +* No setting SPI_MASTER_NO_RX here - if there is only +* a MOSI pin connected the host can still do RX by +* changing the direction of the line. +*/ + master->flags =SPI_MASTER_NO_TX ; + } + master->bus_num = pdev->id; master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup;
@@ -421,7 +419,7 @@ static int spi_gpio_probe(struct platform_device *pdev) bb->chipselect = spi_gpio_chipselect; bb->set_line_direction = spi_gpio_set_direction; -if (master_flags &SPI_MASTER_NO_TX ) { +if (master->flags &SPI_MASTER_NO_TX ) { bb->txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; bb->txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; bb->txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2;
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Drop mflags argument from spi_gpio_request()" to the spi tree
The patch
spi: gpio: Drop mflags argument from spi_gpio_request()
has been applied to the spi tree at
https://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
Quoted 1 line
From
5c8283c172c1597eb7c30b25f186de3ec6ee6cb5Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:29 -0700
Subject: [PATCH] spi: gpio: Drop mflags argument from spi_gpio_request()
The logic of setting mflags in spi_gpio_request() is very simple and there isn't much benefit in having it in that function. Move all of that code outside into spi_gpio_probe() in order to simplify things.
--- drivers/spi/spi-gpio.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/spi/spi-gpio.c +13 -15
@@ -289,25 +289,15 @@ static void spi_gpio_cleanup(struct spi_device *spi)* floating signals. (A weak pulldown would save power too, but many * drivers expect to see all-ones data as the no slave "response".) */ -static int spi_gpio_request (struct device *dev, -struct spi_gpio *spi_gpio, -u16 *mflags) +static int spi_gpio_request (struct device *dev,struct spi_gpio *spi_gpio) { spi_gpio->mosi =devm_gpiod_get_optional (dev,"mosi" ,GPIOD_OUT_LOW );if (IS_ERR (spi_gpio->mosi))return PTR_ERR (spi_gpio->mosi); -if (!spi_gpio->mosi) -/* HW configuration without MOSI pin */ - *mflags |=SPI_MASTER_NO_TX ; spi_gpio->miso =devm_gpiod_get_optional (dev,"miso" ,GPIOD_IN );if (IS_ERR (spi_gpio->miso))return PTR_ERR (spi_gpio->miso); -/* -* No setting SPI_MASTER_NO_RX here - if there is only a MOSI -* pin connected the host can still do RX by changing the -* direction of the line. -*/ spi_gpio->sck =devm_gpiod_get (dev,"sck" ,GPIOD_OUT_LOW );if (IS_ERR (spi_gpio->sck))
@@ -381,7 +371,6 @@ static int spi_gpio_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct spi_bitbang *bb;const struct of_device_id *of_id; -u16 master_flags =0 ; of_id =of_match_device (spi_gpio_dt_ids, &pdev->dev);
@@ -403,14 +392,23 @@ static int spi_gpio_probe(struct platform_device *pdev) spi_gpio->pdev = pdev; - status =spi_gpio_request (dev, spi_gpio, &master_flags); + status =spi_gpio_request (dev, spi_gpio);if (status)return status; master->bits_per_word_mask =SPI_BPW_RANGE_MASK (1 ,32 ); master->mode_bits =SPI_3WIRE |SPI_3WIRE_HIZ |SPI_CPHA |SPI_CPOL |SPI_CS_HIGH ; - master->flags = master_flags; +if (!spi_gpio->mosi) { +/* HW configuration without MOSI pin +* +* No setting SPI_MASTER_NO_RX here - if there is only +* a MOSI pin connected the host can still do RX by +* changing the direction of the line. +*/ + master->flags =SPI_MASTER_NO_TX ; + } + master->bus_num = pdev->id; master->setup = spi_gpio_setup; master->cleanup = spi_gpio_cleanup;
@@ -420,7 +418,7 @@ static int spi_gpio_probe(struct platform_device *pdev) bb->chipselect = spi_gpio_chipselect; bb->set_line_direction = spi_gpio_set_direction; -if (master_flags &SPI_MASTER_NO_TX ) { +if (master->flags &SPI_MASTER_NO_TX ) { bb->txrx_word[SPI_MODE_0 ] = spi_gpio_spec_txrx_word_mode0; bb->txrx_word[SPI_MODE_1 ] = spi_gpio_spec_txrx_word_mode1; bb->txrx_word[SPI_MODE_2 ] = spi_gpio_spec_txrx_word_mode2;
Signature · 1 line
2.20.1
PATCH 9/12 spi: gpio: Drop unused pdev field in struct spi_gpio
In reply to Andrey SmirnovThere's no code using 'pdev' field in struct spi_gpio. Drop it.
--- drivers/spi/spi-gpio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/spi/spi-gpio.c +0 -3
@@ -42,7 +42,6 @@struct spi_gpio {struct spi_bitbang bitbang; -struct platform_device *pdev;struct gpio_desc *sck;struct gpio_desc *miso;struct gpio_desc *mosi;
@@ -391,8 +390,6 @@ static int spi_gpio_probe(struct platform_device *pdev)platform_set_drvdata (pdev, spi_gpio); - spi_gpio->pdev = pdev; - status =spi_gpio_request (dev, spi_gpio);if (status)return status;
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Drop unused pdev field in struct spi_gpio" to the spi tree
The patch
spi: gpio: Drop unused pdev field in struct spi_gpio
has been applied to the spi tree at
https://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
Quoted 1 line
From
45f7718ae713e52def029c071cdba19a8045ac52Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:30 -0700
Subject: [PATCH] spi: gpio: Drop unused pdev field in struct spi_gpio
There's no code using 'pdev' field in struct spi_gpio. Drop it.
--- drivers/spi/spi-gpio.c | 3 --- 1 file changed, 3 deletions(-)
drivers/spi/spi-gpio.c +0 -3
@@ -41,7 +41,6 @@struct spi_gpio {struct spi_bitbang bitbang; -struct platform_device *pdev;struct gpio_desc *sck;struct gpio_desc *miso;struct gpio_desc *mosi;
@@ -390,8 +389,6 @@ static int spi_gpio_probe(struct platform_device *pdev)platform_set_drvdata (pdev, spi_gpio); - spi_gpio->pdev = pdev; - status =spi_gpio_request (dev, spi_gpio);if (status)return status;
Signature · 1 line
2.20.1
PATCH 10/12 spi: gpio: Make sure spi_master_put() is called in every error path
In reply to Andrey SmirnovThere's a number of failure paths in spi_gpio_probe() that do not call spi_master_put() potentially leaking memory. Fix this problem by registering a cleanup funciont via devm_add_action_or_reset() right after SPI controller is allocated.
--- drivers/spi/spi-gpio.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/spi/spi-gpio.c +10 -7
@@ -363,6 +363,11 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev,return 0 ; } +static void spi_gpio_put (void *data) +{ +spi_master_put (data); +} +static int spi_gpio_probe (struct platform_device *pdev) {int status;
@@ -378,6 +383,10 @@ static int spi_gpio_probe(struct platform_device *pdev)if (!master)return -ENOMEM ; + status =devm_add_action_or_reset (&pdev->dev, spi_gpio_put, master); +if (status) +return status; +if (of_id) status =spi_gpio_probe_dt (pdev, master);else
@@ -429,11 +438,7 @@ static int spi_gpio_probe(struct platform_device *pdev) } bb->setup_transfer = spi_bitbang_setup_transfer; - status =spi_bitbang_start (&spi_gpio->bitbang); -if (status) -spi_master_put (master); - -return status; +return spi_bitbang_start (&spi_gpio->bitbang); }static int spi_gpio_remove (struct platform_device *pdev)
@@ -445,8 +450,6 @@ static int spi_gpio_remove(struct platform_device *pdev)/* stop() unregisters child devices too */ spi_bitbang_stop (&spi_gpio->bitbang); -spi_master_put (spi_gpio->bitbang.master); -return 0 ; }
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Make sure spi_master_put() is called in every error path" to the spi tree
The patch
spi: gpio: Make sure spi_master_put() is called in every error path
has been applied to the spi tree at
https://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
Quoted 1 line
From
8b797490b4db09492acda4b4a4a4355d2311a614Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:31 -0700
Subject: [PATCH] spi: gpio: Make sure spi_master_put() is called in every
error path
There's a number of failure paths in spi_gpio_probe() that do not call spi_master_put() potentially leaking memory. Fix this problem by registering a cleanup funciont via devm_add_action_or_reset() right after SPI controller is allocated.
--- drivers/spi/spi-gpio.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/spi/spi-gpio.c +10 -7
@@ -362,6 +362,11 @@ static int spi_gpio_probe_pdata(struct platform_device *pdev,return 0 ; } +static void spi_gpio_put (void *data) +{ +spi_master_put (data); +} +static int spi_gpio_probe (struct platform_device *pdev) {int status;
@@ -377,6 +382,10 @@ static int spi_gpio_probe(struct platform_device *pdev)if (!master)return -ENOMEM ; + status =devm_add_action_or_reset (&pdev->dev, spi_gpio_put, master); +if (status) +return status; +if (of_id) status =spi_gpio_probe_dt (pdev, master);else
@@ -428,11 +437,7 @@ static int spi_gpio_probe(struct platform_device *pdev) } bb->setup_transfer = spi_bitbang_setup_transfer; - status =spi_bitbang_start (&spi_gpio->bitbang); -if (status) -spi_master_put (master); - -return status; +return spi_bitbang_start (&spi_gpio->bitbang); }static int spi_gpio_remove (struct platform_device *pdev)
@@ -444,8 +449,6 @@ static int spi_gpio_remove(struct platform_device *pdev)/* stop() unregisters child devices too */ spi_bitbang_stop (&spi_gpio->bitbang); -spi_master_put (spi_gpio->bitbang.master); -return 0 ; }
Signature · 1 line
2.20.1
PATCH 11/12 spi: bitbang: Introduce spi_bitbang_init()
In reply to Andrey SmirnovMove all of the code doing struct spi_bitbang initialization, so that it can be paired with devm_spi_register_master() in order to avoid having to call spi_bitbang_stop() explicitly.
--- drivers/spi/spi-bitbang.c | 66 +++++++++++++++++++-------------- include/linux/spi/spi_bitbang.h | 1 + 2 files changed, 40 insertions(+), 27 deletions(-)
drivers/spi/spi-bitbang.c +39 -27
@@ -335,6 +335,42 @@ static void spi_bitbang_set_cs(struct spi_device *spi, bool enable)/*----------------------------------------------------------------------*/ +int spi_bitbang_init (struct spi_bitbang *bitbang) +{ +struct spi_master *master = bitbang->master; + +if (!master || !bitbang->chipselect) +return -EINVAL ; + +mutex_init (&bitbang->lock); + +if (!master->mode_bits) + master->mode_bits =SPI_CPOL |SPI_CPHA | bitbang->flags; + +if (master->transfer || master->transfer_one_message) +return -EINVAL ; + + master->prepare_transfer_hardware = spi_bitbang_prepare_hardware; + master->unprepare_transfer_hardware = spi_bitbang_unprepare_hardware; + master->transfer_one = spi_bitbang_transfer_one; + master->set_cs = spi_bitbang_set_cs; + +if (!bitbang->txrx_bufs) { + bitbang->use_dma =0 ; + bitbang->txrx_bufs = spi_bitbang_bufs; +if (!master->setup) { +if (!bitbang->setup_transfer) + bitbang->setup_transfer = + spi_bitbang_setup_transfer; + master->setup = spi_bitbang_setup; + master->cleanup = spi_bitbang_cleanup; + } + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (spi_bitbang_init); +/** * spi_bitbang_start - start up a polled/bitbanging SPI master driver * @bitbang: driver handle
@@ -368,33 +404,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)struct spi_master *master = bitbang->master;int ret; -if (!master || !bitbang->chipselect) -return -EINVAL ; - -mutex_init (&bitbang->lock); - -if (!master->mode_bits) - master->mode_bits =SPI_CPOL |SPI_CPHA | bitbang->flags; - -if (master->transfer || master->transfer_one_message) -return -EINVAL ; - - master->prepare_transfer_hardware = spi_bitbang_prepare_hardware; - master->unprepare_transfer_hardware = spi_bitbang_unprepare_hardware; - master->transfer_one = spi_bitbang_transfer_one; - master->set_cs = spi_bitbang_set_cs; - -if (!bitbang->txrx_bufs) { - bitbang->use_dma =0 ; - bitbang->txrx_bufs = spi_bitbang_bufs; -if (!master->setup) { -if (!bitbang->setup_transfer) - bitbang->setup_transfer = - spi_bitbang_setup_transfer; - master->setup = spi_bitbang_setup; - master->cleanup = spi_bitbang_cleanup; - } - } + ret =spi_bitbang_init (bitbang); +if (ret) +return ret;/* driver may get busy before register() returns, especially * if someone registered boardinfo for devices
include/linux/spi/spi_bitbang.h +1 -0
@@ -44,6 +44,7 @@ extern int spi_bitbang_setup_transfer(struct spi_device *spi,/* start or stop queue processing */ extern int spi_bitbang_start (struct spi_bitbang *spi); +extern int spi_bitbang_init (struct spi_bitbang *spi);extern void spi_bitbang_stop (struct spi_bitbang *spi);#endif /* __SPI_BITBANG_H */
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: bitbang: Introduce spi_bitbang_init()" to the spi tree
The patch
spi: bitbang: Introduce spi_bitbang_init()
has been applied to the spi tree at
https://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
Quoted 1 line
From
45beec3519983cb11768cd3ee350f44975bf4ceaMon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:32 -0700
Subject: [PATCH] spi: bitbang: Introduce spi_bitbang_init()
Move all of the code doing struct spi_bitbang initialization, so that it can be paired with devm_spi_register_master() in order to avoid having to call spi_bitbang_stop() explicitly.
--- drivers/spi/spi-bitbang.c | 66 +++++++++++++++++++-------------- include/linux/spi/spi_bitbang.h | 1 + 2 files changed, 40 insertions(+), 27 deletions(-)
drivers/spi/spi-bitbang.c +39 -27
@@ -335,6 +335,42 @@ static void spi_bitbang_set_cs(struct spi_device *spi, bool enable)/*----------------------------------------------------------------------*/ +int spi_bitbang_init (struct spi_bitbang *bitbang) +{ +struct spi_master *master = bitbang->master; + +if (!master || !bitbang->chipselect) +return -EINVAL ; + +mutex_init (&bitbang->lock); + +if (!master->mode_bits) + master->mode_bits =SPI_CPOL |SPI_CPHA | bitbang->flags; + +if (master->transfer || master->transfer_one_message) +return -EINVAL ; + + master->prepare_transfer_hardware = spi_bitbang_prepare_hardware; + master->unprepare_transfer_hardware = spi_bitbang_unprepare_hardware; + master->transfer_one = spi_bitbang_transfer_one; + master->set_cs = spi_bitbang_set_cs; + +if (!bitbang->txrx_bufs) { + bitbang->use_dma =0 ; + bitbang->txrx_bufs = spi_bitbang_bufs; +if (!master->setup) { +if (!bitbang->setup_transfer) + bitbang->setup_transfer = + spi_bitbang_setup_transfer; + master->setup = spi_bitbang_setup; + master->cleanup = spi_bitbang_cleanup; + } + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (spi_bitbang_init); +/** * spi_bitbang_start - start up a polled/bitbanging SPI master driver * @bitbang: driver handle
@@ -368,33 +404,9 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)struct spi_master *master = bitbang->master;int ret; -if (!master || !bitbang->chipselect) -return -EINVAL ; - -mutex_init (&bitbang->lock); - -if (!master->mode_bits) - master->mode_bits =SPI_CPOL |SPI_CPHA | bitbang->flags; - -if (master->transfer || master->transfer_one_message) -return -EINVAL ; - - master->prepare_transfer_hardware = spi_bitbang_prepare_hardware; - master->unprepare_transfer_hardware = spi_bitbang_unprepare_hardware; - master->transfer_one = spi_bitbang_transfer_one; - master->set_cs = spi_bitbang_set_cs; - -if (!bitbang->txrx_bufs) { - bitbang->use_dma =0 ; - bitbang->txrx_bufs = spi_bitbang_bufs; -if (!master->setup) { -if (!bitbang->setup_transfer) - bitbang->setup_transfer = - spi_bitbang_setup_transfer; - master->setup = spi_bitbang_setup; - master->cleanup = spi_bitbang_cleanup; - } - } + ret =spi_bitbang_init (bitbang); +if (ret) +return ret;/* driver may get busy before register() returns, especially * if someone registered boardinfo for devices
include/linux/spi/spi_bitbang.h +1 -0
@@ -44,6 +44,7 @@ extern int spi_bitbang_setup_transfer(struct spi_device *spi,/* start or stop queue processing */ extern int spi_bitbang_start (struct spi_bitbang *spi); +extern int spi_bitbang_init (struct spi_bitbang *spi);extern void spi_bitbang_stop (struct spi_bitbang *spi);#endif /* __SPI_BITBANG_H */
Signature · 1 line
2.20.1
PATCH 12/12 spi: gpio: Use devm_spi_register_master()
In reply to Andrey SmirnovReplace spi_bitbang_start() with a combination of spi_bitbang_init() and devm_spi_register_master() and drop all of the explicit cleanup-related code that's no longer necessary.
--- drivers/spi/spi-gpio.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/spi/spi-gpio.c +4 -15
@@ -397,8 +397,6 @@ static int spi_gpio_probe(struct platform_device *pdev) spi_gpio =spi_master_get_devdata (master); -platform_set_drvdata (pdev, spi_gpio); - status =spi_gpio_request (dev, spi_gpio);if (status)return status;
@@ -438,19 +436,11 @@ static int spi_gpio_probe(struct platform_device *pdev) } bb->setup_transfer = spi_bitbang_setup_transfer; -return spi_bitbang_start (&spi_gpio->bitbang); -} - -static int spi_gpio_remove (struct platform_device *pdev) -{ -struct spi_gpio *spi_gpio; - - spi_gpio =platform_get_drvdata (pdev); - -/* stop() unregisters child devices too */ -spi_bitbang_stop (&spi_gpio->bitbang); + status =spi_bitbang_init (&spi_gpio->bitbang); +if (status) +return status; -return 0 ; +return devm_spi_register_master (&pdev->dev,spi_master_get (master)); }MODULE_ALIAS ("platform:" DRIVER_NAME );
@@ -461,7 +451,6 @@ static struct platform_driver spi_gpio_driver = { .of_match_table = of_match_ptr(spi_gpio_dt_ids), }, .probe = spi_gpio_probe, - .remove = spi_gpio_remove, };module_platform_driver (spi_gpio_driver);
Signature · 1 line
2.20.1
Mark Brown
maintainerApplied "spi: gpio: Use devm_spi_register_master()" to the spi tree
The patch
spi: gpio: Use devm_spi_register_master()
has been applied to the spi tree at
https://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
Quoted 1 line
From
79567c1a321e7396e734135d56950311dde07db2Mon Sep 17 00:00:00 2001
From: Andrey Smirnov <[email protected]>
Date: Tue, 2 Apr 2019 21:01:33 -0700
Subject: [PATCH] spi: gpio: Use devm_spi_register_master()
Replace spi_bitbang_start() with a combination of spi_bitbang_init() and devm_spi_register_master() and drop all of the explicit cleanup-related code that's no longer necessary.
--- drivers/spi/spi-gpio.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/spi/spi-gpio.c +4 -15
@@ -396,8 +396,6 @@ static int spi_gpio_probe(struct platform_device *pdev) spi_gpio =spi_master_get_devdata (master); -platform_set_drvdata (pdev, spi_gpio); - status =spi_gpio_request (dev, spi_gpio);if (status)return status;
@@ -437,19 +435,11 @@ static int spi_gpio_probe(struct platform_device *pdev) } bb->setup_transfer = spi_bitbang_setup_transfer; -return spi_bitbang_start (&spi_gpio->bitbang); -} - -static int spi_gpio_remove (struct platform_device *pdev) -{ -struct spi_gpio *spi_gpio; - - spi_gpio =platform_get_drvdata (pdev); - -/* stop() unregisters child devices too */ -spi_bitbang_stop (&spi_gpio->bitbang); + status =spi_bitbang_init (&spi_gpio->bitbang); +if (status) +return status; -return 0 ; +return devm_spi_register_master (&pdev->dev,spi_master_get (master)); }MODULE_ALIAS ("platform:" DRIVER_NAME );
@@ -460,7 +450,6 @@ static struct platform_driver spi_gpio_driver = { .of_match_table = of_match_ptr(spi_gpio_dt_ids), }, .probe = spi_gpio_probe, - .remove = spi_gpio_remove, };module_platform_driver (spi_gpio_driver);
Signature · 1 line
2.20.1