From patchwork Mon Dec 16 08:57:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 3352271 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 F021F9F314 for ; Mon, 16 Dec 2013 08:57:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C3372034B for ; Mon, 16 Dec 2013 08:57:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55B7B20158 for ; Mon, 16 Dec 2013 08:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751706Ab3LPI5a (ORCPT ); Mon, 16 Dec 2013 03:57:30 -0500 Received: from smtp205.alice.it ([82.57.200.101]:3694 "EHLO smtp205.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810Ab3LPI53 (ORCPT ); Mon, 16 Dec 2013 03:57:29 -0500 Received: from jcn (82.61.79.211) by smtp205.alice.it (8.6.060.28) id 529A593103E575AE; Mon, 16 Dec 2013 09:57:28 +0100 Received: from ao2 by jcn with local (Exim 4.82) (envelope-from ) id 1VsTzT-0005GC-AI; Mon, 16 Dec 2013 09:57:27 +0100 From: Antonio Ospite To: linux-input@vger.kernel.org Cc: Antonio Ospite , Dmitry Torokhov Subject: [PATCH 2/2] Input: joystick - use sizeof(VARIABLE) in documentation Date: Mon, 16 Dec 2013 09:57:15 +0100 Message-Id: <1387184235-20169-3-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1387184235-20169-1-git-send-email-ospite@studenti.unina.it> References: <1387184235-20169-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE 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, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Use the preferred style sizeof(VARIABLE) instead of sizeof(TYPE) in the joystick API documentation, Documentation/CodingStyle states that this is the preferred style for allocations but using it elsewhere is good too. Also fix some errors like "sizeof(struct mybuffer)" which didn't mean anything. Signed-off-by: Antonio Ospite --- Documentation/input/joystick-api.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/input/joystick-api.txt b/Documentation/input/joystick-api.txt index f95f648..47e60a5 100644 --- a/Documentation/input/joystick-api.txt +++ b/Documentation/input/joystick-api.txt @@ -23,7 +23,7 @@ By default, the device is opened in blocking mode. ~~~~~~~~~~~~~~~~ struct js_event e; - read (fd, &e, sizeof(struct js_event)); + read (fd, &e, sizeof(e)); where js_event is defined as @@ -34,8 +34,8 @@ where js_event is defined as __u8 number; /* axis/button number */ }; -If the read is successful, it will return sizeof(struct js_event), unless -you wanted to read more than one event per read as described in section 3.1. +If the read is successful, it will return sizeof(e), unless you wanted to read +more than one event per read as described in section 3.1. 2.1 js_event.type @@ -144,7 +144,7 @@ all events on the queue (that is, until you get a -1). For example, while (1) { - while (read (fd, &e, sizeof(struct js_event)) > 0) { + while (read (fd, &e, sizeof(e)) > 0) { process_event (e); } /* EAGAIN is returned when the queue is empty */ @@ -181,7 +181,7 @@ at a time using the typical read(2) functionality. For that, you would replace the read above with something like struct js_event mybuffer[0xff]; - int i = read (fd, mybuffer, sizeof(struct mybuffer)); + int i = read (fd, mybuffer, ARRAY_SIZE(mybuffer)); In this case, read would return -1 if the queue was empty, or some other value in which the number of events read would be i /