From patchwork Mon Nov 14 19:48:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13042767 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 75D5DC433FE for ; Mon, 14 Nov 2022 19:49:20 +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=xJnKmOgSpZ31UJ0yc8/hV4OZxHOIsKwpR0+Ih8XBCxA=; b=1scNkQzxkoj2x+ 1ZyUmKFdwMX84RM5aiwENGAtGDCCMsfgv8hhBzYzQ0cV70xnDkhJOe7pFf8E2mwO0RxIMF0elZhsA h1knZg+aCEYtFi/mX0UJYZCh9Cfpo4CB61HFV3sumXP8RkA2vYDhZ7E6kaVJTQkeCmVpB5PQvg/yk zfxg4Z5jT8ASlrXwdkqbQKibrCeVI/8fidKfQKJgo5XYo3CKGRjyRsTCBE6H9qnyzsLMxmafvf7yk Ey8A0ngeeLY34/lxtndIp4moxXkWYm6hjEd3hTUVMHN3W49ubPP/1tVNItHxJxGl828dWEKddT20o iPFmJEwuktuVMbFZEjMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oufRW-004G5y-CS; Mon, 14 Nov 2022 19:48:30 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oufRS-004G3E-VM for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2022 19:48:28 +0000 Received: by mail-pl1-x634.google.com with SMTP id p12so11051323plq.4 for ; Mon, 14 Nov 2022 11:48:24 -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=vyb04QF6WOviRSsxNxXugj6HWLnfLaTGenocXZ3ssCY=; b=ce4IvakUyWb+mgcTgEpB1LG7v3+47YR4xPyNIg67avm23p/tG+pOT6HcQ0b+R4UfOu E7GmFhV2EYceMIWJOm1SQHI3FUqIY43CesIrEuOKy50ZQfBj1+7/iIoOof9SR27vmD68 F+aTNa8KFAsgz3SjSjbFH9jVIeaX/mv0AK7aYyx4Hv4YOF7O/wfX5b/14Cu7xfnAio2G ZQ93yBe3nl19LcikDE3/fWRr3z3/tqFy8sApjhph8MMijGgoVJOYq1C0ynhVLE4VGZZz 8e7i7pZWV8tF6aupvHRnd1a8PBmYPmZOXa3uM8q7R71HVbRgfuxdWqyr/p1yFkibMG3i iKNw== 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=vyb04QF6WOviRSsxNxXugj6HWLnfLaTGenocXZ3ssCY=; b=aIs2reZ6CujX38YJVBihGLF77Gd/hN02q1D0oFpKA3jcAWBMBYi3YuVZqExfrlbP50 TSsMWXA4f/M/w8swPUH/OHOZkldzQuPs5l4w0QXUlcBIE/kc2ushcbyzqM6ROMiRWFZ8 NVpzT5Vl6sbugv3j+nCIqYce11sRoNimL9EOs2GVF8mpOkl9P8Xbpwk12XcggmkwN8Ub e/utD77vTTha9VECmUrgfLEnY5cQsK4nZHW04SLhy9riJPecQO5wTISre3L96MuzZ3iq NkH55EtM7PP2G45RWaS8UcJT3Ct9VT4eNeeqCyGbCGKHpaOfVl9MRzf5PbpREE1UIjNd AmYQ== X-Gm-Message-State: ANoB5pnw3fomb/Vr+R9ivsdgJvXmBmv9ERNV2YI+6d/cO/afgcCPLikI jyGYe+ydZqh4RwLT8TpWxdc= X-Google-Smtp-Source: AA0mqf4Dwe9kYtu+e65Y2upPLiiuDKKuoOdF2u5dTvJcqDJUmJA0jvMywXPWWNsQbZ4PdStAAwV8jQ== X-Received: by 2002:a17:902:f353:b0:187:85d:2522 with SMTP id q19-20020a170902f35300b00187085d2522mr834521ple.17.1668455303761; Mon, 14 Nov 2022 11:48:23 -0800 (PST) Received: from google.com ([2620:15c:9d:2:718:95ee:2678:497]) by smtp.gmail.com with ESMTPSA id h3-20020a056a00000300b0056c6c63fda6sm7121341pfk.3.2022.11.14.11.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 11:48:23 -0800 (PST) Date: Mon, 14 Nov 2022 11:48:20 -0800 From: Dmitry Torokhov To: Thomas Petazzoni , Lorenzo Pieralisi Cc: Pali =?iso-8859-1?q?Roh=E1r?= , Linus Walleij , Rob Herring , Krzysztof =?utf-8?q?Wilczy=C5=84ski?= , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] 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-20221114_114827_038939_F9168F21 X-CRM114-Status: GOOD ( 18.80 ) 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 --- v2: - free port->reset_name when reset GPIO is not found (Pali) - remove stray tab (Pali) I know Pali mentioned that there are pending changes to pci-mvebu, but I do not see any movement there, so I wonder if we could get this one applied so we can continue cleaning up gpiolib code. Thanks! drivers/pci/controller/pci-mvebu.c | 50 ++++++++++-------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 73db99035c2b..b77a77615cc6 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -1262,9 +1261,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 +1326,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,