* [PATCH 1/1] fpga: altera-ps-spi: Fix getting of optional confd gpio
@ 2019-07-25 2:48 Phil Reid
2019-07-25 20:52 ` Moritz Fischer
0 siblings, 1 reply; 2+ messages in thread
From: Phil Reid @ 2019-07-25 2:48 UTC (permalink / raw)
To: atull, mdf, colin.king, agust, preid, linux-fpga
Currently the driver does not handle EPROBE_DEFER for the confd gpio.
Use devm_gpiod_get_optional() instead of devm_gpiod_get() and return
error codes from altera_ps_probe().
Fixes: 5692fae0742d ("fpga manager: Add altera-ps-spi driver for Altera FPGAs")
Signed-off-by: Phil Reid <preid@electromag.com.au>
---
Notes:
Compile tested only. I currently don't have hardware to test.
I was reviewing the driver prior to a board design and noticed
the problem.
drivers/fpga/altera-ps-spi.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
index 678d0115f840..a02b88d63f89 100644
--- a/drivers/fpga/altera-ps-spi.c
+++ b/drivers/fpga/altera-ps-spi.c
@@ -213,7 +213,7 @@ static int altera_ps_write_complete(struct fpga_manager *mgr,
return -EIO;
}
- if (!IS_ERR(conf->confd)) {
+ if (conf->confd) {
if (!gpiod_get_raw_value_cansleep(conf->confd)) {
dev_err(&mgr->dev, "CONF_DONE is inactive!\n");
return -EIO;
@@ -292,10 +292,13 @@ static int altera_ps_probe(struct spi_device *spi)
return PTR_ERR(conf->status);
}
- conf->confd = devm_gpiod_get(&spi->dev, "confd", GPIOD_IN);
+ conf->confd = devm_gpiod_get_optional(&spi->dev, "confd", GPIOD_IN);
if (IS_ERR(conf->confd)) {
- dev_warn(&spi->dev, "Not using confd gpio: %ld\n",
- PTR_ERR(conf->confd));
+ dev_err(&spi->dev, "Failed to get confd gpio: %ld\n",
+ PTR_ERR(conf->confd));
+ return PTR_ERR(conf->confd);
+ } else if (!conf->confd) {
+ dev_warn(&spi->dev, "Not using confd gpio");
}
/* Register manager with unique name */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] fpga: altera-ps-spi: Fix getting of optional confd gpio
2019-07-25 2:48 [PATCH 1/1] fpga: altera-ps-spi: Fix getting of optional confd gpio Phil Reid
@ 2019-07-25 20:52 ` Moritz Fischer
0 siblings, 0 replies; 2+ messages in thread
From: Moritz Fischer @ 2019-07-25 20:52 UTC (permalink / raw)
To: Phil Reid; +Cc: atull, mdf, colin.king, agust, linux-fpga
On Thu, Jul 25, 2019 at 10:48:45AM +0800, Phil Reid wrote:
> Currently the driver does not handle EPROBE_DEFER for the confd gpio.
> Use devm_gpiod_get_optional() instead of devm_gpiod_get() and return
> error codes from altera_ps_probe().
>
> Fixes: 5692fae0742d ("fpga manager: Add altera-ps-spi driver for Altera FPGAs")
> Signed-off-by: Phil Reid <preid@electromag.com.au>
> ---
>
> Notes:
> Compile tested only. I currently don't have hardware to test.
> I was reviewing the driver prior to a board design and noticed
> the problem.
>
> drivers/fpga/altera-ps-spi.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
> index 678d0115f840..a02b88d63f89 100644
> --- a/drivers/fpga/altera-ps-spi.c
> +++ b/drivers/fpga/altera-ps-spi.c
> @@ -213,7 +213,7 @@ static int altera_ps_write_complete(struct fpga_manager *mgr,
> return -EIO;
> }
>
> - if (!IS_ERR(conf->confd)) {
> + if (conf->confd) {
> if (!gpiod_get_raw_value_cansleep(conf->confd)) {
> dev_err(&mgr->dev, "CONF_DONE is inactive!\n");
> return -EIO;
> @@ -292,10 +292,13 @@ static int altera_ps_probe(struct spi_device *spi)
> return PTR_ERR(conf->status);
> }
>
> - conf->confd = devm_gpiod_get(&spi->dev, "confd", GPIOD_IN);
> + conf->confd = devm_gpiod_get_optional(&spi->dev, "confd", GPIOD_IN);
> if (IS_ERR(conf->confd)) {
> - dev_warn(&spi->dev, "Not using confd gpio: %ld\n",
> - PTR_ERR(conf->confd));
> + dev_err(&spi->dev, "Failed to get confd gpio: %ld\n",
> + PTR_ERR(conf->confd));
> + return PTR_ERR(conf->confd);
> + } else if (!conf->confd) {
> + dev_warn(&spi->dev, "Not using confd gpio");
> }
>
> /* Register manager with unique name */
> --
> 1.8.3.1
>
Applied, thanks.
Moritz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-25 20:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-25 2:48 [PATCH 1/1] fpga: altera-ps-spi: Fix getting of optional confd gpio Phil Reid
2019-07-25 20:52 ` Moritz Fischer
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).