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: 9342997 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 5C3BD607D4 for ; Wed, 21 Sep 2016 07:55:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B2682A168 for ; Wed, 21 Sep 2016 07:55:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FB492A245; Wed, 21 Sep 2016 07:55:30 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8EF52A168 for ; Wed, 21 Sep 2016 07:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754822AbcIUHzV (ORCPT ); Wed, 21 Sep 2016 03:55:21 -0400 Received: from smtpout.microchip.com ([198.175.253.82]:35237 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751497AbcIUHyz (ORCPT ); Wed, 21 Sep 2016 03:54:55 -0400 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 , CC: Ludovic Desroches , , , Cyrille Pitchen , Wenyou Yang , Nicolas Ferre 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= Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.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); }