Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754107AbcCHPAj (ORCPT ); Tue, 8 Mar 2016 10:00:39 -0500 Received: from forward.webhostbox.net ([204.11.59.73]:36667 "EHLO forward.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbcCHPAd (ORCPT ); Tue, 8 Mar 2016 10:00:33 -0500 X-Greylist: delayed 547 seconds by postgrey-1.27 at vger.kernel.org; Tue, 08 Mar 2016 10:00:33 EST Date: Tue, 8 Mar 2016 06:51:21 -0800 From: Guenter Roeck To: Venkat Reddy Talla Cc: MyungJoo Ham , Chanwoo Choi , linux-kernel@vger.kernel.org, Laxman Dewangan Subject: Re: [PATCH 1/1] extcon: gpio: queue work only if debounce is NZ Message-ID: <20160308145121.GA13839@roeck-us.net> References: <1457437553-566-1-git-send-email-vreddytalla@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1457437553-566-1-git-send-email-vreddytalla@nvidia.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=MpLykzue c=1 sm=1 tr=0 a=9TTQYYGGY7a1eFc7Vblcuw==:117 a=2cfIYNtKkjgZNaOwnGXpGw==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=7OsogOcEt9IA:10 a=ToySZFBKVOLnIvIwD-sA:9 a=CjuIK1q_8ugA:10 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1297 Lines: 41 On Tue, Mar 08, 2016 at 05:15:53PM +0530, Venkat Reddy Talla wrote: > Use queue_delayed_work only when debounce time is > required to read gpio state properly, read the gpio > state and set the extcon cable state in IRQ handler > context if gpio settling time is not needed. > > Signed-off-by: Venkat Reddy Talla > --- > drivers/extcon/extcon-gpio.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c > index 279ff8f..1beb086 100644 > --- a/drivers/extcon/extcon-gpio.c > +++ b/drivers/extcon/extcon-gpio.c > @@ -56,8 +56,12 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id) > { > struct gpio_extcon_data *data = dev_id; > > - queue_delayed_work(system_power_efficient_wq, &data->work, > + if (data->debounce_jiffies) > + queue_delayed_work(system_power_efficient_wq, &data->work, > data->debounce_jiffies); > + else > + gpio_extcon_work(&data->work.work); > + The interrupt is requested with devm_request_any_context_irq(), meaning the handler may run in hard interrupt context. gpio_extcon_work() calls gpiod_get_value_cansleep(), which may not be a good idea in hard interrupt context. Guenter > return IRQ_HANDLED; > } > > -- > 2.1.4 > >