From patchwork Wed Dec 7 21:07:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13067659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1372CC4708D for ; Wed, 7 Dec 2022 21:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Y4b5NZ3dZtRvrMvQS+45Rb5/eJoWxz3UQOPKO096dh4=; b=aSB3r/5Tig6O9u drpweQ9Cbq6APxVa4F5RUhooxScT23Z6uNMzlDQfRBtsT8CmtwtxRPnP9DQLV8TFbrzrBSHWq5K9X ghtkq06LjYPkwA5VGe5a989wZyecjJesTqWVzNZ0RbUkL5vijEm/Vh8Kpe+lJ0n1adS6OFXkRdRhe Hs2eDYZO9u4wxRn+7Fw/v1d6Agxd/ZAPJjZpIfA6b5RDn54ZJlvrrSRpy7Z8MhO/4LPneIcthrgE4 UMvnbyRhh1qoM9UjEccUjk//T5Wq6fxDALE8saqDMGvG8NPXoregShwkARhVVlMja5mQKtbQ0mW0d zkiTLUxvKPJy4Ixd6lhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p31dP-00CWnn-IE; Wed, 07 Dec 2022 21:07:19 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p31dM-00CWd8-41 for linux-arm-kernel@lists.infradead.org; Wed, 07 Dec 2022 21:07:17 +0000 Received: by mail-pf1-x435.google.com with SMTP id c7so15195140pfc.12 for ; Wed, 07 Dec 2022 13:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=V995C6MwqtUAmTG71E4cb1Pyxeu/S0wZo/QPEUz5JyI=; b=LpQoDdBWH7AjZeARZIav9Ud/rp1eZav/ptYhNkj5zUs0aFgG1QvN3QpxTsdlTLfxQR +U07pkjcNK24yiRBCGfqbHKVQqHgZ59x8Dukmo3jhYItpStJGQjJgkbeY9lg1t8S9HGH yGRbNfl//dN49Tx0QTg8BglhjxBCcorbXlOzpdqMB3sdPYF+NFd1pmGteUpI7OtIWlhA 1+xvxpxN4T+QcploU54kSawaYMNk6EXzxqMI/1E/0ZhlMNFuVXM/C0Y1B1N5MMofO0dx 4jd5ol7KDGkncltwAkp2x7T9KHW1CeEtawu+NB5s9UxB7+BX9lBuaYLLHsGYDBU6fMYI ckew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V995C6MwqtUAmTG71E4cb1Pyxeu/S0wZo/QPEUz5JyI=; b=LkIz6x1UcQfEz0q1C+gCowQR5kx/xSisny+6R+wk0klFfo4HwHnlQk9TGN4NoZchDQ hviS0MnlcRJNF7/PLmhXQAUckep+PcBTD0Dw9EBQkb+95SZKlw9Fgr+5Xz6lMe+ajTwJ gJIe/Mh/j2m0dEL+j8dfdb4bzTlHA7Izg4NezpELHQMOuXNLJCBxdPFjfvXId1Hr8gkv QQQRnAcDL5MlLGeuVQONxINzUEvU1Q/TQ4laVzYdoLpII5sMOQaJWWjVUWZtw8jMU2nt Dfe1d9RODcj6ULWIQW2xEkp4W6Oc/3G4AZuxd+gLvqz1ykAgvBDfR8F6Di+nHKy6KNrO RN0Q== X-Gm-Message-State: ANoB5pn0oRpErRCGg5a5oNFfsfii8eCZotdFEWhDrT/rX6MBD+frwyOA RasozQ+7X7MwI3ux953jj7Q= X-Google-Smtp-Source: AA0mqf4TRbwld+Rgp66Y4tIL68ENi6FOYJj8KLqyjxn7dTcjwWbWKSIY7F4QVxHmA4adoAqSlKP3pA== X-Received: by 2002:a63:f5a:0:b0:470:18d4:f18d with SMTP id 26-20020a630f5a000000b0047018d4f18dmr66492091pgp.295.1670447234255; Wed, 07 Dec 2022 13:07:14 -0800 (PST) Received: from google.com ([2620:15c:9d:2:7a61:38c7:d37a:7f43]) by smtp.gmail.com with ESMTPSA id y23-20020a17090264d700b00187197c499asm15102485pli.164.2022.12.07.13.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 13:07:13 -0800 (PST) Date: Wed, 7 Dec 2022 13:07:10 -0800 From: Dmitry Torokhov To: Bjorn Helgaas Cc: Thomas Petazzoni , Lorenzo Pieralisi , Pali =?iso-8859-1?q?Roh=E1r?= , Rob Herring , Krzysztof =?utf-8?q?Wilczy=C5=84ski?= , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] PCI: mvebu: switch to using gpiod API Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221207_130716_213336_A246CC46 X-CRM114-Status: GOOD ( 17.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib. Signed-off-by: Dmitry Torokhov --- v3: - add #include to avoid compile errors. This was previously included indirectly via linux/of_gpio.h -> linux/gpio/driver.h v2: - free port->reset_name when reset GPIO is not found (Pali) - remove stray tab (Pali) This is the last user of of_get_named_gpio_flags() in the "next" tree. Thanks! drivers/pci/controller/pci-mvebu.c | 51 ++++++++++-------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 73db99035c2b..600964ba174c 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -11,15 +11,15 @@ #include #include #include -#include +#include #include #include +#include #include #include #include #include #include -#include #include #include @@ -1262,9 +1262,8 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, struct mvebu_pcie_port *port, struct device_node *child) { struct device *dev = &pcie->pdev->dev; - enum of_gpio_flags flags; u32 slot_power_limit; - int reset_gpio, ret; + int ret; u32 num_lanes; port->pcie = pcie; @@ -1328,40 +1327,24 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, port->name, child); } - reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags); - if (reset_gpio == -EPROBE_DEFER) { - ret = reset_gpio; + port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset", + port->name); + if (!port->reset_name) { + ret = -ENOMEM; goto err; } - if (gpio_is_valid(reset_gpio)) { - unsigned long gpio_flags; - - port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset", - port->name); - if (!port->reset_name) { - ret = -ENOMEM; + port->reset_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(child), + "reset", GPIOD_OUT_HIGH, + port->name); + ret = PTR_ERR_OR_ZERO(port->reset_gpio); + if (ret) { + if (ret != -ENOENT) goto err; - } - - if (flags & OF_GPIO_ACTIVE_LOW) { - dev_info(dev, "%pOF: reset gpio is active low\n", - child); - gpio_flags = GPIOF_ACTIVE_LOW | - GPIOF_OUT_INIT_LOW; - } else { - gpio_flags = GPIOF_OUT_INIT_HIGH; - } - - ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags, - port->reset_name); - if (ret) { - if (ret == -EPROBE_DEFER) - goto err; - goto skip; - } - - port->reset_gpio = gpio_to_desc(reset_gpio); + /* reset gpio is optional */ + port->reset_gpio = NULL; + devm_kfree(dev, port->reset_name); + port->reset_name = NULL; } slot_power_limit = of_pci_get_slot_power_limit(child,