From patchwork Tue Feb 1 09:21:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 522261 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p119MQXx031600 for ; Tue, 1 Feb 2011 09:22:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756527Ab1BAJVg (ORCPT ); Tue, 1 Feb 2011 04:21:36 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:52406 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753670Ab1BAJVe (ORCPT ); Tue, 1 Feb 2011 04:21:34 -0500 Received: by iwn9 with SMTP id 9so6283778iwn.19 for ; Tue, 01 Feb 2011 01:21:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=hKfRXK7YqL9k/SR1jSXKlwGGBiM/0+0tHlPm/uNcXog=; b=aO059Ghi6RtYB1aD9RxFdWLHHnPAZHE0lQjbjG6T8MBJARgiTMWPTBxxEhCmqi3tPj IL20f9o9yhnwtaP8ztCDiiWVubPElt1sSfW088XXxzweHDZEFT6c8h9tltdZgtOp0QiX 9I4MIjd9yWvK+oUzS/AIHu8JgGIwD066QeBiw= 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:content-transfer-encoding :in-reply-to:user-agent; b=RugQRNDiclCNZZTXonYnVFo7T/n01jW123DBA2u8lTyMMyqNvenjQW4HRZlvxz19sq JID8tXOol8SSZUtTM4C7gMmX8fFCbtLkKGaPbaRq710/EE//Q1CYmrfYG69d/8DHOtmW 0ChWdNbHntYp/nFlpMWebYCs4Kp+j+uSXCUpk= Received: by 10.42.164.198 with SMTP id h6mr545791icy.494.1296552093461; Tue, 01 Feb 2011 01:21:33 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-98-234-113-65.hsd1.ca.comcast.net [98.234.113.65]) by mx.google.com with ESMTPS id u5sm16848528ics.18.2011.02.01.01.21.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 01 Feb 2011 01:21:30 -0800 (PST) Date: Tue, 1 Feb 2011 01:21:26 -0800 From: Dmitry Torokhov To: Duncan Laurie Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Input: serio - clear serio event queue after sysfs driver rebind Message-ID: <20110201092126.GC17706@core.coreip.homeip.net> References: <1290467390-25302-1-git-send-email-dlaurie@chromium.org> <20101127084153.GC28745@core.coreip.homeip.net> <20101208051211.GB4140@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101208051211.GB4140@core.coreip.homeip.net> 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-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 01 Feb 2011 09:22:27 +0000 (UTC) diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index db5b0bc..7c38d1f 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -188,7 +188,8 @@ static void serio_free_event(struct serio_event *event) kfree(event); } -static void serio_remove_duplicate_events(struct serio_event *event) +static void serio_remove_duplicate_events(void *object, + enum serio_event_type type) { struct serio_event *e, *next; unsigned long flags; @@ -196,13 +197,13 @@ static void serio_remove_duplicate_events(struct serio_event *event) spin_lock_irqsave(&serio_event_lock, flags); list_for_each_entry_safe(e, next, &serio_event_list, node) { - if (event->object == e->object) { + if (object == e->object) { /* * If this event is of different type we should not * look further - we only suppress duplicate events * that were sent back-to-back. */ - if (event->type != e->type) + if (type != e->type) break; list_del_init(&e->node); @@ -245,7 +246,7 @@ static void serio_handle_event(struct work_struct *work) break; } - serio_remove_duplicate_events(event); + serio_remove_duplicate_events(event->object, event->type); serio_free_event(event); } @@ -436,10 +437,12 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute * } else if (!strncmp(buf, "rescan", count)) { serio_disconnect_port(serio); serio_find_driver(serio); + serio_remove_duplicate_events(serio, SERIO_RESCAN_PORT); } else if ((drv = driver_find(buf, &serio_bus)) != NULL) { serio_disconnect_port(serio); error = serio_bind_driver(serio, to_serio_driver(drv)); put_driver(drv); + serio_remove_duplicate_events(serio, SERIO_RESCAN_PORT); } else { error = -EINVAL; }