From patchwork Sun Sep 24 14:56:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114128 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1642813qgf; Sun, 24 Sep 2017 07:59:26 -0700 (PDT) X-Received: by 10.159.249.69 with SMTP id h5mr4949380pls.208.1506265166549; Sun, 24 Sep 2017 07:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265166; cv=none; d=google.com; s=arc-20160816; b=RiKzXpZHikHdVbS8V/yFq0aDXzZ/I81ayz6eIxZaA69MreBsZRExTCqPQSuoVOPCz2 u0AgLTj3P5gQNl58gUrM81VS1AVFFRJTPjrUmPsi21/Jpy3BDEaBdNKrSJHCAsZCRUI4 WY0jST3h2/QBtlgibJ782fp5mzBb64EGSMmN+b9B8WQVBG0OHCJ85uqeP4yDYRQTiUSL /V4ozDMM8geMj5z0kI9vAnr5f8asJJC3ehkFILYe4NlKt6OGgHSHTpnJDZ7KBFygDdZ9 rmpV+TNQ3AiDxS+cS497CR+eGfpCxReeIp891nPXNOUISFbNfgMUYMxjVT5GT+P7AQhO blyQ== 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=M9XDYYz0gZs1pQCax0DPKAB1f/KOsg+vKI8BIsSW1d0=; b=ZR3STNEF9ofCdmEKcEqkIb4Ct/aRmcljFNJgcTSTs8i+bM1Anp4USbK1NzLFdK++Ec qfskl1WqCV5ezSwio9VsbXcMJRuh7OnUnTIFoPjtOYDh9k43iKQQrW7PdAMZdssKT+HZ lIZbbPi5dAb+KEKjYuSGY6DfSWl3lwH536f2TOPoS0/1W1npGQAzm0CGbLimFsKCpcjF fIaH7mGO78s+kvyZyyzCqF41GjIT4hXSHfzHoEJKtkycOVeE6eGW6pHhkwf1WMp424vH CoMoSoLmIlptr88uFhqtv14+SzcPWa1RbQsJ0d7boqZ/BI832QJihR9qp/6l4VZL0wyv JqyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=irUfUJ2M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 z2si2728151pgo.334.2017.09.24.07.59.26; Sun, 24 Sep 2017 07:59:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=irUfUJ2M; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752639AbdIXO7Y (ORCPT + 26 others); Sun, 24 Sep 2017 10:59:24 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:55571 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbdIXO7W (ORCPT ); Sun, 24 Sep 2017 10:59:22 -0400 Received: by mail-pg0-f42.google.com with SMTP id b11so2721490pgn.12 for ; Sun, 24 Sep 2017 07:59:22 -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=M9XDYYz0gZs1pQCax0DPKAB1f/KOsg+vKI8BIsSW1d0=; b=irUfUJ2MH2rJmZTNqx6+vL2SbpYjKjMLRMUmuMohRvJsS7NBU67KggDbzLFZVgz2AD vaFuaUxroMlE+yEjRHQpGDWdtgxwqJnJcsrIbIbQABEFbyg7DisyY98hc63AJbBrpHqE tvJds2cKRivU6z0q7TSQU9vjXuRz2mjHgqU40= 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=M9XDYYz0gZs1pQCax0DPKAB1f/KOsg+vKI8BIsSW1d0=; b=IqPBZp6U0r1gXj/oowBkrWqyd9/4/bbZr/7P3VcUh/HRzyZZZl/iiYWstQeGQHZ5B5 EqDDpyboLEd4PxRz2R2G/EiMvRe54SHKwvsLOg6ND151UaBZUSSKnzMR6yGgrXvZk/S/ YQmZDYCwQqcEjxO7oBYlNOquChaLNBIgKOHozgg4mZTcN6kvZhBQEzPQNj/BUYLJssWk 1Iv3aDk9msNSaTyEgYydagsqcUMz542xtMg9GHNmlDvKWzHuVcH2CGjWljiG5r0/CH+m MNbNpjUB1M4RJmHNK3kzw56RurMeheXOdsnQ4+bZCVDW1RCup3Gnzs0bSNSakflS47jE tgVA== X-Gm-Message-State: AHPjjUhU7MG0ncfZnBX35EIMm8nbxW2e0Lylb4b1FNJWvF+2FFlVJdZP 39boPGiJLZfNqwZKPJQDDfqubg== X-Google-Smtp-Source: AOwi7QDiw4q5JwFL9AxHZKPO/60rcqAYZn7JXQHbvhyY1Vo+rfyp8zRK9kPGuzt6AzX7iGdKkQj2zQ== X-Received: by 10.84.171.193 with SMTP id l59mr4792507plb.133.1506265161898; Sun, 24 Sep 2017 07:59:21 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.07.58.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 07:59:21 -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 3/8] extcon: gpio: Move platform data into state container Date: Sun, 24 Sep 2017 16:56:17 +0200 Message-Id: <20170924145622.4031-4-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This moves the platform data settings from the platform data struct and into the state container, saving some unnecessary references and simplifying things a bit. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 56 ++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 30 deletions(-) -- 2.13.5 Acked-by: Chanwoo Choi diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 6abf5f70fdbf..9c4094edd123 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -29,7 +29,13 @@ #include /** - * struct gpio_extcon_pdata - A simple GPIO-controlled extcon device. + * struct gpio_extcon_data - A simple GPIO-controlled extcon device state container. + * @edev: Extcon device. + * @irq: Interrupt line for the external connector. + * @work: Work fired by the interrupt. + * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce + * value. + * @id_gpiod: GPIO descriptor for this external connector. * @extcon_id: The unique id of specific external connector. * @gpio: Corresponding GPIO. * @gpio_active_low: Boolean describing whether gpio active state is 1 or 0 @@ -40,23 +46,18 @@ * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ -struct gpio_extcon_pdata { - unsigned int extcon_id; - unsigned gpio; - bool gpio_active_low; - unsigned long debounce; - unsigned long irq_flags; - bool check_on_resume; -}; - struct gpio_extcon_data { struct extcon_dev *edev; int irq; struct delayed_work work; unsigned long debounce_jiffies; - struct gpio_desc *id_gpiod; - struct gpio_extcon_pdata *pdata; + unsigned int extcon_id; + unsigned gpio; + bool gpio_active_low; + unsigned long debounce; + unsigned long irq_flags; + bool check_on_resume; }; static void gpio_extcon_work(struct work_struct *work) @@ -67,10 +68,10 @@ static void gpio_extcon_work(struct work_struct *work) work); state = gpiod_get_value_cansleep(data->id_gpiod); - if (data->pdata->gpio_active_low) + if (data->gpio_active_low) state = !state; - extcon_set_state_sync(data->edev, data->pdata->extcon_id, state); + extcon_set_state_sync(data->edev, data->extcon_id, state); } static irqreturn_t gpio_irq_handler(int irq, void *dev_id) @@ -84,24 +85,23 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id) static int gpio_extcon_init(struct device *dev, struct gpio_extcon_data *data) { - struct gpio_extcon_pdata *pdata = data->pdata; int ret; - ret = devm_gpio_request_one(dev, pdata->gpio, GPIOF_DIR_IN, + ret = devm_gpio_request_one(dev, data->gpio, GPIOF_DIR_IN, dev_name(dev)); if (ret < 0) return ret; - data->id_gpiod = gpio_to_desc(pdata->gpio); + data->id_gpiod = gpio_to_desc(data->gpio); if (!data->id_gpiod) return -EINVAL; - if (pdata->debounce) { + if (data->debounce) { ret = gpiod_set_debounce(data->id_gpiod, - pdata->debounce * 1000); + data->debounce * 1000); if (ret < 0) data->debounce_jiffies = - msecs_to_jiffies(pdata->debounce); + msecs_to_jiffies(data->debounce); } data->irq = gpiod_to_irq(data->id_gpiod); @@ -113,20 +113,16 @@ static int gpio_extcon_init(struct device *dev, struct gpio_extcon_data *data) static int gpio_extcon_probe(struct platform_device *pdev) { - struct gpio_extcon_pdata *pdata = dev_get_platdata(&pdev->dev); struct gpio_extcon_data *data; int ret; - if (!pdata) - return -EBUSY; - if (!pdata->irq_flags || pdata->extcon_id > EXTCON_NONE) - return -EINVAL; - data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_extcon_data), GFP_KERNEL); if (!data) return -ENOMEM; - data->pdata = pdata; + + if (!data->irq_flags || data->extcon_id > EXTCON_NONE) + return -EINVAL; /* Initialize the gpio */ ret = gpio_extcon_init(&pdev->dev, data); @@ -134,7 +130,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) return ret; /* Allocate the memory of extcon devie and register extcon device */ - data->edev = devm_extcon_dev_allocate(&pdev->dev, &pdata->extcon_id); + data->edev = devm_extcon_dev_allocate(&pdev->dev, &data->extcon_id); if (IS_ERR(data->edev)) { dev_err(&pdev->dev, "failed to allocate extcon device\n"); return -ENOMEM; @@ -151,7 +147,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) * is attached or detached. */ ret = devm_request_any_context_irq(&pdev->dev, data->irq, - gpio_irq_handler, pdata->irq_flags, + gpio_irq_handler, data->irq_flags, pdev->name, data); if (ret < 0) return ret; @@ -178,7 +174,7 @@ static int gpio_extcon_resume(struct device *dev) struct gpio_extcon_data *data; data = dev_get_drvdata(dev); - if (data->pdata->check_on_resume) + if (data->check_on_resume) queue_delayed_work(system_power_efficient_wq, &data->work, data->debounce_jiffies); From patchwork Sun Sep 24 14:56:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114129 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1643313qgf; Sun, 24 Sep 2017 08:00:06 -0700 (PDT) X-Received: by 10.98.129.6 with SMTP id t6mr4822700pfd.225.1506265206551; Sun, 24 Sep 2017 08:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265206; cv=none; d=google.com; s=arc-20160816; b=Qv0A418q1yESDAshpxukOvsef3y/khsRFh6v1LQkx4bF1p+GK87oBFCRWQUFIfVUWB fb3ITsRK5NMY9A9fs6jz5a2l2eV5ktLpv10O1n8sHuoZogVeCQKNx/l0jFanR42si4ML MknigTx2coMMM5DnBwufVDc7CUzAOBfJNyFDR7k0ca+yHF8Ni1Mthur6+J65zVZFcLmk z4ITsfNNqzeXT1XcCs9ITiyYbuPrDeS1ltz78iAeWLE403p6kFpeGa7+HwkMkwJrfFMr Vakxr/fAcTQwI4brMIhB64X2XS9IzxaPcKvb6Oo5U1d2u1t4oLyeGL9K0CZceSNIWYiG 4foA== 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=9EoT4D03TXTHT89pkomvmDIwfs/ypqXeVk5hZO8RL1E=; b=CCIyxwVJ19tpENkMMzwN4BzCycu9d1yFjU3YbTQ4LU0XbNrEhlYhtiMhMqa4Lzvr6f skvPx9u+6E59nFAg+//uokO+ACCIzSDIgTuXYI2L+OCByrsV6dsdn9gY2MXcEFauDTyG Ddja3DIxO9tQJiPXEMbAVXpRZpRqTvzTQu/sh//LVpnoiFXXvFKIdaRtvWaciIEOb2IQ YZcJRb74P0h1WiEDa47XyvzXO7KFmQLam5D4bt2yhFZkfBBXhTq8DSElgljSmlqkC1uQ 4YjqW4n/5fFQrwPzlZzN+56bmgXAh3PfsT++3fZ7OYkytwKciulWsN0Py9yG/32O51zh QGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h6CObgrT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 f18si2725636pgn.355.2017.09.24.08.00.06; Sun, 24 Sep 2017 08:00:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h6CObgrT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752649AbdIXPAE (ORCPT + 26 others); Sun, 24 Sep 2017 11:00:04 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:52166 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752461AbdIXPAC (ORCPT ); Sun, 24 Sep 2017 11:00:02 -0400 Received: by mail-pf0-f169.google.com with SMTP id b70so2605498pfl.8 for ; Sun, 24 Sep 2017 08:00:02 -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=9EoT4D03TXTHT89pkomvmDIwfs/ypqXeVk5hZO8RL1E=; b=h6CObgrTcPZkdCAZ/ct51BJ9g/Sc+SyyI8QsgYXVjwweu63cKkYzoFIiCwZatHg/w/ x/1PrysEf5xwZ/wmfqjFGMgWXDEJsCr71VsL/xzA+to2DX7HG+ekmaWEOzXIoxTPVdTy HOV8l0jbFIDCGrwZBT6WazKpQTGFafpQPS1gc= 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=9EoT4D03TXTHT89pkomvmDIwfs/ypqXeVk5hZO8RL1E=; b=RsUHP0+zIqDGvNsLPMyGi3bk4Buh7xQR8ki8SvCltRl1jOhCDOCIm6Ejk5fjBO0NUx OC46zBr8hi/5uVP4kOj+fSYC7BQ278C078uIQO27F86dX5JUZUqLe0AVIJZeyJ2J9W3u 3sHfxc6xuN3i70XHaeadxSRzDVeSk/PVkCZa2WisSzh9rmht4y5Rb8cElMuFzg+21ZAs CFKe3XMEHqRO294V7nIFT1cVSFQHxpbdX0NDN8Bkmyz2p7X27v8CB2UL++LOzkKriLpT xvmzcQkxEoKde24cf2+MJNd3XYEUVR60QUrXkngIEtTfTC0TGP3R7zCkNiFiZu6z8P/X psvA== X-Gm-Message-State: AHPjjUgxDIxdWge/wjq1LOXiVx8UyqF9DfAJ2gd1z8hZ0gQuy9XwhAnK rJfmY1NzUs3LZdE2FSkbmEnwTQ== X-Google-Smtp-Source: AOwi7QDThN7DPSh4jq4dQGnzZXDT+pqUvSJe3tfRlstyuqnHgE+2JRdLz+w3VG71kPXvU+jlLuiBcQ== X-Received: by 10.84.212.2 with SMTP id d2mr4876051pli.412.1506265201913; Sun, 24 Sep 2017 08:00:01 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.07.59.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:00:01 -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 4/8] extcon: gpio: Convert to fully use GPIO descriptor Date: Sun, 24 Sep 2017 16:56:18 +0200 Message-Id: <20170924145622.4031-5-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we are not getting the GPIO from any platform data and global GPIO numberspace, we simply get the named "extcon" GPIO directly from the device. Cut away "active low" since GPIO descriptors already know if the line is active high or low. Simplify a bit with a struct device *dev helper variable in probe() and cut the complex init() function. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 66 ++++++++++---------------------------------- 1 file changed, 15 insertions(+), 51 deletions(-) -- 2.13.5 diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 9c4094edd123..86f3ec6d6014 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -35,12 +34,8 @@ * @work: Work fired by the interrupt. * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce * value. - * @id_gpiod: GPIO descriptor for this external connector. + * @gpiod: GPIO descriptor for this external connector. * @extcon_id: The unique id of specific external connector. - * @gpio: Corresponding GPIO. - * @gpio_active_low: Boolean describing whether gpio active state is 1 or 0 - * If true, low state of gpio means active. - * If false, high state of gpio means active. * @debounce: Debounce time for GPIO IRQ in ms. * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW). * @check_on_resume: Boolean describing whether to check the state of gpio @@ -51,10 +46,8 @@ struct gpio_extcon_data { int irq; struct delayed_work work; unsigned long debounce_jiffies; - struct gpio_desc *id_gpiod; + struct gpio_desc *gpiod; unsigned int extcon_id; - unsigned gpio; - bool gpio_active_low; unsigned long debounce; unsigned long irq_flags; bool check_on_resume; @@ -67,10 +60,7 @@ static void gpio_extcon_work(struct work_struct *work) container_of(to_delayed_work(work), struct gpio_extcon_data, work); - state = gpiod_get_value_cansleep(data->id_gpiod); - if (data->gpio_active_low) - state = !state; - + state = gpiod_get_value_cansleep(data->gpiod); extcon_set_state_sync(data->edev, data->extcon_id, state); } @@ -83,60 +73,34 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static int gpio_extcon_init(struct device *dev, struct gpio_extcon_data *data) -{ - int ret; - - ret = devm_gpio_request_one(dev, data->gpio, GPIOF_DIR_IN, - dev_name(dev)); - if (ret < 0) - return ret; - - data->id_gpiod = gpio_to_desc(data->gpio); - if (!data->id_gpiod) - return -EINVAL; - - if (data->debounce) { - ret = gpiod_set_debounce(data->id_gpiod, - data->debounce * 1000); - if (ret < 0) - data->debounce_jiffies = - msecs_to_jiffies(data->debounce); - } - - data->irq = gpiod_to_irq(data->id_gpiod); - if (data->irq < 0) - return data->irq; - - return 0; -} - static int gpio_extcon_probe(struct platform_device *pdev) { struct gpio_extcon_data *data; + struct device *dev = &pdev->dev; int ret; - data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_extcon_data), - GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(struct gpio_extcon_data), GFP_KERNEL); if (!data) return -ENOMEM; if (!data->irq_flags || data->extcon_id > EXTCON_NONE) return -EINVAL; - /* Initialize the gpio */ - ret = gpio_extcon_init(&pdev->dev, data); - if (ret < 0) - return ret; + data->gpiod = devm_gpiod_get(dev, "extcon", GPIOD_IN); + if (IS_ERR(data->gpiod)) + return PTR_ERR(data->gpiod); + data->irq = gpiod_to_irq(data->gpiod); + if (data->irq <= 0) + return data->irq; /* Allocate the memory of extcon devie and register extcon device */ - data->edev = devm_extcon_dev_allocate(&pdev->dev, &data->extcon_id); + data->edev = devm_extcon_dev_allocate(dev, &data->extcon_id); if (IS_ERR(data->edev)) { - dev_err(&pdev->dev, "failed to allocate extcon device\n"); + dev_err(dev, "failed to allocate extcon device\n"); return -ENOMEM; } - ret = devm_extcon_dev_register(&pdev->dev, data->edev); + ret = devm_extcon_dev_register(dev, data->edev); if (ret < 0) return ret; @@ -146,7 +110,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) * Request the interrupt of gpio to detect whether external connector * is attached or detached. */ - ret = devm_request_any_context_irq(&pdev->dev, data->irq, + ret = devm_request_any_context_irq(dev, data->irq, gpio_irq_handler, data->irq_flags, pdev->name, data); if (ret < 0) From patchwork Sun Sep 24 14:56:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114130 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1644178qgf; Sun, 24 Sep 2017 08:00:54 -0700 (PDT) X-Received: by 10.98.26.201 with SMTP id a192mr4754257pfa.311.1506265254862; Sun, 24 Sep 2017 08:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265254; cv=none; d=google.com; s=arc-20160816; b=D+pk6G4AH7DAePiyt09A/ma3+nM2oWx8reVHsf+VntoJrUy6/uEVTgCQGDolmh4Pq9 YPKqV1wv7S5rbaaeW8OznmpdD2vGgnWJydGVWbjR1W1GiDqgX08c1MQ9V3kFmpScFZ0P OLH1JxfxXrBA+ZXWYyRH00jZxmFNN39/OOWTl1aYYL5Y8Iao473OJ9bs3OKBA1tpGzBc ZljU0KZccFiD0S4ngbuTqABaPHk0ZsC/W0at9xwHCnFuyZQPLT4ipiSG+LwGgseWGbGY oH1ZCeL5/B/o3EhyEmn6z6IkDeQ26B0A+HDctwI8heS7XQ29f9bIAz1tLTr6WTMrmZdg wQbQ== 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=kGwfhHNs16L499QCaDMtlsmYNdt4BX9na+tY/K9pl9U=; b=HBF4RASlGchpf3SNluEEdQMtPKISsRTe6NK182oUiDVJqjpS0WtmTjV1R2dt536x8o SjFxM8UYJhe+ard+lgmwppC4T/wfQOqV8mP/h0R+2J37+5UhEYmLfV0MrHA9jFY7jl/M S/HjgZ4K0hwZD11WPj+RFfmGhm+V6sriR5ZB2xHwPUK2hRKIP6+pnntYnng4qXow6N5Q pzHG3vgUQbvt2sxkXmaouwOg3DnxP7slGjvH2DlNlEKePvsDIxz2nlOe/Hel9klkR2yV G6FJA0RYtn2elzJmreuBgkVzq5Jh8fTo3lyW/G/BtTSEw/YLTchoiOoYQkNomejr3xoM NRug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VOgpi8gK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 s78si2644786pfa.117.2017.09.24.08.00.53; Sun, 24 Sep 2017 08:00:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VOgpi8gK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbdIXPAw (ORCPT + 26 others); Sun, 24 Sep 2017 11:00:52 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:45314 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752607AbdIXPAu (ORCPT ); Sun, 24 Sep 2017 11:00:50 -0400 Received: by mail-pg0-f51.google.com with SMTP id 188so2733256pgb.2 for ; Sun, 24 Sep 2017 08:00:50 -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=kGwfhHNs16L499QCaDMtlsmYNdt4BX9na+tY/K9pl9U=; b=VOgpi8gKmWrVBniz7fZ/OqH0SLtA7j8h5SeF241I5yAg6ntB6oVk7nD/fQxdc5uSUs +JJ9rfdgQoc/z45y/sGGNni9CYc848acAjwVwr8zTm/yzVpQh7edu24VDbOfWK5H3gmo IfVdPu114ABfhCivvSYylK+2RrGrznXZ8LhIY= 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=kGwfhHNs16L499QCaDMtlsmYNdt4BX9na+tY/K9pl9U=; b=mTiFtBFlQ9o+l+HwWepj0rxUzqHW1dN7lnDw4+dHlWw85Ax3Wu/Goqns8EmnIUAorJ Yn5FDyaJwKbjnhE1I5MWL+8jmBYpzjLBInTIEaR0LDqRs2xb+FW7+WxCbNGgclsp7aS+ Kogk537qrCK17kq4/Ph2oDaciwTkFSZwCoxK+brQ7JmYcR3gccnFjjtYthU8WbHyAIkE lgJQA6Kglx4u3KpPE70ZlwGmGmBlDqtz6ChrkcKCEU8NUA+hWfyYIB5wB5sNMmdKTFUA 73BOvABtXTsYbHeesGGrQWokdqkpag7KvXPCbszkwpaVnQUkg/QZDaZ33Y9CICkh8s5U EB8Q== X-Gm-Message-State: AHPjjUhLx1nVrBS2Yi22bPgmTUcCZ6Tohieg6325basVxBR/nuqMiUlV xGpi0Np/PEkr/iJYXMui4KW55g== X-Google-Smtp-Source: AOwi7QAVJ4Th5OmZKuZAIAv7AYKoX/klo4w45fn08GZqa4xKL/r984+6CI9qrLeTfjfayRwrf4SquA== X-Received: by 10.99.51.15 with SMTP id z15mr4837618pgz.287.1506265249948; Sun, 24 Sep 2017 08:00:49 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:00:49 -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 5/8] extcon: gpio: Request reasonable interrupts Date: Sun, 24 Sep 2017 16:56:19 +0200 Message-Id: <20170924145622.4031-6-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only thing that makes sense is to request a falling edge interrupt if the line is active low and a rising edge interrupt if the line is active high, so just do that and get rid of the assignment from platform data. The GPIO descriptor knows if the line is active high or low. Also make irq a local variable in probe(), it's not used anywhere else. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) -- 2.13.5 diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 86f3ec6d6014..6d9cb4ed11c2 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -30,26 +30,22 @@ /** * struct gpio_extcon_data - A simple GPIO-controlled extcon device state container. * @edev: Extcon device. - * @irq: Interrupt line for the external connector. * @work: Work fired by the interrupt. * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce * 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. - * @irq_flags: IRQ Flags (e.g., IRQF_TRIGGER_LOW). * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ struct gpio_extcon_data { struct extcon_dev *edev; - int irq; struct delayed_work work; unsigned long debounce_jiffies; struct gpio_desc *gpiod; unsigned int extcon_id; unsigned long debounce; - unsigned long irq_flags; bool check_on_resume; }; @@ -77,21 +73,34 @@ static int gpio_extcon_probe(struct platform_device *pdev) { struct gpio_extcon_data *data; struct device *dev = &pdev->dev; + unsigned long irq_flags; + int irq; int ret; data = devm_kzalloc(dev, sizeof(struct gpio_extcon_data), GFP_KERNEL); if (!data) return -ENOMEM; - if (!data->irq_flags || data->extcon_id > EXTCON_NONE) + if (data->extcon_id > EXTCON_NONE) return -EINVAL; data->gpiod = devm_gpiod_get(dev, "extcon", GPIOD_IN); if (IS_ERR(data->gpiod)) return PTR_ERR(data->gpiod); - data->irq = gpiod_to_irq(data->gpiod); - if (data->irq <= 0) - return data->irq; + irq = gpiod_to_irq(data->gpiod); + if (irq <= 0) + return irq; + + /* + * It is unlikely that this is an acknowledged interrupt that goes + * away after handling, what we are looking for are falling edges + * if the signal is active low, and rising edges if the signal is + * active high. + */ + if (gpiod_is_active_low(data->gpiod)) + irq_flags = IRQF_TRIGGER_FALLING; + else + irq_flags = IRQF_TRIGGER_RISING; /* Allocate the memory of extcon devie and register extcon device */ data->edev = devm_extcon_dev_allocate(dev, &data->extcon_id); @@ -110,8 +119,8 @@ static int gpio_extcon_probe(struct platform_device *pdev) * Request the interrupt of gpio to detect whether external connector * is attached or detached. */ - ret = devm_request_any_context_irq(dev, data->irq, - gpio_irq_handler, data->irq_flags, + ret = devm_request_any_context_irq(dev, irq, + gpio_irq_handler, irq_flags, pdev->name, data); if (ret < 0) return ret; From patchwork Sun Sep 24 14:56:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114132 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1645641qgf; Sun, 24 Sep 2017 08:02:11 -0700 (PDT) X-Received: by 10.84.232.199 with SMTP id x7mr4966887plm.191.1506265331836; Sun, 24 Sep 2017 08:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265331; cv=none; d=google.com; s=arc-20160816; b=TG2B14CHAi2qkbRBH9rSi3GKjgIs+zbl3pyxE9+Kex6gIGPIoVhFaN9ui5W6tO9GkB QxUuO0WZu15k2PjMD16wPj7cXd3d98e25I7IJEXyVza1bhX9FTZBrwArizSuwqlxd4jB /h8Emie/QyBFtK8Bya6C/jzUwmzP+PHYCgboKTuQVBrKXotPVTKmoQpym/w47ZULqe6o Gcuj1J1iYNFaLGFBbA0a0e/iHNzs4TCcSoMs1556L8s0W9yXTKjsTo0jltfSjbJCqa4R 0a9A1tUq4RMIvQ2F4x2MWGnEtU8i5GJb9/bywu0/vc0tRlV6na3pG/PgwQ7wAVrKl7O6 2Ykw== 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=I0NEvmbxcWXA5okiDqqtuj9tm8T9ilhu7ty7iDdGUhA=; b=NKLOiMXlHjAB4iooTQ8YdRzMCHxpVZVsRsWTDE8svCzIn+oiJhbz94ItVxFia/azM5 em3fCx/UGc/g8vEItLGJ293NZzKQnvHLysYBL32SssfaRJVUOM1nBmnKhTd2kRmr6ziD jv9RmhjDj/UNlKBPJS2T1OcWTwk7pGqe/dffET9uOloFBFptzp8C6sAiSGC/265Cl5el TncyAlULVn0YpTGa8Rm/mBE+YOGNxAMcvJkSQEBe4F+9QE6AbG/SMuvim0D77N8G8GDN C3X49fdZkyh/xmIqTWvgYPfn1AOrCsvgnEm06+JD2WMDj8ybm3CK80fRINh6JFNBiHlj LGbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOS6kKNZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 y7si2751784pgr.195.2017.09.24.08.02.11; Sun, 24 Sep 2017 08:02:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOS6kKNZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdIXPCJ (ORCPT + 26 others); Sun, 24 Sep 2017 11:02:09 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:53341 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752591AbdIXPCI (ORCPT ); Sun, 24 Sep 2017 11:02:08 -0400 Received: by mail-pg0-f45.google.com with SMTP id j70so2723265pgc.10 for ; Sun, 24 Sep 2017 08:02:08 -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=I0NEvmbxcWXA5okiDqqtuj9tm8T9ilhu7ty7iDdGUhA=; b=LOS6kKNZLmmkya90eLpPL0wKT4r+X25Enx6ArhrlRdlnny7hVaUSSZLvGgpOLC+9bC icr4i2DBTUD+I+Bo8aY1CkWNL+cBdocbaWDNtEEQIviE/pPUnHqLp8GSYO6hXza2K+/R PJeN6XOnWoJkxWNc9QYPrQcLkbZOXEL89aH/E= 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=I0NEvmbxcWXA5okiDqqtuj9tm8T9ilhu7ty7iDdGUhA=; b=IORvTsgZ/Q6kh5IrnUtIuAgP8YXNgpgVfdJyXwlB7ZGy+pD1+e4Jmfz6E5omIRwRa/ /R7NNhGuwPqERNGqK0buJC6dxIDs7cls6HLQX5UEQLuet4d814diEIhXDCfDC1aaiBDV xBPl3c2Nkg3PO3tFsTVRy5086LcbfNFaRut3WvNzN73OfpHs8GYdhi3YYYz4pLiaOOWB oie8OqBMTGgBq13BrJqcw7HPTU5PChZU1IfOvv7GwNs8QaGSEvr703SyDz5HB8eDbktf 5z/kN3MsA/huV5uGZ9K+btbmlAuvA4znoFx3nv6MAdkQqH8zAsHdpojxKQ8A9+c8OIpa 5Dpg== X-Gm-Message-State: AHPjjUg9MgPDrMGIjFu+ysaRtW3c8YSyjogC9HhBDx2Ejj9IfVjBwU3u HAvbFHn3Jv48SGTqNMP9/vXiIQ== X-Google-Smtp-Source: AOwi7QBfiQx2z6+FjfQwqplh8ONEfdKGTjVz8zBFf45I4Fw7WvZBmoUk2MMWsQbRe9yGLlLQoIQCDQ== X-Received: by 10.84.131.74 with SMTP id 68mr4968870pld.227.1506265327650; Sun, 24 Sep 2017 08:02:07 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.08.01.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:02:07 -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 7/8] extcon: gpio: Get connector type from device property Date: Sun, 24 Sep 2017 16:56:21 +0200 Message-Id: <20170924145622.4031-8-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We do not use the "EXTCON_NONE" type to report this as before, use the connector type defined in the device property, from device tree or ACPI DSDT. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- 2.13.5 diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index 8fc52631c8a2..b7353f5018b5 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -35,7 +35,8 @@ * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce * value. * @gpiod: GPIO descriptor for this external connector. - * @extcon_id: The unique id of specific external connector. + * @connector_type: The connector type we're detecting on this extcon, terminated with EXTCON_NONE + * One GPIO is one cable, so one type only. * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ @@ -44,7 +45,7 @@ struct gpio_extcon_data { struct delayed_work work; unsigned long debounce_jiffies; struct gpio_desc *gpiod; - unsigned int extcon_id; + unsigned int connector_type[2]; bool check_on_resume; }; @@ -56,7 +57,7 @@ static void gpio_extcon_work(struct work_struct *work) work); state = gpiod_get_value_cansleep(data->gpiod); - extcon_set_state_sync(data->edev, data->extcon_id, state); + extcon_set_state_sync(data->edev, data->connector_type[0], state); } static irqreturn_t gpio_irq_handler(int irq, void *dev_id) @@ -74,6 +75,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; unsigned long irq_flags; u32 debounce_usecs; + u32 connector_type; int irq; int ret; @@ -81,9 +83,6 @@ static int gpio_extcon_probe(struct platform_device *pdev) if (!data) return -ENOMEM; - if (data->extcon_id > EXTCON_NONE) - return -EINVAL; - data->gpiod = devm_gpiod_get(dev, "extcon", GPIOD_IN); if (IS_ERR(data->gpiod)) return PTR_ERR(data->gpiod); @@ -102,8 +101,16 @@ static int gpio_extcon_probe(struct platform_device *pdev) else irq_flags = IRQF_TRIGGER_RISING; + ret = device_property_read_u32(dev, "extcon-connector-types", &connector_type); + if (ret || !connector_type) { + dev_err(dev, "illegal cable type or undefined cable type\n"); + return -EINVAL; + } + data->connector_type[0] = connector_type; + data->connector_type[1] = EXTCON_NONE; + /* Allocate the memory of extcon devie and register extcon device */ - data->edev = devm_extcon_dev_allocate(dev, &data->extcon_id); + data->edev = devm_extcon_dev_allocate(dev, data->connector_type); if (IS_ERR(data->edev)) { dev_err(dev, "failed to allocate extcon device\n"); return -ENOMEM; From patchwork Sun Sep 24 14:56:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 114133 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1646389qgf; Sun, 24 Sep 2017 08:02:51 -0700 (PDT) X-Received: by 10.84.240.4 with SMTP id y4mr4895697plk.22.1506265371709; Sun, 24 Sep 2017 08:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506265371; cv=none; d=google.com; s=arc-20160816; b=aM05sU5+ZA60Hm6oy7qa1VyuneJQxRc4YOctB+/BFihFai5g3h6FUzJmd9gh3Zm7BK IPoBcQSoxkw5B0BLsLCjLQghiYwIPaP+8xI9q1cJG5uhseAVN7TPEkMYXMUL2y/2BeAU m1JC3+OCvq+LndBbyXBbA0s53seeldKdwzUUnJtcda5jE617eyOrodE9SUMemEM2Y47Q Rr1qaoXwPiSeYdVx+c6xzzrrFbhG8DdDzj6FOtTn66FSGqYmjph5DC50vjZhhRRatasj vMP7V8R1dCv9IxLxcDZuOB7Cz0MgO0I+cX0PEijU+hgJ5fbaGxOKF6SfSPK25Ef8qrsS BXsg== 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=PHU9GwQikBxttSN6CQscSmCAlSIe7qNrQaoy+I4aNN4=; b=lUvxyOXvyq5rS8dWMFHAjrhhVNqChMA2R56+MpjeWToTXQADlyJ3Y0LRvhC7sLUVVO pgfsMiOmKSNuv/YbBMWxWDq6d9t31jBi5SsnQaIniSeGMiNP2Q7TfRpB4EnQ7IMEmbAh iv/oRzjCDs0/fZh4gdjGZMkkQxHQT0MsadxIA2HtXA6+QkNYvGs1HV5aBJYlLyp/HAWQ lN8E3PFz1U8ugccMCv04V6mROV5kqlZbsm0Jp3ucFbR9Lb4WOvxfPrbLtp+Ycp95hvw5 dnUWUm5J/kk0EgJkWs60QiLoITLt0dyBrCNJgpMnBRzGu0xPYipOifGDXttMuoICulzZ +NKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B/YBjcar; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 p14si2753146pli.693.2017.09.24.08.02.51; Sun, 24 Sep 2017 08:02:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B/YBjcar; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbdIXPCs (ORCPT + 26 others); Sun, 24 Sep 2017 11:02:48 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:50797 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752461AbdIXPCq (ORCPT ); Sun, 24 Sep 2017 11:02:46 -0400 Received: by mail-pg0-f54.google.com with SMTP id p5so2730598pgn.7 for ; Sun, 24 Sep 2017 08:02:46 -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=PHU9GwQikBxttSN6CQscSmCAlSIe7qNrQaoy+I4aNN4=; b=B/YBjcarg4evTS4hONzQQav1IN0BRtTfnxijA8IWZMH3F4P53q8a4taiN7iGLMOw9j ol6UYmrzGXp7JdQB8LjWgNHH2rCu5to25GSE98/4EFRdkMAp1zpgd12UIM0rj1To1e7M WAn2wYWDy7l38Lb9+kydseVxsYkR2h9az218U= 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=PHU9GwQikBxttSN6CQscSmCAlSIe7qNrQaoy+I4aNN4=; b=KfXLiBX9cVnziQg9lk+aaO7kg3eGyeQ2q90RdH9m7Gtt+oEjFS7fniWJvyhhmHxo/p E5i0w8RnOX6D6vpXbTltEjsQ16TAjvR1x6JjV4qdFIWUp1pGvgMR6+VISxKkCcD/Qeoq F7eElvMkkSUcFylkHQ437lT6uSvsHG/vA0PbKJBsW76RcSosltf68Ot/nowF2mvCVEmZ xHTDDJO4OMaBnN/PLcDz/VvzmetfpK99cRSzb2H6e3iHM2U9t/eZTU1YMkOYCYZ6hT81 c23c3p9OwQ4eYMST8ZzWrRnO7LmEYR45L0SoGyEiZ8IlzbH6Qp2V+fROOiM+u2MzIORt divA== X-Gm-Message-State: AHPjjUjdP0bE2Gcy/N+kyBEGYqfGlu+taVagaGpSVj3UfYhpxH+woX0V scOHUlo5QUluG8BKNfM8Ce0FLmI9Q5Q= X-Google-Smtp-Source: AOwi7QBzN5AkklkkcDT97zcjcrWrF9Gjl24mR+QM3FZhreTMLwk/INeidPkdEjjfnXu3qUQSUGOdmw== X-Received: by 10.98.71.153 with SMTP id p25mr4846219pfi.84.1506265366320; Sun, 24 Sep 2017 08:02:46 -0700 (PDT) Received: from genomnajs.saswifi.com ([104.153.224.168]) by smtp.gmail.com with ESMTPSA id n83sm7386805pfi.163.2017.09.24.08.02.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 08:02:45 -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 8/8] extcon: gpio: Always check state on resume Date: Sun, 24 Sep 2017 16:56:22 +0200 Message-Id: <20170924145622.4031-9-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It makes most sense to always check the state of the GPIO external connector at system resume so just do this by default. Add a TODO if people turn out to desire to parameterize this. Signed-off-by: Linus Walleij --- drivers/extcon/extcon-gpio.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.13.5 diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index b7353f5018b5..4f0ad5ad2722 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c @@ -83,6 +83,15 @@ static int gpio_extcon_probe(struct platform_device *pdev) if (!data) return -ENOMEM; + /* + * Always checking connector state on resume makes most sense so do this + * by default. + * + * TODO: if parameterization is needed, augment this to use proper device + * properties or set it up from PM core. + */ + data->check_on_resume = true; + data->gpiod = devm_gpiod_get(dev, "extcon", GPIOD_IN); if (IS_ERR(data->gpiod)) return PTR_ERR(data->gpiod);