From patchwork Wed Sep 21 07:55:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Ferre X-Patchwork-Id: 9342999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42019607D4 for ; Wed, 21 Sep 2016 07:56:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 303252A264 for ; Wed, 21 Sep 2016 07:56:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 248E82A267; Wed, 21 Sep 2016 07:56:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BA3702A264 for ; Wed, 21 Sep 2016 07:56:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmcNT-0002UK-Pk; Wed, 21 Sep 2016 07:55:35 +0000 Received: from smtpout.microchip.com ([198.175.253.82] helo=email.microchip.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bmcN9-00012F-AL for linux-arm-kernel@lists.infradead.org; Wed, 21 Sep 2016 07:55:16 +0000 Received: from tenerife.corp.atmel.com (10.10.76.4) by chn-sv-exch06.mchp-main.com (10.10.76.107) with Microsoft SMTP Server id 14.3.181.6; Wed, 21 Sep 2016 00:54:53 -0700 From: Nicolas Ferre To: , Mark Brown , Alexandre Belloni , Boris BREZILLON , Subject: [PATCH] spi: atmel: use managed resource for gpio chip select Date: Wed, 21 Sep 2016 09:55:28 +0200 Message-ID: <20160921075528.14452-1-nicolas.ferre@atmel.com> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAC+NgFvrOosTGxcLF5cOie9bmUbjB7U0PTrBY3Pu0jdHi/rXTLBZfm4wtOqasYrJovHSE3WLa9HfMDmwBDFGsmXlJ+RUJrBmvzjWwFkznqmjf8JG1gXEpRxcjF4eQwHpGiUnbdzB1MXJysAnoSpyd8IQNJCEicJJRYkLbc2YQh1mggUli14cu9i5GDg5hATeJva1yIA0sAqoS71a+YgaxeQVsJN78vcQCYksIyEk0nL8PFReUODnzCVicWUBC4uCLF2BxIQEVib73/ewQ9YEStzZ/grKdJP6vnAll20kcnn4RynaQuH9/BhtMzcGtz6FsbYntr/axQtg6EtsO9kPdYCuxZ8ZEJgjbXeLBo+VQtq/ErIcNUDVREqf6P7NOYBSbheTUWUhOXcDItIpR2tnDTzc4TNc1wtnDwEwvNzmjQDc3MTNPLzk/dxMjJFKydzCeafM/xCjJwaQkyrt10vlwIb6k/JTKjMTijPii0pzU4kOMEhw8SiK8h5YB5XiLCxJzizPTYVIyHBxKErwXQFKCRanpqRVpmTklqUUQ6VOMklLivPdAkgIgfRmleXC5S4yiUsK8UUuBcjwFqUW5mSUQ8VuMwhwPmYRY8vLzUqWATmQAAg3GV4ziHIxKwrwXQWbxZOaVwJ3wCug6JqDr1u0+DXJdSSJCSqqBUfGO1P4nez403tipuSHfKan3f/sy3wVMbSvPMGoZ2C66yW7gGpXXfXQdc6ljsfPaL41dmbO92W7982bPrTR/FyMQu5Wn3u/m5OcF58PXrxfTPv6NfWUUW+VrmYnXI951fWbaz2prs8gvI3jFjc7Uj03L2U/PDdJSVTwnv1m5v31LgOSya2+jlViKMxINtZiLihMBR+qv9QoDAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160921_005515_495197_C35393C6 X-CRM114-Status: UNSURE ( 9.21 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicolas Ferre , linux-kernel@vger.kernel.org, Wenyou Yang , Ludovic Desroches , Cyrille Pitchen , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Nicolas Ferre --- 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); }