[{"id":1775090,"web_url":"http://patchwork.ozlabs.org/comment/1775090/","msgid":"<59C9B5C9.6060701@samsung.com>","list_archive_url":null,"date":"2017-09-26T02:04:57","subject":"Re: [PATCH 3/8] extcon: gpio: Move platform data into state\n\tcontainer","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> This moves the platform data settings from the platform data\n> struct and into the state container, saving some unnecessary\n> references and simplifying things a bit.\n> \n> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>\n> ---\n>  drivers/extcon/extcon-gpio.c | 56 ++++++++++++++++++++------------------------\n>  1 file changed, 26 insertions(+), 30 deletions(-)\n\nLooks good to me.\nAcked-by: Chanwoo Choi <cw00.choi@samsung.com>\n\n\n> \n> diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c\n> index 6abf5f70fdbf..9c4094edd123 100644\n> --- a/drivers/extcon/extcon-gpio.c\n> +++ b/drivers/extcon/extcon-gpio.c\n> @@ -29,7 +29,13 @@\n>  #include <linux/workqueue.h>\n>  \n>  /**\n> - * struct gpio_extcon_pdata - A simple GPIO-controlled extcon device.\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> + * @id_gpiod:\t\tGPIO descriptor for this external connector.\n>   * @extcon_id:\t\tThe unique id of specific external connector.\n>   * @gpio:\t\tCorresponding GPIO.\n>   * @gpio_active_low:\tBoolean describing whether gpio active state is 1 or 0\n> @@ -40,23 +46,18 @@\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_pdata {\n> -\tunsigned int extcon_id;\n> -\tunsigned gpio;\n> -\tbool gpio_active_low;\n> -\tunsigned long debounce;\n> -\tunsigned long irq_flags;\n> -\tbool check_on_resume;\n> -};\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> -\n>  \tstruct gpio_desc *id_gpiod;\n> -\tstruct gpio_extcon_pdata *pdata;\n> +\tunsigned int extcon_id;\n> +\tunsigned gpio;\n> +\tbool gpio_active_low;\n> +\tunsigned long debounce;\n> +\tunsigned long irq_flags;\n> +\tbool check_on_resume;\n>  };\n>  \n>  static void gpio_extcon_work(struct work_struct *work)\n> @@ -67,10 +68,10 @@ static void gpio_extcon_work(struct work_struct *work)\n>  \t\t\t     work);\n>  \n>  \tstate = gpiod_get_value_cansleep(data->id_gpiod);\n> -\tif (data->pdata->gpio_active_low)\n> +\tif (data->gpio_active_low)\n>  \t\tstate = !state;\n>  \n> -\textcon_set_state_sync(data->edev, data->pdata->extcon_id, state);\n> +\textcon_set_state_sync(data->edev, data->extcon_id, state);\n>  }\n>  \n>  static irqreturn_t gpio_irq_handler(int irq, void *dev_id)\n> @@ -84,24 +85,23 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)\n>  \n>  static int gpio_extcon_init(struct device *dev, struct gpio_extcon_data *data)\n>  {\n> -\tstruct gpio_extcon_pdata *pdata = data->pdata;\n>  \tint ret;\n>  \n> -\tret = devm_gpio_request_one(dev, pdata->gpio, GPIOF_DIR_IN,\n> +\tret = devm_gpio_request_one(dev, data->gpio, GPIOF_DIR_IN,\n>  \t\t\t\tdev_name(dev));\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> -\tdata->id_gpiod = gpio_to_desc(pdata->gpio);\n> +\tdata->id_gpiod = gpio_to_desc(data->gpio);\n>  \tif (!data->id_gpiod)\n>  \t\treturn -EINVAL;\n>  \n> -\tif (pdata->debounce) {\n> +\tif (data->debounce) {\n>  \t\tret = gpiod_set_debounce(data->id_gpiod,\n> -\t\t\t\t\tpdata->debounce * 1000);\n> +\t\t\t\t\t data->debounce * 1000);\n>  \t\tif (ret < 0)\n>  \t\t\tdata->debounce_jiffies =\n> -\t\t\t\tmsecs_to_jiffies(pdata->debounce);\n> +\t\t\t\tmsecs_to_jiffies(data->debounce);\n>  \t}\n>  \n>  \tdata->irq = gpiod_to_irq(data->id_gpiod);\n> @@ -113,20 +113,16 @@ static int gpio_extcon_init(struct device *dev, struct gpio_extcon_data *data)\n>  \n>  static int gpio_extcon_probe(struct platform_device *pdev)\n>  {\n> -\tstruct gpio_extcon_pdata *pdata = dev_get_platdata(&pdev->dev);\n>  \tstruct gpio_extcon_data *data;\n>  \tint ret;\n>  \n> -\tif (!pdata)\n> -\t\treturn -EBUSY;\n> -\tif (!pdata->irq_flags || pdata->extcon_id > EXTCON_NONE)\n> -\t\treturn -EINVAL;\n> -\n>  \tdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_extcon_data),\n>  \t\t\t\t   GFP_KERNEL);\n>  \tif (!data)\n>  \t\treturn -ENOMEM;\n> -\tdata->pdata = pdata;\n> +\n> +\tif (!data->irq_flags || data->extcon_id > EXTCON_NONE)\n> +\t\treturn -EINVAL;\n>  \n>  \t/* Initialize the gpio */\n>  \tret = gpio_extcon_init(&pdev->dev, data);\n> @@ -134,7 +130,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)\n>  \t\treturn ret;\n>  \n>  \t/* Allocate the memory of extcon devie and register extcon device */\n> -\tdata->edev = devm_extcon_dev_allocate(&pdev->dev, &pdata->extcon_id);\n> +\tdata->edev = devm_extcon_dev_allocate(&pdev->dev, &data->extcon_id);\n>  \tif (IS_ERR(data->edev)) {\n>  \t\tdev_err(&pdev->dev, \"failed to allocate extcon device\\n\");\n>  \t\treturn -ENOMEM;\n> @@ -151,7 +147,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)\n>  \t * is attached or detached.\n>  \t */\n>  \tret = devm_request_any_context_irq(&pdev->dev, data->irq,\n> -\t\t\t\t\tgpio_irq_handler, pdata->irq_flags,\n> +\t\t\t\t\tgpio_irq_handler, data->irq_flags,\n>  \t\t\t\t\tpdev->name, data);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n> @@ -178,7 +174,7 @@ static int gpio_extcon_resume(struct device *dev)\n>  \tstruct gpio_extcon_data *data;\n>  \n>  \tdata = dev_get_drvdata(dev);\n> -\tif (data->pdata->check_on_resume)\n> +\tif (data->check_on_resume)\n>  \t\tqueue_delayed_work(system_power_efficient_wq,\n>  \t\t\t&data->work, data->debounce_jiffies);\n>  \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 3y1PRY73CFz9t3F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 12:05:13 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S967157AbdIZCFB (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 25 Sep 2017 22:05:01 -0400","from mailout2.samsung.com ([203.254.224.25]:62671 \"EHLO\n\tmailout2.samsung.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S965981AbdIZCE6 (ORCPT\n\t<rfc822; linux-gpio@vger.kernel.org>); Mon, 25 Sep 2017 22:04:58 -0400","from epcas1p1.samsung.com (unknown [182.195.41.45])\n\tby mailout2.samsung.com (KnoxPortal) with ESMTP id\n\t20170926020456epoutp021d08c148bf9867fd84a2bc5a42e0544e~nxxWuQ7RQ0228502285epoutp02I;\n\tTue, 26 Sep 2017 02:04:56 +0000 (GMT)","from epsmges1p1.samsung.com (unknown [182.195.40.69]) by\n\tepcas1p1.samsung.com (KnoxPortal) with ESMTP id\n\t20170926020455epcas1p1d2764654c61590294d2349b807c76b9f~nxxWZLXHg2333623336epcas1p1F;\n\tTue, 26 Sep 2017 02:04:55 +0000 (GMT)","from epcas1p4.samsung.com ( [182.195.41.48]) by\n\tepsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id\n\tCA.EE.04439.7C5B9C95; Tue, 26 Sep 2017 11:04:55 +0900 (KST)","from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by\n\tepcas1p1.samsung.com (KnoxPortal) with ESMTP id\n\t20170926020455epcas1p18146a661a66b3c06dc6b80f412124dde~nxxWJVCgV2108321083epcas1p17;\n\tTue, 26 Sep 2017 02:04:55 +0000 (GMT)","from epmmp1.local.host ( [203.254.227.16]) by\n\tepsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id\n\t88.B4.06995.7C5B9C95; Tue, 26 Sep 2017 11:04:55 +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<0OWV006CS747EW70@mmp1.samsung.com>;\n\tTue, 26 Sep 2017 11:04:55 +0900 (KST)"],"X-AuditID":"b6c32a35-8adff70000001157-23-59c9b5c7db95","MIME-version":"1.0","Content-transfer-encoding":"8BIT","Content-type":"text/plain; charset=\"UTF-8\"","Message-id":"<59C9B5C9.6060701@samsung.com>","Date":"Tue, 26 Sep 2017 11:04:57 +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 3/8] extcon: gpio: Move platform data into state\n\tcontainer","In-reply-to":"<20170924145622.4031-4-linus.walleij@linaro.org>","X-Brightmail-Tracker":["H4sIAAAAAAAAA+NgFvrIKsWRmVeSWpSXmKPExsWy7bCmge7xrScjDd69tLA481vXYsqf5UwW\n\tm+f/YbS4vGsOm8WThWeYLG43rmBzYPO4c20Pm8fO7w3sHn1bVjF6fN4kF8ASlWqTkZqYklqk\n\tkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ibaqvk4hOg65aZA7RbSaEsMacUKBSQWFys\n\tpG9nU5RfWpKqkJFfXGKrFG1oaKRnaGCuZ2RkpGdiHGtlZApUkpCasez7XcaCi9oVz16uYWlg\n\tfK7UxcjJISFgInHl7Se2LkYuDiGBHYwSB4/sYIZwvjNKzL3ymAmm6tG9s1BVuxklfm3/xA6S\n\t4BUQlPgx+R5LFyMHB7OAvMSRS9kgYWYBTYmtu9ezQ9TfY5To27qMDaJeS+L1vO/sIPUsAqoS\n\tPW2VIGE2oPD+FzfASvgFFCWu/njMCGKLCkRI7Jz/DWyViEC4xL5jB8COYxboYJR4swMiISwQ\n\tILH25ntmEJtTwFbi4f8JYIdKCOxhk9g7eQkrxAcuEv/OTGeGsIUlXh3fAnaEhIC0xKWjthD1\n\t7YwSm+eAPAPiAG24v7IRqtlY4lRXIxPEa3wS7772sEI080p0tAlBlHhIzFuyE6rcUeJe/2kW\n\tiO8PM0pMnjSZfQKj3CykAJuFCLBZSAG2gJF5FaNYakFxbnpqsWGBoV5xYm5xaV66XnJ+7iZG\n\tcHLTMt3BOOWczyFGAQ5GJR7eBqaTkUKsiWXFlbmHGCU4mJVEeOU3A4V4UxIrq1KL8uOLSnNS\n\tiw8xmgLDeyKzlGhyPjDx5pXEG5pYGpiYGQHTl6WhoZI4r+j6axFCAumJJanZqakFqUUwf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124dde","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":"20170924145924epcas5p40b56107b697683bef6e1b8099301f2cc","X-RootMTR":"20170924145924epcas5p40b56107b697683bef6e1b8099301f2cc","References":"<20170924145622.4031-1-linus.walleij@linaro.org>\n\t<CGME20170924145924epcas5p40b56107b697683bef6e1b8099301f2cc@epcas5p4.samsung.com>\n\t<20170924145622.4031-4-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"}}]