From patchwork Sun Sep 24 14:56:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114131 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1644878qgf; Sun, 24 Sep 2017 08:01:29 -0700 (PDT) X-Received: by 10.84.218.71 with SMTP id f7mr4872912plm.145.1506265288823; Sun, 24 Sep 2017 08:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265288; cv=none; d=google.com; s=arc-20160816; b=VoaT9RyfMk2q1nDs8nXjrc8S154ZYHu/bN7ppgsN1t5NyCsC8ud7W3JdKi8rDRxND6 NlMhSurfSZfwnS4qrzcaYq7sAmM8wkAZwj61G3tvF34kOSxpfFNJTSDRIdHuklhaJaCI hS9WVy/UATQSSYUN9A+lPtbDMciKGXDIk3aha+rgYHr2NzTS2t+xGSza8kI9dLg7qomI e1GO3HZRjE2HST/4Tsaf8n5rUWyyyFIOtAd7ipi+1nUWVf5wF1t3k+rEf5iF9eQzUERT GS3sXUI3DjZsgeD7fbtYtVKsIN+PsZ49Cxbt7KrqUB3UmU5yAM1izTVI2JmhddEVBn0e QuoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=C0aF5SXNxs9r/RIQU+HmWMsxLjQkWWmL1d3e0Y54mKg=; b=LfpTkDwaXTYDNCb6BXN5QRm+iFr2uKWghO4gVt9QARxQSeykxA/cgFZ9wRLGKfzlLv I4PYXbSE46Vmkt76xS24uNVQf+oDcHkBx1pIkBzjM70kb7iQiNQN/QmFsvmbspO+biqT fMQ++CkIjkHnutJUokuc36dp1UeUvFayoJnyStXul7QiHS9FA1Y5rAw37zr20ZHZzkrU xOYJGMaHZVnIZUzXlofpeOktEnx/X8IqFluLdMCRLP+93BbnvSs5K8uHYnGpj6t6aCN/ pGm0kNytVc/K2R8u/a4HnJQdO6V5DKqKGc1NofncFJxHSIM72b8iNC1t6cYk30HTxaiP Q+SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GbGj0DDq; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z31si2743608plb.732.2017.09.24.08.01.28; Sun, 24 Sep 2017 08:01:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GbGj0DDq; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752510AbdIXPB2 (ORCPT + 5 others); Sun, 24 Sep 2017 11:01:28 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:46449 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbdIXPB1 (ORCPT ); Sun, 24 Sep 2017 11:01:27 -0400 Received: by mail-pg0-f42.google.com with SMTP id i130so2732497pgc.3 for ; Sun, 24 Sep 2017 08:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/9fxiD6ys0Hzzn3dJW1TOtNYjkdHftdU0/8lE6VRkvg=; b=GbGj0DDquQMc1XUW7vc+p3k4scsM8/AYScpVRpSlplm/UML60npVKMdgrcb8QyksSB wQMo19A9tEN+3FD8ev0GMgjPx7t5DbI4SDWzJ6LZHg4HcVOPzn0tGa2vGqZ7KS46zcmj bdySTQ4YNj3BxX+ewwKPVk1Fcs/reSAVuVQ/U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/9fxiD6ys0Hzzn3dJW1TOtNYjkdHftdU0/8lE6VRkvg=; b=UkiX6FRjigzfp0/B69U3KNGxEj/Ur6yPGrohbWF09ndfB43PukZrJHOy98BJSdblfC XImuk/zLsgKmLDHSssBQ0E0HHmtZpYOMzZ3JMQe1qvAmZHS2LOQGHMykakwBoEnYdyAW ACMhG8mwUxvvW+HVMQAmKVSHN8iBcDWaQbMmFC3wQCxOGTxZeBlm8qTPyCfFlrD8X/7g 26Ka6fJjkn/cR8B279fCrhdfRjt3sVTaURjW0eaTYsYDUho70cPLM68vq0jQj+CxKhc+ DCVwtc/mGw9WHpq0EXmVRmEqg1AKwTQOEGcNRda1guzwUCgq6gXvR0PWT6E8WoQ9oJ6W MthA== X-Gm-Message-State: AHPjjUiXW7cqQS17h8rBIis9BJwBAauUJ7ChYIfdg7d+i3rakw3xFnzl 1sTVf4R+hhYhjHZvGuHiP8jSuA== X-Google-Smtp-Source: AOwi7QA+qWxXrWIN34W0uqFLcrJjKl3yGIKVrQJe5CsE7z3L75AdhvW6Z57eveWedQG+ltfh7mdfEA== X-Received: by 10.84.128.69 with SMTP id 63mr5025606pla.119.1506265286876; Sun, 24 Sep 2017 08:01:26 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.08.00.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:01:26 -0700 (PDT) From: Linus Walleij To: MyungJoo Ham , Chanwoo Choi Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Stultz , Mike Lockwood , Guenter Roeck , Linus Walleij Subject: [PATCH 6/8] extcon: gpio: Get debounce setting from device property Date: Sun, 24 Sep 2017 16:56:20 +0200 Message-Id: <20170924145622.4031-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170924145622.4031-1-linus.walleij@linaro.org> References: <20170924145622.4031-1-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Look up the debouncing value using the device property that will pick it from device tree or ACPI DSDT or whatever is available. Reintroduce the debounce handling previously deleted in the series, setting the delayed worker to delay 0 ms if the GPIO driver supports debouncing for us, else just delay the reading of the value delayed by jiffies. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Chanwoo Choi diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 6d9cb4ed11c2..8fc52631c8a2 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -35,7 +36,6 @@ * value. * @gpiod: GPIO descriptor for this external connector. * @extcon_id: The unique id of specific external connector. - * @debounce: Debounce time for GPIO IRQ in ms. * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ @@ -45,7 +45,6 @@ struct gpio_extcon_data { unsigned long debounce_jiffies; struct gpio_desc *gpiod; unsigned int extcon_id; - unsigned long debounce; bool check_on_resume; }; @@ -74,6 +73,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) struct gpio_extcon_data *data; struct device *dev = &pdev->dev; unsigned long irq_flags; + u32 debounce_usecs; int irq; int ret; @@ -109,6 +109,15 @@ static int gpio_extcon_probe(struct platform_device *pdev) return -ENOMEM; } + ret = device_property_read_u32(dev, "input-debounce", &debounce_usecs); + if (ret || !debounce_usecs) { + dev_err(dev, "illegal debounce value, set to 20 ms\n"); + debounce_usecs = 20000; + } + ret = gpiod_set_debounce(data->gpiod, debounce_usecs); + if (ret) + data->debounce_jiffies = msecs_to_jiffies(debounce_usecs * 1000); + ret = devm_extcon_dev_register(dev, data->edev); if (ret < 0) return ret;