From patchwork Mon Nov 23 11:21:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: samu.p.onkalo@nokia.com X-Patchwork-Id: 62141 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nANBME1f009472 for ; Mon, 23 Nov 2009 11:22:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753791AbZKWLWH (ORCPT ); Mon, 23 Nov 2009 06:22:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755586AbZKWLWH (ORCPT ); Mon, 23 Nov 2009 06:22:07 -0500 Received: from smtp.nokia.com ([192.100.122.233]:51947 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753791AbZKWLWG (ORCPT ); Mon, 23 Nov 2009 06:22:06 -0500 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nANBLrMP020988; Mon, 23 Nov 2009 13:22:08 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 23 Nov 2009 13:21:53 +0200 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 23 Nov 2009 13:21:48 +0200 Received: from localhost.localdomain (4fid08082.ntc.nokia.com [172.22.144.188]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nANBLjAN023342; Mon, 23 Nov 2009 13:21:45 +0200 From: Samu Onkalo To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, Samu Onkalo Subject: [PATCH] input-polldev: Poll interval setting can cause polling with zero interval Date: Mon, 23 Nov 2009 13:21:44 +0200 Message-Id: <1258975304-4751-1-git-send-email-samu.p.onkalo@nokia.com> X-Mailer: git-send-email 1.6.0.4 X-OriginalArrivalTime: 23 Nov 2009 11:21:48.0723 (UTC) FILETIME=[25D18030:01CA6C2F] X-Nokia-AV: Clean Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c index 3187427..2d2c626 100644 --- a/drivers/input/input-polldev.c +++ b/drivers/input/input-polldev.c @@ -59,12 +59,13 @@ static void input_polldev_stop_workqueue(void) static void input_polldev_queue_work(struct input_polled_dev *dev) { unsigned long delay; + if (dev->poll_interval > 0) { + delay = msecs_to_jiffies(dev->poll_interval); + if (delay >= HZ) + delay = round_jiffies_relative(delay); - delay = msecs_to_jiffies(dev->poll_interval); - if (delay >= HZ) - delay = round_jiffies_relative(delay); - - queue_delayed_work(polldev_wq, &dev->work, delay); + queue_delayed_work(polldev_wq, &dev->work, delay); + } } static void input_polled_device_work(struct work_struct *work) @@ -88,8 +89,7 @@ static int input_open_polled_device(struct input_dev *input) if (dev->open) dev->open(dev); - queue_delayed_work(polldev_wq, &dev->work, - msecs_to_jiffies(dev->poll_interval)); + input_polldev_queue_work(dev); return 0; } @@ -138,8 +138,7 @@ static ssize_t input_polldev_set_poll(struct device *dev, if (input->users) { cancel_delayed_work_sync(&polldev->work); - if (polldev->poll_interval > 0) - input_polldev_queue_work(polldev); + input_polldev_queue_work(polldev); } mutex_unlock(&input->mutex);