From patchwork Wed Apr 14 18:14:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 92454 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3EIEsnx025209 for ; Wed, 14 Apr 2010 18:14:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756378Ab0DNSO2 (ORCPT ); Wed, 14 Apr 2010 14:14:28 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:56740 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756359Ab0DNSO1 (ORCPT ); Wed, 14 Apr 2010 14:14:27 -0400 Received: by wyb39 with SMTP id 39so49411wyb.19 for ; Wed, 14 Apr 2010 11:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=LpH6mbqD5c6biQn1MFqTtJUrVl6/O8cTguEZM0cJQ10=; b=nYeMOVArfRQjbNo3tIfMU//30KTGmnpKYUClXAwn++4s7GNAZnGe1dH1MAZl3F2YG0 wYn83aTeWwGCfCCb3PCddJhqiRoIGXLbkMx5kc7q/avLDd8bzS4n37DqAFd6XOow4RM3 n0IWsIiU9FT9PxJQ3mrgyF4CPOSOwoMfxZYTI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=DXjkSHNd0vNGRloAU8b1rOY6cCPnr58Hbd8asKgNswN8n/9tMwOMK6Am8XCS7RhcVv SyONLazV+iEsd8+zxe3o71SyDJ3oZwOYmoIDXx9BnwVHdf4uI6rPQpgDbiRFnIsEHKQr 5qoFfbrxRxGFxlmd/ApNZ+Hsc2dVLv9A3kDOY= Received: by 10.216.156.193 with SMTP id m43mr5343655wek.11.1271268865493; Wed, 14 Apr 2010 11:14:25 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-24-6-153-206.hsd1.ca.comcast.net [24.6.153.206]) by mx.google.com with ESMTPS id x1sm4450110wbx.13.2010.04.14.11.14.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 14 Apr 2010 11:14:23 -0700 (PDT) Date: Wed, 14 Apr 2010 11:14:18 -0700 From: Dmitry Torokhov To: Daniel Mack Cc: linux-input@vger.kernel.org Subject: Re: [PATCH] input: eeti_ts: cancel pending work when going to suspend Message-ID: <20100414181417.GA27661@core.coreip.homeip.net> References: <1271183505-28133-1-git-send-email-daniel@caiaq.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1271183505-28133-1-git-send-email-daniel@caiaq.de> User-Agent: Mutt/1.5.20 (2009-08-17) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 14 Apr 2010 18:14:54 +0000 (UTC) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 204b8a1..75f8b73 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -124,14 +124,25 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static int eeti_ts_open(struct input_dev *dev) +static void eeti_ts_start(struct eeti_ts_priv *priv) { - struct eeti_ts_priv *priv = input_get_drvdata(dev); - enable_irq(priv->irq); /* Read the events once to arm the IRQ */ eeti_ts_read(&priv->work); +} + +static void eeti_ts_stop(struct eeti_ts_priv *priv) +{ + disable_irq(priv->irq); + cancel_work_sync(&priv->work); +} + +static int eeti_ts_open(struct input_dev *dev) +{ + struct eeti_ts_priv *priv = input_get_drvdata(dev); + + eeti_ts_start(priv); return 0; } @@ -140,8 +151,7 @@ static void eeti_ts_close(struct input_dev *dev) { struct eeti_ts_priv *priv = input_get_drvdata(dev); - disable_irq(priv->irq); - cancel_work_sync(&priv->work); + eeti_ts_stop(priv); } static int __devinit eeti_ts_probe(struct i2c_client *client, @@ -153,10 +163,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, unsigned int irq_flags; int err = -ENOMEM; - /* In contrast to what's described in the datasheet, there seems + /* + * In contrast to what's described in the datasheet, there seems * to be no way of probing the presence of that device using I2C * commands. So we need to blindly believe it is there, and wait - * for interrupts to occur. */ + * for interrupts to occur. + */ priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) { @@ -212,9 +224,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, goto err2; } - /* Disable the irq for now. It will be enabled once the input device - * is opened. */ - disable_irq(priv->irq); + /* + * Disable the device for now. It will be enabled once the + * input device is opened. + */ + eeti_ts_stop(priv); device_init_wakeup(&client->dev, 0); return 0; @@ -235,6 +249,12 @@ static int __devexit eeti_ts_remove(struct i2c_client *client) struct eeti_ts_priv *priv = i2c_get_clientdata(client); free_irq(priv->irq, priv); + /* + * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it + * so that device still works if we reload the driver. + */ + enable_irq(priv->irq); + input_unregister_device(priv->input); i2c_set_clientdata(client, NULL); kfree(priv); @@ -246,6 +266,14 @@ static int __devexit eeti_ts_remove(struct i2c_client *client) static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) { struct eeti_ts_priv *priv = i2c_get_clientdata(client); + struct input_dev *input_dev = priv->input; + + mutex_lock(&input_dev->mutex); + + if (input_dev->users) + eeti_ts_stop(priv); + + mutex_unlock(&input_dev->mutex); if (device_may_wakeup(&client->dev)) enable_irq_wake(priv->irq); @@ -256,10 +284,18 @@ static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) static int eeti_ts_resume(struct i2c_client *client) { struct eeti_ts_priv *priv = i2c_get_clientdata(client); + struct input_dev *input_dev = priv->input; if (device_may_wakeup(&client->dev)) disable_irq_wake(priv->irq); + mutex_lock(&input_dev->mutex); + + if (input_dev->users) + eeti_ts_start(priv); + + mutex_unlock(&input_dev->mutex); + return 0; } #else