[{"id":1775093,"web_url":"http://patchwork.ozlabs.org/comment/1775093/","msgid":"<59C9B93D.2080109@samsung.com>","list_archive_url":null,"date":"2017-09-26T02:19:41","subject":"Re: [PATCH 5/8] extcon: gpio: Request reasonable interrupts","submitter":{"id":46832,"url":"http://patchwork.ozlabs.org/api/people/46832/","name":"Chanwoo Choi","email":"cw00.choi@samsung.com"},"content":"Hi Linus,\n\nOn 2017년 09월 24일 23:56, Linus Walleij wrote:\n> The only thing that makes sense is to request a falling edge interrupt\n> if the line is active low and a rising edge interrupt if the line is\n> active high, so just do that and get rid of the assignment from\n> platform data. The GPIO descriptor knows if the line is active high\n> or low.\n> \n> Also make irq a local variable in probe(), it's not used anywhere else.\n> \n> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>\n> ---\n>  drivers/extcon/extcon-gpio.c | 29 +++++++++++++++++++----------\n>  1 file changed, 19 insertions(+), 10 deletions(-)\n\nLooks good to me.\nAcked-by: Chanwoo Choi <cw00.choi@samsung.com>\n\n> \n> diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c\n> index 86f3ec6d6014..6d9cb4ed11c2 100644\n> --- a/drivers/extcon/extcon-gpio.c\n> +++ b/drivers/extcon/extcon-gpio.c\n> @@ -30,26 +30,22 @@\n>  /**\n>   * struct gpio_extcon_data - A simple GPIO-controlled extcon device state container.\n>   * @edev:\t\tExtcon device.\n> - * @irq:\t\tInterrupt line for the external connector.\n>   * @work:\t\tWork fired by the interrupt.\n>   * @debounce_jiffies:\tNumber of jiffies to wait for the GPIO to stabilize, from the debounce\n>   *\t\t\tvalue.\n>   * @gpiod:\t\tGPIO descriptor for this external connector.\n>   * @extcon_id:\t\tThe unique id of specific external connector.\n>   * @debounce:\t\tDebounce time for GPIO IRQ in ms.\n> - * @irq_flags:\t\tIRQ Flags (e.g., IRQF_TRIGGER_LOW).\n>   * @check_on_resume:\tBoolean describing whether to check the state of gpio\n>   *\t\t\twhile resuming from sleep.\n>   */\n>  struct gpio_extcon_data {\n>  \tstruct extcon_dev *edev;\n> -\tint irq;\n>  \tstruct delayed_work work;\n>  \tunsigned long debounce_jiffies;\n>  \tstruct gpio_desc *gpiod;\n>  \tunsigned int extcon_id;\n>  \tunsigned long debounce;\n> -\tunsigned long irq_flags;\n>  \tbool check_on_resume;\n>  };\n>  \n> @@ -77,21 +73,34 @@ static int gpio_extcon_probe(struct platform_device *pdev)\n>  {\n>  \tstruct gpio_extcon_data *data;\n>  \tstruct device *dev = &pdev->dev;\n> +\tunsigned long irq_flags;\n> +\tint irq;\n>  \tint ret;\n>  \n>  \tdata = devm_kzalloc(dev, sizeof(struct gpio_extcon_data), GFP_KERNEL);\n>  \tif (!data)\n>  \t\treturn -ENOMEM;\n>  \n> -\tif (!data->irq_flags || data->extcon_id > EXTCON_NONE)\n> +\tif (data->extcon_id > EXTCON_NONE)\n>  \t\treturn -EINVAL;\n>  \n>  \tdata->gpiod = devm_gpiod_get(dev, \"extcon\", GPIOD_IN);\n>  \tif (IS_ERR(data->gpiod))\n>  \t\treturn PTR_ERR(data->gpiod);\n> -\tdata->irq = gpiod_to_irq(data->gpiod);\n> -\tif (data->irq <= 0)\n> -\t\treturn data->irq;\n> +\tirq = gpiod_to_irq(data->gpiod);\n> +\tif (irq <= 0)\n> +\t\treturn irq;\n> +\n> +\t/*\n> +\t * It is unlikely that this is an acknowledged interrupt that goes\n> +\t * away after handling, what we are looking for are falling edges\n> +\t * if the signal is active low, and rising edges if the signal is\n> +\t * active high.\n> +\t */\n> +\tif (gpiod_is_active_low(data->gpiod))\n> +\t\tirq_flags = IRQF_TRIGGER_FALLING;\n> +\telse\n> +\t\tirq_flags = IRQF_TRIGGER_RISING;\n>  \n>  \t/* Allocate the memory of extcon devie and register extcon device */\n>  \tdata->edev = devm_extcon_dev_allocate(dev, &data->extcon_id);\n> @@ -110,8 +119,8 @@ static int gpio_extcon_probe(struct platform_device *pdev)\n>  \t * Request the interrupt of gpio to detect whether external connector\n>  \t * is attached or detached.\n>  \t */\n> -\tret = devm_request_any_context_irq(dev, data->irq,\n> -\t\t\t\t\tgpio_irq_handler, data->irq_flags,\n> +\tret = devm_request_any_context_irq(dev, irq,\n> +\t\t\t\t\tgpio_irq_handler, irq_flags,\n>  \t\t\t\t\tpdev->name, data);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>","headers":{"Return-Path":"<linux-gpio-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-gpio-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y1PmJ4Ny3z9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 12:19:44 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S934880AbdIZCTn (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 25 Sep 2017 22:19:43 -0400","from mailout1.samsung.com ([203.254.224.24]:31307 \"EHLO\n\tmailout1.samsung.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S934681AbdIZCTm (ORCPT\n\t<rfc822; linux-gpio@vger.kernel.org>); Mon, 25 Sep 2017 22:19:42 -0400","from epcas1p4.samsung.com (unknown [182.195.41.48])\n\tby mailout1.samsung.com (KnoxPortal) with ESMTP id\n\t20170926021940epoutp011254ecebf07d09b1de83092a02b459da~nx_N3EfCu0296302963epoutp01n;\n\tTue, 26 Sep 2017 02:19:40 +0000 (GMT)","from epsmges1p4.samsung.com (unknown [182.195.40.69]) by\n\tepcas1p1.samsung.com (KnoxPortal) with ESMTP id\n\t20170926021939epcas1p197f0b71b8ac39dbbaa5eb434d589bb01~nx_NkHtiL3125831258epcas1p12;\n\tTue, 26 Sep 2017 02:19:39 +0000 (GMT)","from epcas1p3.samsung.com ( [182.195.41.47]) by\n\tepsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id\n\tDD.49.04388.B39B9C95; Tue, 26 Sep 2017 11:19:39 +0900 (KST)","from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by\n\tepcas1p1.samsung.com (KnoxPortal) with ESMTP id\n\t20170926021939epcas1p12e593c580db6d38b1d672d5bd67ae59a~nx_NWmX9T3124431244epcas1p1y;\n\tTue, 26 Sep 2017 02:19:39 +0000 (GMT)","from epmmp1.local.host ( [203.254.227.16]) by\n\tepsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id\n\t4D.95.06995.B39B9C95; Tue, 26 Sep 2017 11:19:39 +0900 (KST)","from [10.113.62.212] by mmp1.samsung.com (Oracle Communications\n\tMessaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id\n\t<0OWV0042Z7SR12C0@mmp1.samsung.com>;\n\tTue, 26 Sep 2017 11:19:39 +0900 (KST)"],"X-AuditID":"b6c32a38-d89ff70000001124-ad-59c9b93bdd16","MIME-version":"1.0","Content-transfer-encoding":"8BIT","Content-type":"text/plain; charset=\"UTF-8\"","Message-id":"<59C9B93D.2080109@samsung.com>","Date":"Tue, 26 Sep 2017 11:19:41 +0900","From":"Chanwoo Choi <cw00.choi@samsung.com>","Organization":"Samsung Electronics","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101\n\tThunderbird/31.6.0","To":"Linus Walleij <linus.walleij@linaro.org>,\n\tMyungJoo Ham <myungjoo.ham@samsung.com>","Cc":"linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,\n\tJohn Stultz <john.stultz@linaro.org>, Guenter Roeck <linux@roeck-us.net>","Subject":"Re: [PATCH 5/8] extcon: gpio: Request reasonable interrupts","In-reply-to":"<20170924145622.4031-6-linus.walleij@linaro.org>","X-Brightmail-Tracker":["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rXNMzPk5ob8vqV5O7L8gp/1M3ZHJZbijERDLeai4kQAynvLyYIDAAA=","H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t9jAV3rnScjDXbOUrY481vXYsqf5UwW\n\tm+f/YbS4vGsOm8WThWeYLG43rmBzYPO4c20Pm8fO7w3sHn1bVjF6fN4kF8ASxWWTkpqTWZZa\n\tpG+XwJXxp+UIS8EM2YolqyYwNTB+FOti5OSQEDCReN6xhr2LkYtDSGAno8T2n7/YQBK8AoIS\n\tPybfY+li5OBgFpCXOHIpGyTMLKAuMWneImaI+geMEs/XfmWFqNeSeNL7gB3EZhFQlbj8+i0j\n\tiM0GFN//4gbYTH4BRYmrPx4zgswUFYiQ6D5RCRIWEQiXmL3gPTPE/A5GicmbNUFsYQEXiTez\n\tb7JC7DrMKPH353GwXZwCthKPvrUxTmAUmIXk1FkIp85CcuoCRuZVjJKpBcW56bnFRgWGeanl\n\tesWJucWleel6yfm5mxiBQb3tsFbfDsb7S+IPMQpwMCrx8DYwnYwUYk0sK67MPcQowcGsJMJ7\n\tfTtQiDclsbIqtSg/vqg0J7X4EKM0B4uSOO/tvGORQgLpiSWp2ampBalFMFkmDk6pBsblp853\n\tui1ZcqtAJ0P91P6ekjvCR56Gi/Bz7EoI7VxcluUlu6d247yXDUp/GRcvu+awq67vT2bdDUfX\n\tCt31hdNE0hVurHto+0NC1vj0t5QoRiXOVNamEzbcE1hWcniteN0WFMOQp1KUqZ603Sfm6vs/\n\tn+ef97use2O39Gv9d+azL1/4utzJIEyJpTgj0VCLuag4EQAssAG9ZgIAAA=="],"X-CMS-MailID":"20170926021939epcas1p12e593c580db6d38b1d672d5bd67ae59a","X-Msg-Generator":"CA","X-Sender-IP":"182.195.42.142","X-Local-Sender":"=?utf-8?b?7LWc7LCs7JqwG1RpemVuIFBsYXRmb3JtIExhYihTL1c=?=\n\t=?utf-8?b?7IS87YSwKRvsgrzshLHsoITsnpAbU2VuaW9yIEVuZ2luZWVy?=","X-Global-Sender":"=?utf-8?q?Chanwoo_Choi=1BTizen_Platform_Lab=2E=1BSamsung?=\n\t=?utf-8?q?_Electronics=1BSenior_Engineer?=","X-Sender-Code":"=?utf-8?q?C10=1BTELE=1BC10V8111?=","CMS-TYPE":"101P","DLP-Filter":"Pass","X-CFilter-Loop":"Reflected","X-CMS-RootMailID":"20170924150052epcas2p1d9069ef18771b6aceba7e1361d47a65e","X-RootMTR":"20170924150052epcas2p1d9069ef18771b6aceba7e1361d47a65e","References":"<20170924145622.4031-1-linus.walleij@linaro.org>\n\t<CGME20170924150052epcas2p1d9069ef18771b6aceba7e1361d47a65e@epcas2p1.samsung.com>\n\t<20170924145622.4031-6-linus.walleij@linaro.org>","Sender":"linux-gpio-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-gpio.vger.kernel.org>","X-Mailing-List":"linux-gpio@vger.kernel.org"}}]