From patchwork Thu Aug 3 11:40:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 9878777 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 4F65B60360 for ; Thu, 3 Aug 2017 11:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 463AA28880 for ; Thu, 3 Aug 2017 11:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B15B288AC; Thu, 3 Aug 2017 11:41:16 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5FD35288B9 for ; Thu, 3 Aug 2017 11:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9mWg1S7861GeTRI63FkbCq2d3xfuPaDhzuMZgDUFI4E=; b=qSuulON6MyaAz12woHC+N/utgA A00y4ek4X61J79gJLsjphKhyjDwcCfOAeoSNk7U7r9mtgJhuC8wy8zHxgFhDqsXUDl61b+Zc4KIDr unGY3BGvo1yxPqol/0ey9Y7NHw+AY41K+65kBFbrsMHdm3Ulu5MKz56sV4yykmB1Tj4NOlnlMvcop Zg/l3ShodD2PQG5MN28Hm8v/ASKGgcSfU8NPtQK1c+XHct6qCvp891R6nlNN057DK5mzWyHXGTA5O qRPENQFj8fMc+znsvY9NXhkIUvR9fWUIwKk570vbOIFwEd+IPkpkiE0n9+XoNw+PmJLQP4kSwivRC E7Demn6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ddEV5-0005NB-8H; Thu, 03 Aug 2017 11:41:11 +0000 Received: from goliath.siemens.de ([192.35.17.28]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddEV2-0005KK-47 for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2017 11:41:10 +0000 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id v73BeZlv032486 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Aug 2017 13:40:35 +0200 Received: from md1f2u6c.ww002.siemens.net.net ([139.25.68.37]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id v73BeYFa029399; Thu, 3 Aug 2017 13:40:35 +0200 From: Jan Kiszka To: Mark Brown , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Andy Shevchenko , Mika Westerberg Subject: [PATCH RFC 1/2] spi: pxa2xx: Convert to GPIO descriptor API where possible Date: Thu, 3 Aug 2017 13:40:32 +0200 Message-Id: <6bfd2b29b888c14f1a6feb9dee5bb54b74e761b0.1501760433.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170803_044108_505843_D244E3A6 X-CRM114-Status: GOOD ( 16.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linux Kernel Mailing List , linux-arm-kernel , linux-spi MIME-Version: 1.0 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 From: Jan Kiszka We still need to request/free GPIOs passed via the legacy path of pxa2xx_spi_chip::gpio_cs, but we can use the gpiod API otherwise. Consistently use the descriptor API instead of the legacy one. Signed-off-by: Jan Kiszka Acked-by: Mika Westerberg --- drivers/spi/spi-pxa2xx.c | 32 ++++++++++++++++---------------- drivers/spi/spi-pxa2xx.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 38d053682892..7faba738110c 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -402,8 +402,8 @@ static void cs_assert(struct driver_data *drv_data) return; } - if (gpio_is_valid(chip->gpio_cs)) { - gpio_set_value(chip->gpio_cs, chip->gpio_cs_inverted); + if (chip->gpiod_cs) { + gpiod_set_value(chip->gpiod_cs, chip->gpio_cs_inverted); return; } @@ -424,8 +424,8 @@ static void cs_deassert(struct driver_data *drv_data) return; } - if (gpio_is_valid(chip->gpio_cs)) { - gpio_set_value(chip->gpio_cs, !chip->gpio_cs_inverted); + if (chip->gpiod_cs) { + gpiod_set_value(chip->gpiod_cs, !chip->gpio_cs_inverted); return; } @@ -1213,17 +1213,16 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, struct pxa2xx_spi_chip *chip_info) { struct driver_data *drv_data = spi_master_get_devdata(spi->master); + struct gpio_desc *gpiod; int err = 0; if (chip == NULL) return 0; if (drv_data->cs_gpiods) { - struct gpio_desc *gpiod; - gpiod = drv_data->cs_gpiods[spi->chip_select]; if (gpiod) { - chip->gpio_cs = desc_to_gpio(gpiod); + chip->gpiod_cs = gpiod; chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; gpiod_set_value(gpiod, chip->gpio_cs_inverted); } @@ -1237,8 +1236,10 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, /* NOTE: setup() can be called multiple times, possibly with * different chip_info, release previously requested GPIO */ - if (gpio_is_valid(chip->gpio_cs)) - gpio_free(chip->gpio_cs); + if (chip->gpiod_cs) { + gpio_free(desc_to_gpio(chip->gpiod_cs)); + chip->gpiod_cs = NULL; + } /* If (*cs_control) is provided, ignore GPIO chip select */ if (chip_info->cs_control) { @@ -1254,11 +1255,11 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, return err; } - chip->gpio_cs = chip_info->gpio_cs; + gpiod = gpio_to_desc(chip_info->gpio_cs); + chip->gpiod_cs = gpiod; chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; - err = gpio_direction_output(chip->gpio_cs, - !chip->gpio_cs_inverted); + err = gpiod_direction_output(gpiod, !chip->gpio_cs_inverted); } return err; @@ -1317,8 +1318,7 @@ static int setup(struct spi_device *spi) } chip->frm = spi->chip_select; - } else - chip->gpio_cs = -1; + } chip->enable_dma = drv_data->master_info->enable_dma; chip->timeout = TIMOUT_DFLT; } @@ -1416,8 +1416,8 @@ static void cleanup(struct spi_device *spi) return; if (drv_data->ssp_type != CE4100_SSP && !drv_data->cs_gpiods && - gpio_is_valid(chip->gpio_cs)) - gpio_free(chip->gpio_cs); + chip->gpiod_cs) + gpio_free(desc_to_gpio(chip->gpiod_cs)); kfree(chip); } diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index 2823a00a9405..94f7b0713281 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -83,7 +83,7 @@ struct chip_data { u16 lpss_tx_threshold; u8 enable_dma; union { - int gpio_cs; + struct gpio_desc *gpiod_cs; unsigned int frm; }; int gpio_cs_inverted;