From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753517AbbCaHrN (ORCPT ); Tue, 31 Mar 2015 03:47:13 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:36121 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbbCaHrI (ORCPT ); Tue, 31 Mar 2015 03:47:08 -0400 X-AuditID: cbfee61a-f79c06d000004e71-33-551a50f79a7d From: Robert Baldyga To: cw00.choi@samsung.com Cc: myungjoo.ham@samsung.com, rogerq@ti.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com, Robert Baldyga Subject: [PATCH 3/4] extcon: usb-gpio: make debounce value configurable in devicetree Date: Tue, 31 Mar 2015 09:46:02 +0200 Message-id: <1427787963-23562-4-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1427787963-23562-1-git-send-email-r.baldyga@samsung.com> References: <1427787963-23562-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgluLIzCtJLcpLzFFi42I5/e+xoO73AKlQg9//tCyuf3nOajH/yDlW i8u75rBZrD1yl93iduMKNosHh3eyW/Q80nJg9+jbsorR4/iN7UwenzfJBTBHcdmkpOZklqUW 6dslcGWsXbaOqeA6X8XU6TdZGhjn8HQxcnJICJhI/N11ghnCFpO4cG89WxcjF4eQwHRGiemN i5ghnJ+MEtdWr2EEqWIT0JHY8n0CkM3BISIgKdGyzwykhllgNaPE9zv7wCYJC4RL/DnzGcxm EVCVeHj/KztIPa+Aq8TOKXIQy+QkTh6bzApicwq4SczbtxxsvBBQyayrn9knMPIuYGRYxSia WpBcUJyUnmuoV5yYW1yal66XnJ+7iREcPs+kdjCubLA4xCjAwajEw3vhnmSoEGtiWXFl7iFG CQ5mJRHePR+BQrwpiZVVqUX58UWlOanFhxilOViUxHmV7NtChATSE0tSs1NTC1KLYLJMHJxS DYz6Xxe6tXGbmqsGP/guwHmrx6PxWWXTPOuJ7+YkSbFXdJ+UK31aXfB02omYe03TBD7pKZkI NM7aLGRyX5HD7IzGH8N1nu9zOM9o9DjydtgbMO4vyj0j9OdGg2fA5T/bdHl/mq09/UVtXk9R mebneSF/9vauE+4UYS+atXeX4MGQXGnGyFXcNkosxRmJhlrMRcWJAFwgCVgbAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds devicetree property for setting debounce value. It allows to set debounce time shorter or longer depending on the needs of given platform. Signed-off-by: Robert Baldyga --- drivers/extcon/extcon-usb-gpio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/extcon/extcon-usb-gpio.c b/drivers/extcon/extcon-usb-gpio.c index 02ff40e..86e3ece 100644 --- a/drivers/extcon/extcon-usb-gpio.c +++ b/drivers/extcon/extcon-usb-gpio.c @@ -130,6 +130,7 @@ static int usb_extcon_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct usb_extcon_info *info; + u32 debounce; int ret; if (!np) @@ -140,6 +141,11 @@ static int usb_extcon_probe(struct platform_device *pdev) return -ENOMEM; info->dev = dev; + + ret = of_property_read_u32(np, "debounce", &debounce); + if (ret < 0) + debounce = USB_GPIO_DEBOUNCE_MS; + info->id_gpiod = devm_gpiod_get_optional(&pdev->dev, "id"); info->vbus_gpiod = devm_gpiod_get_optional(&pdev->dev, "vbus"); @@ -161,16 +167,14 @@ static int usb_extcon_probe(struct platform_device *pdev) } if (info->id_gpiod) - ret = gpiod_set_debounce(info->id_gpiod, - USB_GPIO_DEBOUNCE_MS * 1000); + ret = gpiod_set_debounce(info->id_gpiod, debounce * 1000); if (!ret && info->vbus_gpiod) { - ret = gpiod_set_debounce(info->vbus_gpiod, - USB_GPIO_DEBOUNCE_MS * 1000); + ret = gpiod_set_debounce(info->vbus_gpiod, debounce * 1000); if (ret < 0 && info->id_gpiod) gpiod_set_debounce(info->vbus_gpiod, 0); } if (ret < 0) - info->debounce_jiffies = msecs_to_jiffies(USB_GPIO_DEBOUNCE_MS); + info->debounce_jiffies = msecs_to_jiffies(debounce); INIT_DELAYED_WORK(&info->wq_detcable, usb_extcon_detect_cable); -- 1.9.1