Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1006060pxb; Thu, 28 Jan 2021 06:04:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGPHls80LLu/Jw9h+HX7ZQAQX4D6rQa3+rZz40zBtC4YFRMOdpl99+VKcIk4IZUqpg9TVo X-Received: by 2002:aa7:c583:: with SMTP id g3mr14782323edq.357.1611842664533; Thu, 28 Jan 2021 06:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611842664; cv=none; d=google.com; s=arc-20160816; b=M0UDtUP60gv8RgZBEy7SDpNtgZHAK3NmhEUICcZSsQJq5ffA/aOcLRilkt6BdC0/ge Y2u/CxdspipFrEdsvZYOhloAs2AU0kyOv4Sk/SFc4slbuy6L15PP1eUGCjU9tPlvWcaM 0ie4rzIKc0L4vvFTeIuDmxAY2dm61wHHQVAVyD5jCbJtENHKZKylGJSNO73tDyIRHb9d mDj4oWw6BB+hFidquIgeVAsUwIaghDSdAjort1sWJo30vbPhg4oyFPxmrC9yXh1w4zPI A5URTpC9te+W1k7hmfKiaE/NZOG8cL3RKzJHco9fHxVgJIyi50L9KWHtO6gukRxkN+uN RGBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=XOxn20oF6MVmDhSRUDlTSGsxscy9unTWAEXEx1yypcs=; b=qN74F/PNErNAjqv2MZeF+tuEjTNgqvw/WuBUR2e/ZGMqanAZJMXkI+27T9vPtA+tcM tu4psMWollQDKLjdoTzh4KKkR5dZ8rrvZXwaw30Y6r/UCQn2nAmjobHTTcGTGEX/Pxum cqNOUFyaGcScNqMkqMcKUfaxO19ck77GBj5YIlx5zXZVHnRiKFFzkOgt4dkEqQ0mWfaJ iZ4n6Jt/5JeevCoA4bpxrX7Cbo3T+GeWZwt35dksjNqzxwIFShMcdV2tMjin4mbb7BFj DDM75IhfP2qXd50oCoaJabW3pC8uAfiskMzkzPcdezFU9+n9WyXUaaQ/tt8dsEvVCIfv nxvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si2587987eji.560.2021.01.28.06.03.52; Thu, 28 Jan 2021 06:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbhA1N7O (ORCPT + 99 others); Thu, 28 Jan 2021 08:59:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbhA1N7D (ORCPT ); Thu, 28 Jan 2021 08:59:03 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1FF0C0613D6 for ; Thu, 28 Jan 2021 05:58:22 -0800 (PST) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l57oR-0006i7-4l; Thu, 28 Jan 2021 14:58:19 +0100 Received: from ore by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1l57oG-0006AS-9M; Thu, 28 Jan 2021 14:58:08 +0100 Date: Thu, 28 Jan 2021 14:58:08 +0100 From: Oleksij Rempel To: Linus Walleij Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Ahmad Fatoum , linux-iio , Robin van der Gracht , William Breathitt Gray , "linux-kernel@vger.kernel.org" , Rob Herring , Pengutronix Kernel Team , David Jander Subject: Re: [PATCH v4 2/2] counter: add IRQ or GPIO based pulse counter Message-ID: <20210128135808.ttvd2xxjkmsqanr7@pengutronix.de> References: <20210126131239.8335-1-o.rempel@pengutronix.de> <20210126131239.8335-3-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 14:57:01 up 57 days, 4:03, 33 users, load average: 0.08, 0.05, 0.00 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 09:24:08AM +0100, Linus Walleij wrote: > Hi Oleksij, > > thanks for your patch! > > On Tue, Jan 26, 2021 at 2:15 PM Oleksij Rempel wrote: > > > + priv->irq = platform_get_irq(pdev, 0); > > + if (priv->irq < 0) { > > + dev_err(dev, "failed to map GPIO to IRQ: %d\n", priv->irq); > > + return priv->irq; > > + } > > + > > + priv->gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_IN); > > + if (IS_ERR(priv->gpio)) > > + return dev_err_probe(dev, PTR_ERR(priv->gpio), "failed to get gpio\n"); > > I would attempt to get the IRQ from the GPIO if not defined explicitly > in the device tree. > > priv->gpio = devm_gpiod_get_optional(...) > if (priv->gpio) { > /* Attempt to look up IRQ */ > irq = gpiod_to_irq(priv->irq); > } > priv->irq = platfform_get_irq(...) > if (priv->irq < 0 && irq > 0) { > /* Use the GPIO-related IRQ */ > priv->irq = irq; > } else if (priv->irq < 0) { > /* Error */ > } > > This way the example in the device tree binding which only defines > a GPIO and no interrupt will work if the GPIO chip provides an > IRQ mapping. > Ok, thx! I'll send updated version after dt-binding discussion Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |