From patchwork Tue Sep 6 05:01:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12966815 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 EB17CC6FA83 for ; Tue, 6 Sep 2022 05:03: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=ILTHNZXgeYFb1TzWJJLgGwgH5vzjn4UQyuqu/Jce4m0=; b=BOvuAqQo0mx0su h1cVqS1NYtfDcfayMv3LizTzanWmH+mhNr7ZCq08lTGNci935/kU3xqtOFlPASABBw362romQd9Ry jeDarUYzcLhJecOzRXGnOxlOsqZqjTqHdPRm8c4BrrqDrKoiMS/4d1ptpapnmqU/mVX99Cjl4uH1w LqnFXC/Hgs0i3VPTqktql98fx/KZ3sUfbYrqmeh8MJpS8/kVhZIcxGCcFTU5VkEsNKGCQUoahIcRI v7Qm1lKZRpozkRY4AXfY3eOC3SiglsMxH7VgTQL4OKpX9CRkBek8YGsyOkH3ySZP3gckyS3FrI+3N KdhC4D+7j2klWDFdCQHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVQit-009Uus-Or; Tue, 06 Sep 2022 05:02:07 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVQih-009Ul2-1y for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2022 05:01:57 +0000 Received: by mail-pj1-x1033.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so13757243pjq.3 for ; Mon, 05 Sep 2022 22:01:51 -0700 (PDT) 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; bh=Ldy1JheZ7FCt/jxCBpowwGYgtHJwSVrIu+wqfaCl/vY=; b=nS/IBGO0rkxxmQBAJnHTCAVhZXQMmuvxeYcH4cs0a+YlhuWNKPCfsikPzsfr+LtkfS 6dFJ5Am/5uICOdFpIGq/cx5Ty18vXBL5HjnMo25/A19VuntRo3kInFc5HXDwqXipYAXa lWfAnEwLa24gqV2ERkHMSTaM/oY4KPV5rCTgrmuDgm+veZmX3NhMMcfHii8y1J4o6Kb9 Lw0bP2cIXWGns+aWg8QGuWN0SFgs2KVVSyTlxcBThiPpAceQ//nY5KRXd3hwpW+MT6js NWTXNndRl3RG92hAeaDqG4JS0NklRtEHizXIr+N822eajjg/pYzeW8CKOgACy83iNz4M 6YKg== 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; bh=Ldy1JheZ7FCt/jxCBpowwGYgtHJwSVrIu+wqfaCl/vY=; b=sLHwLOI3Xd+jCkwvzYgKAs4dKjcz8DGdHo7Dxy5Tf6zqez19hBNbR8rbSYnP85GFxB p5lIqUZw1sG1J+ROVWtAtZFo3ov3jWtgIUmD4dW6I9cTFCoGSHLJVlnrsOLdUcQYrHyn QuOgkjfQsGWqFKgvMcmRrg1dgyOz79rZpS/ae1fdh2CxMvQTiXdkflGEckYwToG40l8K 0XVFzAhkJ9FpdvjhtQR5hjgieWSpfJRIctOLwMYezsmm2ZmJXg9th44slq4eS5H2GpVf ivy+ecBAhouSozeFbkwOR/7R7tvGQXKNa3AuDxnEgZFKMA4/tyEbDwzgCMGNXNj8qfFE CeuQ== X-Gm-Message-State: ACgBeo0AkeAqFBl0n1O+cOKXHR+33OaIP1wBU3Pqfe5QjKMOlOrn6Geg gYvFtqC4IwNykre8Wp7mXvk= X-Google-Smtp-Source: AA6agR6eECcxcWLwzhSb2s5VjWwhFiSzmD6nMYitrRoHBLxpoQHYUvHfxSxhVHWM2Ica/isLr3/jyw== X-Received: by 2002:a17:903:1ce:b0:16e:f510:6666 with SMTP id e14-20020a17090301ce00b0016ef5106666mr51788528plh.158.1662440511104; Mon, 05 Sep 2022 22:01:51 -0700 (PDT) Received: from google.com ([2620:15c:202:201:1190:fbfa:ae95:111c]) by smtp.gmail.com with ESMTPSA id e15-20020aa798cf000000b005364e0ec330sm203458pfm.59.2022.09.05.22.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 22:01:50 -0700 (PDT) Date: Mon, 5 Sep 2022 22:01:47 -0700 From: Dmitry Torokhov To: Lee Jones Cc: Maxime Coquelin , Alexandre Torgue , Francesco Dolcini , Linus Walleij , Marcel Ziswiler , Bartosz Golaszewski , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mfd: stmpe: 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-20220905_220155_143076_88AF64BD X-CRM114-Status: GOOD ( 17.17 ) 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 --- drivers/mfd/stmpe.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 987e251d90ae..0c4f74197d3e 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -8,14 +8,13 @@ */ #include -#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -30,17 +29,12 @@ * @irq_trigger: IRQ trigger to use for the interrupt to the host * @autosleep: bool to enable/disable stmpe autosleep * @autosleep_timeout: inactivity timeout in milliseconds for autosleep - * @irq_over_gpio: true if gpio is used to get irq - * @irq_gpio: gpio number over which irq will be requested (significant only if - * irq_over_gpio is true) */ struct stmpe_platform_data { int id; unsigned int blocks; unsigned int irq_trigger; bool autosleep; - bool irq_over_gpio; - int irq_gpio; int autosleep_timeout; }; @@ -1349,13 +1343,6 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata, if (pdata->id < 0) pdata->id = -1; - pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0, - &pdata->irq_trigger); - if (gpio_is_valid(pdata->irq_gpio)) - pdata->irq_over_gpio = 1; - else - pdata->irq_trigger = IRQF_TRIGGER_NONE; - of_property_read_u32(np, "st,autosleep-timeout", &pdata->autosleep_timeout); @@ -1381,6 +1368,7 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum) struct stmpe_platform_data *pdata; struct device_node *np = ci->dev->of_node; struct stmpe *stmpe; + struct gpio_desc *irq_gpio; int ret; u32 val; @@ -1434,18 +1422,20 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum) if (ci->init) ci->init(stmpe); - if (pdata->irq_over_gpio) { - ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio, - GPIOF_DIR_IN, "stmpe"); - if (ret) { - dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", - ret); - return ret; - } + irq_gpio = devm_gpiod_get_optional(ci->dev, "irq", GPIOD_ASIS); + ret = PTR_ERR_OR_ZERO(irq_gpio); + if (ret) { + dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", ret); + return ret; + } - stmpe->irq = gpio_to_irq(pdata->irq_gpio); + if (irq_gpio) { + stmpe->irq = gpiod_to_irq(irq_gpio); + pdata->irq_trigger = gpiod_is_active_low(irq_gpio) ? + IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH; } else { stmpe->irq = ci->irq; + pdata->irq_trigger = IRQF_TRIGGER_NONE; } if (stmpe->irq < 0) {