From patchwork Fri Nov 3 13:03:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 10039987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6AAAE6032D for ; Fri, 3 Nov 2017 13:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66D9E29511 for ; Fri, 3 Nov 2017 13:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B80E295D7; Fri, 3 Nov 2017 13:04:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FE7B29511 for ; Fri, 3 Nov 2017 13:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249AbdKCNEO (ORCPT ); Fri, 3 Nov 2017 09:04:14 -0400 Received: from mga09.intel.com ([134.134.136.24]:64441 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751381AbdKCNEO (ORCPT ); Fri, 3 Nov 2017 09:04:14 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Nov 2017 06:04:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,338,1505804400"; d="scan'208";a="917235821" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 03 Nov 2017 06:04:11 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DA2F550B; Fri, 3 Nov 2017 15:03:40 +0200 (EET) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: Andy Shevchenko Subject: [PATCH v3 3/5] iio: proximity: sx9500: Set IRQ pin to direction-input if necessary Date: Fri, 3 Nov 2017 15:03:38 +0200 Message-Id: <20171103130340.42459-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171103130340.42459-1-andriy.shevchenko@linux.intel.com> References: <20171103130340.42459-1-andriy.shevchenko@linux.intel.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the new more strict ACPI gpio code the DSDT's IoRestriction flags are honored on gpiod_get(), but in some DSDT's it is wrong, so explicitly call gpiod_direction_input() on the IRQ GPIO if necessary. Signed-off-by: Andy Shevchenko --- drivers/iio/proximity/sx9500.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index eb687b3dd442..3cf054155779 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -892,8 +893,13 @@ static void sx9500_gpio_probe(struct i2c_client *client, gpiod_int = devm_gpiod_get(dev, "interrupt", GPIOD_IN); if (IS_ERR(gpiod_int)) dev_err(dev, "gpio get irq failed\n"); - else + else { + if (gpiod_get_direction(gpiod_int) != GPIOF_DIR_IN) { + dev_warn(dev, FW_BUG "IRQ GPIO not in input mode, fixing\n"); + gpiod_direction_input(gpiod_int); + } client->irq = gpiod_to_irq(gpiod_int); + } } data->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);