From patchwork Mon Aug 17 07:00:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 253705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C3FBC433E3 for ; Mon, 17 Aug 2020 07:03:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0D5D20758 for ; Mon, 17 Aug 2020 07:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647810; bh=cZA9ZUARN+utcYkCJWoSAM3zaWPeBpxOmpgTjJgh5s8=; h=From:To:Subject:Date:In-Reply-To:References:List-ID:From; b=keVtJXaqdHr8f9To4B9xxUUj/vFrH48yDn5blELB64DNpXJHJMmab1j53E3DCXznE I4kocpXlRqx7ABmBVEJHCZbyGMwK/bVQo9YglGRiF8ENQxTf4lTjl9lXMYN17dWBGV vysC7AzUZ7/C/UHpnf+eKejBDJmRnvTbtlo1A2H4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbgHQHDO (ORCPT ); Mon, 17 Aug 2020 03:03:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:41730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbgHQHA3 (ORCPT ); Mon, 17 Aug 2020 03:00:29 -0400 Received: from localhost.localdomain (unknown [194.230.155.242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22A2A207FB; Mon, 17 Aug 2020 07:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597647628; bh=cZA9ZUARN+utcYkCJWoSAM3zaWPeBpxOmpgTjJgh5s8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tD4Cr2JesNZLkoLInAuT7zRPnlGs2KbpxEfpPfVFYqhs8MJ/zpMI7culDGiYnTT6v XzNbsKqHjbMt39ifPAlL0qdmVqmakqTLQKo9wIHmw2kvf/k1PO/Ikbvf1OYBGb9eyW RIG5syYrs+k6kw+ToWuVQPRr3YuC42EM8Qlpy9X8= From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Rob Herring , Krzysztof Kozlowski , Vijai Kumar K , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v2 05/13] extcon: ptn5150: Use generic "interrupts" property Date: Mon, 17 Aug 2020 09:00:01 +0200 Message-Id: <20200817070009.4631-6-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817070009.4631-1-krzk@kernel.org> References: <20200817070009.4631-1-krzk@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Interrupts do not have to be always GPIO based so instead of expecting "int-gpios" property and converting the GPIO to an interrupt, just accept any interrupt via generic "interrupts" property. Keep support for old "int-gpios" for backward compatibility. Signed-off-by: Krzysztof Kozlowski --- drivers/extcon/extcon-ptn5150.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/extcon/extcon-ptn5150.c b/drivers/extcon/extcon-ptn5150.c index 5f5252752644..12e52ddbd77e 100644 --- a/drivers/extcon/extcon-ptn5150.c +++ b/drivers/extcon/extcon-ptn5150.c @@ -239,11 +239,6 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, info->dev = &i2c->dev; info->i2c = i2c; - info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); - if (IS_ERR(info->int_gpiod)) { - dev_err(dev, "failed to get INT GPIO\n"); - return PTR_ERR(info->int_gpiod); - } info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_IN); if (IS_ERR(info->vbus_gpiod)) { dev_err(dev, "failed to get VBUS GPIO\n"); @@ -267,22 +262,30 @@ static int ptn5150_i2c_probe(struct i2c_client *i2c, return ret; } - if (info->int_gpiod) { + if (i2c->irq > 0) { + info->irq = i2c->irq; + } else { + info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN); + if (IS_ERR(info->int_gpiod)) { + dev_err(dev, "failed to get INT GPIO\n"); + return PTR_ERR(info->int_gpiod); + } + info->irq = gpiod_to_irq(info->int_gpiod); if (info->irq < 0) { dev_err(dev, "failed to get INTB IRQ\n"); return info->irq; } + } - ret = devm_request_threaded_irq(dev, info->irq, NULL, - ptn5150_irq_handler, - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, - i2c->name, info); - if (ret < 0) { - dev_err(dev, "failed to request handler for INTB IRQ\n"); - return ret; - } + ret = devm_request_threaded_irq(dev, info->irq, NULL, + ptn5150_irq_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + i2c->name, info); + if (ret < 0) { + dev_err(dev, "failed to request handler for INTB IRQ\n"); + return ret; } /* Allocate extcon device */