From patchwork Fri Feb 14 07:57:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 3651171 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6B0329F501 for ; Fri, 14 Feb 2014 08:26:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AA3E20212 for ; Fri, 14 Feb 2014 08:26:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 47C0A2020E for ; Fri, 14 Feb 2014 08:26:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751643AbaBNI0I (ORCPT ); Fri, 14 Feb 2014 03:26:08 -0500 Received: from mail-pd0-f170.google.com ([209.85.192.170]:58383 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751956AbaBNIZu (ORCPT ); Fri, 14 Feb 2014 03:25:50 -0500 Received: by mail-pd0-f170.google.com with SMTP id p10so11675242pdj.15 for ; Fri, 14 Feb 2014 00:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=NoknKCSrD6r60ZWf6P4QrDNGLKScvfeTiNkmxsz11uE=; b=JucOc3XKUc6h0BWLnc7ZgTU0r3ccM9pjn5Ba9wfVFux7u6TA85o1QHZIU2aqxVC9Z9 F9sXwt368BIsD11Ir1kj3ctm4QCviPoOJlJQ6CH3EBbTS3qUEII9BQH7m9HHh/MQWMJ/ 7LDECu8pA5rmaY8Zhov1sazO5eaBfiSAzqyZS6+rD+39gHuZlHk/fExsmG0hXorUl8Iq AjhE4AW5q+cI9wl6RxivSlX8s7pnnIkUhPedi82WbtPZJmpoEEf2q3Q74o1wRuPduxCS IiUYtUt8ZqbIQnSsWYZDukQT67qYg8N1nJN9KxhxcHCvn+fF790RBp5DT0URGS3Hllqr c7pQ== X-Received: by 10.66.233.71 with SMTP id tu7mr7592639pac.22.1392366349885; Fri, 14 Feb 2014 00:25:49 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-67-188-112-76.hsd1.ca.comcast.net. [67.188.112.76]) by mx.google.com with ESMTPSA id cz3sm14557375pbc.9.2014.02.14.00.25.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 14 Feb 2014 00:25:49 -0800 (PST) Date: Thu, 13 Feb 2014 23:57:17 -0800 From: Dmitry Torokhov To: Barry Song <21cnbao@gmail.com> Cc: linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, workgroup.linux@csr.com, Xianglong Du , Rongjun Ying , Barry Song Subject: Re: [PATCH v3] input: sirfsoc-onkey - report onkey untouch event by detecting pin status Message-ID: <20140214075717.GA14682@core.coreip.homeip.net> References: <1392348001-4950-1-git-send-email-21cnbao@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1392348001-4950-1-git-send-email-21cnbao@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Barry, On Fri, Feb 14, 2014 at 11:20:01AM +0800, Barry Song wrote: > From: Xianglong Du > > this patch adds a delayed_work to detect the untouch of onkey since HW will > not generate interrupt for it. > > at the same time, we move the KEY event to POWER instead of SUSPEND, which > will be suitable for both Android and Linux. Userspace PowerManager Daemon > will decide to suspend or shutdown based on how long we have touched onkey > > Signed-off-by: Xianglong Du > Signed-off-by: Rongjun Ying > Signed-off-by: Barry Song > --- > -v3: move to use custom devres action Thank you for making the changes, however it seems that we can control whether the device generates interrupts or not and so we can implement open and close methods. If patch below works then your cancel_delayed_work() call should go into sirfosc_pwrc_close() and we do not need to use devm_free_irq() not custom action. Thanks. Tested-by: Xianglong Du Tested-by: Xianglong Du diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c index e8897c3..dc7db65 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c @@ -49,6 +49,35 @@ static irqreturn_t sirfsoc_pwrc_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static void sirfsoc_pwrc_toggle_interrupts(struct sirfsoc_pwrc_drvdata *pwrcdrv, + bool enable) +{ + u32 int_mask; + + int_mask = sirfsoc_rtc_iobrg_readl(pwrcdrv->pwrc_base + PWRC_INT_MASK); + if (enable) + int_mask |= PWRC_ON_KEY_BIT; + else + int_mask &= ~PWRC_ON_KEY_BIT; + sirfsoc_rtc_iobrg_writel(int_mask, pwrcdrv->pwrc_base + PWRC_INT_MASK); +} + +static int sirfsoc_pwrc_open(struct input_dev *input) +{ + struct sirfsoc_pwrc_drvdata *pwrcdrv = input_get_drvdata(input); + + sirfsoc_pwrc_toggle_interrupts(pwrcdrv, true); + + return 0; +} + +static void sirfsoc_pwrc_close(struct input_dev *input) +{ + struct sirfsoc_pwrc_drvdata *pwrcdrv = input_get_drvdata(input); + + sirfsoc_pwrc_toggle_interrupts(pwrcdrv, false); +} + static const struct of_device_id sirfsoc_pwrc_of_match[] = { { .compatible = "sirf,prima2-pwrc" }, {}, @@ -70,7 +99,7 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) } /* - * we can't use of_iomap because pwrc is not mapped in memory, + * We can't use of_iomap because pwrc is not mapped in memory, * the so-called base address is only offset in rtciobrg */ error = of_property_read_u32(np, "reg", &pwrcdrv->pwrc_base); @@ -88,6 +117,11 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) pwrcdrv->input->phys = "pwrc/input0"; pwrcdrv->input->evbit[0] = BIT_MASK(EV_PWR); + pwrcdrv->input->open = sirfsoc_pwrc_open; + pwrcdrv->input->close = sirfsoc_pwrc_close; + + input_set_drvdata(pwrcdrv->input, pwrcdrv); + irq = platform_get_irq(pdev, 0); error = devm_request_irq(&pdev->dev, irq, sirfsoc_pwrc_isr, IRQF_SHARED, @@ -98,11 +132,6 @@ static int sirfsoc_pwrc_probe(struct platform_device *pdev) return error; } - sirfsoc_rtc_iobrg_writel( - sirfsoc_rtc_iobrg_readl(pwrcdrv->pwrc_base + PWRC_INT_MASK) | - PWRC_ON_KEY_BIT, - pwrcdrv->pwrc_base + PWRC_INT_MASK); - error = input_register_device(pwrcdrv->input); if (error) { dev_err(&pdev->dev, @@ -129,15 +158,16 @@ static int pwrc_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct sirfsoc_pwrc_drvdata *pwrcdrv = platform_get_drvdata(pdev); + struct input_dev *input = pwrcdrv->input; /* * Do not mask pwrc interrupt as we want pwrc work as a wakeup source * if users touch X_ONKEY_B, see arch/arm/mach-prima2/pm.c */ - sirfsoc_rtc_iobrg_writel( - sirfsoc_rtc_iobrg_readl( - pwrcdrv->pwrc_base + PWRC_INT_MASK) | PWRC_ON_KEY_BIT, - pwrcdrv->pwrc_base + PWRC_INT_MASK); + mutex_lock(&input->mutex); + if (input->users) + sirfsoc_pwrc_toggle_interrupts(pwrcdrv, true); + mutex_unlock(&input->mutex); return 0; }