From patchwork Thu Jun 25 22:57:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 191750 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1253329ilg; Thu, 25 Jun 2020 15:58:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCZY8B9+FLVDc6j+fIb8V/W//JPyJxhOfHNiM9P1kyr50Im8PXt5mtYIIx/4X8XU2vSpdi X-Received: by 2002:aa7:d64b:: with SMTP id v11mr479036edr.381.1593125890632; Thu, 25 Jun 2020 15:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593125890; cv=none; d=google.com; s=arc-20160816; b=R/on09iEQZWEK9OIt1gwHkD2txT+gcQ33+9OYpFofNbaA0Av6S8ioKcZAfTVpkgH8L LJscHCvEPFmkgDRdVFwc0IgTdhxgW3Z+WMT+UoI+udz9E0xJ6lnKHttJvFFNuXhaJhhw XrqlN8fWZNRz5u53yvzO9pQKCRJkEsI9A39r3n2gjadVbntTq09/hIo7EKjo3Q3PwDuA D3wQUGynvHq/GpM/dOn2qKAhIBKPQ2pJf4VZp83vwUjZp7mFSQhWAhbrcVgcjeXtluzC HmQKP4VNG9zgw7oxkLTaBn/q2R2/RbxZunC+XKnjYAmr5XCCxg7c5hiGy0TY/dVoP5Xc x3fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sQgdyk3y6zB0hASByJVzzEmARHNFTqPRb6Kf1xIGKh0=; b=Tdk+biVrXCb693YSdQQ4CM+ig56RI4mjsRjEHwiGfidGBiv56A6WohAR9iTOsCVpOO sVDgY7IZNZQpPzLzf+y+0zI6Hh1nACDAVEvqMTG3Byx4Z9RQcAoGqxEBQti3Xhq7+AbJ gt+u/0rGpLOBQ75cQjnWAkGJe+uJfjTa7Mul5Axa+FLuG5FCt+LiL/93KvuPQzVgePIm OUDMRgnDCquZlO7ynXnc9VFL3fo2wtUytd8txWS9Lg5trDQJzJ/Yftw736YYA9Ycd2wC dTYnGfIMrrVhB5GCl4PlXD4O4JfWlGiq8Pa0Bh2IAB1PFnzNRaUvT0IIXbM605NgE/Am NzfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oSfs64PK; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jp13si14924902ejb.312.2020.06.25.15.58.10; Thu, 25 Jun 2020 15:58:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oSfs64PK; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728675AbgFYW6I (ORCPT + 2 others); Thu, 25 Jun 2020 18:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbgFYW6H (ORCPT ); Thu, 25 Jun 2020 18:58:07 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE4FC08C5DB for ; Thu, 25 Jun 2020 15:58:07 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id h19so8291184ljg.13 for ; Thu, 25 Jun 2020 15:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sQgdyk3y6zB0hASByJVzzEmARHNFTqPRb6Kf1xIGKh0=; b=oSfs64PKV38JXFXyuunReN5Z6kVfanjPQbqNiy926u6l8uP8SvoJ6QA1DQLHxjix2Y S3IXOYafJgGmvwLB1jbGL7oXyQZMpgGye1p03NHK02AMCX+MltYL/6746tIQNi+rMala 7zsZ5l9kSGKASL4LWwBu3CZbWjZt4WCTmSznFIGBSCbBDhPb8EUIDxG8s8B6a+TWNrf6 04EYLlyZWINjRId7DtwXo9XBcVJcVHTJ6oAWSoAowFPoIyX71kIRGtazxNgPp2FFQBZJ SXI3lU0TPTwLtGWDvoZgLdHB5QLV5iZv8XG/8WlWpkRpZ50JSNkzMEzQZs5Z30zekbpC pvww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sQgdyk3y6zB0hASByJVzzEmARHNFTqPRb6Kf1xIGKh0=; b=KybAmefhPpqerI5Kd7hBeGGpQgRBf1y1Lvfpihi2Dq5LOblUaTjtZe89eiI6TlHPg9 o4C6ie8q75eA84iHAVmRprNWaXZeISCiOSwQRK1AzroblQsPqYMPo38TvkvhsvshdQCY +cRz5BH1nwb7xSkmi6jddn8qTYHFdAvXh4PprJA3y8QqKvn2kyF/gC5EiSd3+v4um8Rz u2v3tbSpSzL4inWqzSTcu9m0AtTkdp9BMs2ySVUycNowveVA/tslXn32RsyjGwLvset6 MhWkyv2oLTQZyBbF4T1ddLsnriY0+/zpFG1pnFTcuzvJ6HMh8uyP6Gs7ySNmhFiuOtjb 6d0g== X-Gm-Message-State: AOAM5311YzzmIlXYhHGuNxuKfOCyWdAQN4jtUZxpHJl55SU0y0m7OcFb nnfhCzIUlHSbsGOD1DUzF2GNigxxvNY= X-Received: by 2002:a2e:94d0:: with SMTP id r16mr16807227ljh.351.1593125885668; Thu, 25 Jun 2020 15:58:05 -0700 (PDT) Received: from genomnajs.lan (c-d63ee155.152980-0-69706f6e6c79.bbcust.telenor.se. [85.225.62.214]) by smtp.gmail.com with ESMTPSA id d9sm126976ljc.117.2020.06.25.15.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 15:58:05 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Tomer Maimon Subject: [PATCH] spi: npcm-pspi: Convert to use GPIO descriptors Date: Fri, 26 Jun 2020 00:57:59 +0200 Message-Id: <20200625225759.273911-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The Nuvoton PSPI driver already uses the core to handle GPIO chip selects but is using the old GPIO number method and retrieveing the GPIOs in the probe() call. Switch it over to using GPIO descriptors saving a bunch of code and modernizing it. Compile tested med ARMv7 multiplatform config augmented with the Nuvoton arch and this driver. Cc: Tomer Maimon Signed-off-by: Linus Walleij --- drivers/spi/spi-npcm-pspi.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) -- 2.25.4 diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index 87cd0233c60b..56d10c4511db 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include #include @@ -344,16 +342,9 @@ static int npcm_pspi_probe(struct platform_device *pdev) struct npcm_pspi *priv; struct spi_master *master; unsigned long clk_hz; - struct device_node *np = pdev->dev.of_node; - int num_cs, i; - int csgpio; int irq; int ret; - num_cs = of_gpio_named_count(np, "cs-gpios"); - if (num_cs < 0) - return num_cs; - master = spi_alloc_master(&pdev->dev, sizeof(*priv)); if (!master) return -ENOMEM; @@ -418,24 +409,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) npcm_pspi_prepare_transfer_hardware; master->unprepare_transfer_hardware = npcm_pspi_unprepare_transfer_hardware; - master->num_chipselect = num_cs; - - for (i = 0; i < num_cs; i++) { - csgpio = of_get_named_gpio(np, "cs-gpios", i); - if (csgpio < 0) { - dev_err(&pdev->dev, "failed to get csgpio#%u\n", i); - goto out_disable_clk; - } - dev_dbg(&pdev->dev, "csgpio#%u = %d\n", i, csgpio); - ret = devm_gpio_request_one(&pdev->dev, csgpio, - GPIOF_OUT_INIT_HIGH, DRIVER_NAME); - if (ret < 0) { - dev_err(&pdev->dev, - "failed to configure csgpio#%u %d\n" - , i, csgpio); - goto out_disable_clk; - } - } + master->use_gpio_descriptors = true; /* set to default clock rate */ npcm_pspi_set_baudrate(priv, NPCM_PSPI_DEFAULT_CLK);