From: Nicolas Ferre <nicolas.ferre@atmel.com> To: <linux@meltdown.ru>, Mark Brown <broonie@kernel.org>, Alexandre Belloni <alexandre.belloni@free-electrons.com>, Boris BREZILLON <boris.brezillon@free-electrons.com>, <linux-spi@vger.kernel.org> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, Cyrille Pitchen <cyrille.pitchen@atmel.com>, Wenyou Yang <wenyou.yang@atmel.com>, Nicolas Ferre <nicolas.ferre@atmel.com> Subject: [PATCH] spi: atmel: use managed resource for gpio chip select Date: Wed, 21 Sep 2016 09:55:28 +0200 [thread overview] Message-ID: <20160921075528.14452-1-nicolas.ferre@atmel.com> (raw) Use the managed gpio CS pin request so that we avoid having trouble in the cleanup code. In fact, if module was configured with DT, cleanup code released invalid pin. Since resource wasn't freed, module cannot be reinserted. Reported-by: Alexander Morozov <linux@meltdown.ru> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> --- drivers/spi/spi-atmel.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8feac599e9ab..4e3f2345844a 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1248,7 +1248,8 @@ static int atmel_spi_setup(struct spi_device *spi) return -ENOMEM; if (as->use_cs_gpios) { - ret = gpio_request(npcs_pin, dev_name(&spi->dev)); + ret = devm_gpio_request(&spi->dev, + npcs_pin, dev_name(&spi->dev)); if (ret) { kfree(asd); return ret; @@ -1471,13 +1472,11 @@ static int atmel_spi_transfer_one_message(struct spi_master *master, static void atmel_spi_cleanup(struct spi_device *spi) { struct atmel_spi_device *asd = spi->controller_state; - unsigned gpio = (unsigned long) spi->controller_data; if (!asd) return; spi->controller_state = NULL; - gpio_free(gpio); kfree(asd); } -- 2.9.0
WARNING: multiple messages have this Message-ID (diff)
From: nicolas.ferre@atmel.com (Nicolas Ferre) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] spi: atmel: use managed resource for gpio chip select Date: Wed, 21 Sep 2016 09:55:28 +0200 [thread overview] Message-ID: <20160921075528.14452-1-nicolas.ferre@atmel.com> (raw) Use the managed gpio CS pin request so that we avoid having trouble in the cleanup code. In fact, if module was configured with DT, cleanup code released invalid pin. Since resource wasn't freed, module cannot be reinserted. Reported-by: Alexander Morozov <linux@meltdown.ru> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> --- drivers/spi/spi-atmel.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8feac599e9ab..4e3f2345844a 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1248,7 +1248,8 @@ static int atmel_spi_setup(struct spi_device *spi) return -ENOMEM; if (as->use_cs_gpios) { - ret = gpio_request(npcs_pin, dev_name(&spi->dev)); + ret = devm_gpio_request(&spi->dev, + npcs_pin, dev_name(&spi->dev)); if (ret) { kfree(asd); return ret; @@ -1471,13 +1472,11 @@ static int atmel_spi_transfer_one_message(struct spi_master *master, static void atmel_spi_cleanup(struct spi_device *spi) { struct atmel_spi_device *asd = spi->controller_state; - unsigned gpio = (unsigned long) spi->controller_data; if (!asd) return; spi->controller_state = NULL; - gpio_free(gpio); kfree(asd); } -- 2.9.0
next reply other threads:[~2016-09-21 7:55 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-09-21 7:55 Nicolas Ferre [this message] 2016-09-21 7:55 ` [PATCH] spi: atmel: use managed resource for gpio chip select Nicolas Ferre 2016-09-21 8:20 ` Geert Uytterhoeven 2016-09-21 8:20 ` Geert Uytterhoeven 2016-09-21 8:20 ` Geert Uytterhoeven 2016-11-07 13:54 ` Nicolas Ferre 2016-11-07 13:54 ` Nicolas Ferre 2016-11-07 13:54 ` Nicolas Ferre
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=20160921075528.14452-1-nicolas.ferre@atmel.com \ --to=nicolas.ferre@atmel.com \ --cc=alexandre.belloni@free-electrons.com \ --cc=boris.brezillon@free-electrons.com \ --cc=broonie@kernel.org \ --cc=cyrille.pitchen@atmel.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-spi@vger.kernel.org \ --cc=linux@meltdown.ru \ --cc=ludovic.desroches@atmel.com \ --cc=wenyou.yang@atmel.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.