From patchwork Tue Jul 29 15:14:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 4640791 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 39BC1C0338 for ; Tue, 29 Jul 2014 15:15:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E21720149 for ; Tue, 29 Jul 2014 15:15:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5282B20142 for ; Tue, 29 Jul 2014 15:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753982AbaG2POy (ORCPT ); Tue, 29 Jul 2014 11:14:54 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:32993 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752764AbaG2POy (ORCPT ); Tue, 29 Jul 2014 11:14:54 -0400 Received: by mail-we0-f169.google.com with SMTP id u56so9236716wes.28 for ; Tue, 29 Jul 2014 08:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xzf6Py///PBn/rtOAvBom6dcdCEzhzy15d9Vo2G4UwI=; b=v/cBegTf53cba89lYC5O4hoMv352wXU52HhuVEctj/loTBZDk4pMylNHtfsINp+Ihd lqG3fHqqAcjRUdzPiHaMjo7VyqL3C8sx1PWtn7VFmT4RZH7gVZXnqOpo8qLYSG3IEfnj 0NZZIGw7L+NOAwg/GIYhtbIUZplROTMZd9+jqfwkQQjTQc/+UU7uJypbhzYvcp0KbJwK YJC5F8Kd7TBU4Bg3XYTbZLNPl20kJpq5qQY5hEFb2eFY0su8JDkHqObDU6IZF8BnBMse pVilYkktgubp11F/KScjOq5HTYkgh9igKmtaLxmCssc083DyU8ijZlyKJx+ToLqE7aDn IuYA== X-Received: by 10.180.39.172 with SMTP id q12mr6987043wik.55.1406646893215; Tue, 29 Jul 2014 08:14:53 -0700 (PDT) Received: from david-tp.localdomain (stgt-4d0247ad.pool.mediaWays.net. [77.2.71.173]) by mx.google.com with ESMTPSA id fs3sm44361822wic.20.2014.07.29.08.14.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Jul 2014 08:14:52 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , David Herrmann Subject: [PATCH 05/12] HID: uhid: turn report_id into u32 Date: Tue, 29 Jul 2014 17:14:19 +0200 Message-Id: <1406646866-999-6-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.0.3 In-Reply-To: <1406646866-999-1-git-send-email-dh.herrmann@gmail.com> References: <1406646866-999-1-git-send-email-dh.herrmann@gmail.com> 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.5 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 All accesses to @report_id are protected by @qlock. No need to use an atomic. Signed-off-by: David Herrmann --- drivers/hid/uhid.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 5dee8bd..db4e119 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c @@ -44,10 +44,11 @@ struct uhid_device { __u8 tail; struct uhid_event *outq[UHID_BUFSIZE]; + /* blocking GET_REPORT support; state changes protected by qlock */ struct mutex report_lock; wait_queue_head_t report_wait; atomic_t report_done; - atomic_t report_id; + u32 report_id; struct uhid_event report_buf; }; @@ -163,7 +164,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum, spin_lock_irqsave(&uhid->qlock, flags); ev->type = UHID_FEATURE; - ev->u.feature.id = atomic_inc_return(&uhid->report_id); + ev->u.feature.id = ++uhid->report_id; ev->u.feature.rnum = rnum; ev->u.feature.rtype = report_type; @@ -497,7 +498,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid, spin_lock_irqsave(&uhid->qlock, flags); /* id for old report; drop it silently */ - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id) + if (uhid->report_id != ev->u.feature_answer.id) goto unlock; if (atomic_read(&uhid->report_done)) goto unlock;