From patchwork Tue Sep 21 16:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12508335 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 908D6C433F5 for ; Tue, 21 Sep 2021 16:33:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77BFE60F6D for ; Tue, 21 Sep 2021 16:33:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbhIUQfW (ORCPT ); Tue, 21 Sep 2021 12:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbhIUQfV (ORCPT ); Tue, 21 Sep 2021 12:35:21 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6C31C061574; Tue, 21 Sep 2021 09:33:52 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id w29so41031255wra.8; Tue, 21 Sep 2021 09:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xkOYayTUXE8FXeS0HkJiFMUyE0P/EeUIyIfzXkEamSg=; b=VBv1HkuHcAC9P2f/9nJZjPtjDkdMEwkBk6HnEWcVg1/yiw3aJBmcNocLOQWdCMLwBq 1MwJeIP9ypPSNJulleViPP7YC8lX/QrYJsJTpwK2QWX5aHbi4+FMQgeEX1SEe5nffxdp 2I7gWRhSE2xUWx0rTiWBY7yaK3+fqEulWbWlUkPBOrGP8g6Ig/Em5lamKXO/j6RXJd2t hzB/UoNSi/vVwlKHaI+KE++QAYNy2emIrgRGAWHONf1exnM1xD+NLzpBaq53x+goq7UQ HGcy2AwQFrhYzdKcnvTtFkZ3IXds9ofOK43ZcVysrOx4231+unFKs/cnMm43MGHhUBdL PIfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xkOYayTUXE8FXeS0HkJiFMUyE0P/EeUIyIfzXkEamSg=; b=BjxVpXxV9ZKwKPfA5a35irXsH2Pm4D0waZcxTZ+4VLkuBb08peqQkf7ppUi0gHdLTM ZR5utntkfkY+C+KlfqM16/9WzKcxmKwgmcq8ByJ19E+nb0yFQtG0xE7XJe1jWdACXUsp ckDW44UfrNjvaDLTyKBtLDyuml2qD01pFWQfWvqM1jmnQtWJVaMmebjYbP4UUrh/qOGC vNICpnt106yNtSI5PcTE9lA6+uReP7qCteKb3WSJlwVhTew+Vf5H0TZ/u1APyxTmRsgf 3bukcIPrJbbjOXth3ruL6drZw/uUQCoAd2l+ybyWnN/fQG7R35Mf12T6AgC9p8ozq3aQ WuuQ== X-Gm-Message-State: AOAM531yV3s36UrvWGHtMFpZKA8kHz1OT9Cdivi7QeKUCdYPTgAbQqhJ HD2kwxG9pZ479V28M5HfSzE= X-Google-Smtp-Source: ABdhPJx92e3qspCxJd9hONE3SKczQd2201vObImah7VYbroWfik9nyGPOFzJg32TgXFbMJ3ZJV8UhQ== X-Received: by 2002:a05:600c:2d45:: with SMTP id a5mr5631207wmg.39.1632242031439; Tue, 21 Sep 2021 09:33:51 -0700 (PDT) Received: from localhost.localdomain ([94.73.35.139]) by smtp.gmail.com with ESMTPSA id z13sm23149308wrs.90.2021.09.21.09.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 09:33:51 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, rydberg@bitmath.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH RESEND 1/2] HID: magicmouse: fix checkpatch errors Date: Tue, 21 Sep 2021 18:33:46 +0200 Message-Id: <20210921163347.7317-1-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Fix errors reported by checkpatch in hid-magicmouse.c: hid-magicmouse.c:35: ERROR: open brace '{' following function definitions go on the next line hid-magicmouse.c:46: ERROR: do not initialise statics to false hid-magicmouse.c:79: ERROR: Macros with complex values should be enclosed in parentheses hid-magicmouse.c:83: ERROR: Macros with complex values should be enclosed in parentheses hid-magicmouse.c:88: ERROR: Macros with complex values should be enclosed in parentheses hid-magicmouse.c:93: ERROR: Macros with complex values should be enclosed in parentheses hid-magicmouse.c:99: ERROR: Macros with complex values should be enclosed in parentheses hid-magicmouse.c:104: ERROR: Macros with complex values should be enclosed in parentheses hid-magicmouse.c:185: ERROR: do not use assignment in if condition Signed-off-by: José Expósito --- drivers/hid/hid-magicmouse.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 686788ebf3e1..b1ae61f9e675 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -33,7 +33,8 @@ MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel"); static unsigned int scroll_speed = 32; static int param_set_scroll_speed(const char *val, - const struct kernel_param *kp) { + const struct kernel_param *kp) +{ unsigned long speed; if (!val || kstrtoul(val, 0, &speed) || speed > 63) return -EINVAL; @@ -43,7 +44,7 @@ static int param_set_scroll_speed(const char *val, module_param_call(scroll_speed, param_set_scroll_speed, param_get_uint, &scroll_speed, 0644); MODULE_PARM_DESC(scroll_speed, "Scroll speed, value from 0 (slow) to 63 (fast)"); -static bool scroll_acceleration = false; +static bool scroll_acceleration; module_param(scroll_acceleration, bool, 0644); MODULE_PARM_DESC(scroll_acceleration, "Accelerate sequential scroll events"); @@ -76,32 +77,32 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie /* Touch surface information. Dimension is in hundredths of a mm, min and max * are in units. */ -#define MOUSE_DIMENSION_X (float)9056 +#define MOUSE_DIMENSION_X ((float)9056) #define MOUSE_MIN_X -1100 #define MOUSE_MAX_X 1258 #define MOUSE_RES_X ((MOUSE_MAX_X - MOUSE_MIN_X) / (MOUSE_DIMENSION_X / 100)) -#define MOUSE_DIMENSION_Y (float)5152 +#define MOUSE_DIMENSION_Y ((float)5152) #define MOUSE_MIN_Y -1589 #define MOUSE_MAX_Y 2047 #define MOUSE_RES_Y ((MOUSE_MAX_Y - MOUSE_MIN_Y) / (MOUSE_DIMENSION_Y / 100)) -#define TRACKPAD_DIMENSION_X (float)13000 +#define TRACKPAD_DIMENSION_X ((float)13000) #define TRACKPAD_MIN_X -2909 #define TRACKPAD_MAX_X 3167 #define TRACKPAD_RES_X \ ((TRACKPAD_MAX_X - TRACKPAD_MIN_X) / (TRACKPAD_DIMENSION_X / 100)) -#define TRACKPAD_DIMENSION_Y (float)11000 +#define TRACKPAD_DIMENSION_Y ((float)11000) #define TRACKPAD_MIN_Y -2456 #define TRACKPAD_MAX_Y 2565 #define TRACKPAD_RES_Y \ ((TRACKPAD_MAX_Y - TRACKPAD_MIN_Y) / (TRACKPAD_DIMENSION_Y / 100)) -#define TRACKPAD2_DIMENSION_X (float)16000 +#define TRACKPAD2_DIMENSION_X ((float)16000) #define TRACKPAD2_MIN_X -3678 #define TRACKPAD2_MAX_X 3934 #define TRACKPAD2_RES_X \ ((TRACKPAD2_MAX_X - TRACKPAD2_MIN_X) / (TRACKPAD2_DIMENSION_X / 100)) -#define TRACKPAD2_DIMENSION_Y (float)11490 +#define TRACKPAD2_DIMENSION_Y ((float)11490) #define TRACKPAD2_MIN_Y -2478 #define TRACKPAD2_MAX_Y 2587 #define TRACKPAD2_RES_Y \ @@ -182,14 +183,17 @@ static void magicmouse_emit_buttons(struct magicmouse_sc *msc, int state) /* The button was released. */ } else if (last_state != 0) { state = last_state; - } else if ((id = magicmouse_firm_touch(msc)) >= 0) { - int x = msc->touches[id].x; - if (x < middle_button_start) - state = 1; - else if (x > middle_button_stop) - state = 2; - else - state = 4; + } else { + id = magicmouse_firm_touch(msc); + if (id >= 0) { + int x = msc->touches[id].x; + if (x < middle_button_start) + state = 1; + else if (x > middle_button_stop) + state = 2; + else + state = 4; + } } /* else: we keep the mouse's guess */ input_report_key(msc->input, BTN_MIDDLE, state & 4); From patchwork Tue Sep 21 16:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12508337 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37914C433EF for ; Tue, 21 Sep 2021 16:33:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E1E56023D for ; Tue, 21 Sep 2021 16:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbhIUQfX (ORCPT ); Tue, 21 Sep 2021 12:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbhIUQfW (ORCPT ); Tue, 21 Sep 2021 12:35:22 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 048ACC061574; Tue, 21 Sep 2021 09:33:54 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id g16so40982172wrb.3; Tue, 21 Sep 2021 09:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4O959HY4uJXPTwzINpSqdurSsUaNuNPAPUgJobPVG8Y=; b=MlInAdkiy6d3MnQsTolT2Bk8UjDWVJq6CDFKLRHSiPl0PdM6a7QjNKRXnklXpJqjjl FMi6ckyCCgG8k3OP6Wi/OIzXkuxSVe2MjOHgFZMOtjO+t+1mKrpR3guNnSpocJo5+xa4 PIyRwxoYKbZo5LYunAoeMTHesPW7aFgTvo2Z9sGqIYj+oPM5RQAkDhtpAe5kwS7ppUSM pWW677fBkwJPnujvZG6H3ZWGC1p68P26D72Y25ML4QLN5Sd+lrb0UHps74NSbe0MMBgS BVlJRyPjP9g/eInwpqnKy7TIO3QTL+3k4ZQj6GaVPZVbf2dZId4dereZ24YwCq5xfwdq fhXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4O959HY4uJXPTwzINpSqdurSsUaNuNPAPUgJobPVG8Y=; b=smDbmZ3V3mn9g2M3CtHGkCeZf/pXDtyLTLIHMm2YngNi7k/dXejFUBJMMh/RSZpOpb avjwkLBV6Rl6IiyTk85NnrzwOdJqsyD/wKVQlMooiCFtzdtdNY/wIsc++XXMdwH7s0hp +5hSm9VfW7NuJ86mWIlJnkcDDvnWPDrIjHKLqw3ldWWUmncnkqUK/jDd6ktP6Z7HGsmn E6XEBmbYqVqTYoqgxEjD/Dq5Jm+m+VcVo/GYWgR0C+o/gYsGWU/VnOJqQVRaQIih4NHJ Bx/e4OCRKDNvPdBMw5fp0ibb3pmXf767JMSiNHQiJ/I7P+Db6zATS6FbuzfCSTfAq9xr mH6Q== X-Gm-Message-State: AOAM533C3+oLqv0IYj605pOTgyPEPM1FMXlvXqt7O/Nc+jODHYUaTmR5 OsDvx05bZWrxXKU63SUFiG0= X-Google-Smtp-Source: ABdhPJxD3FNRIsD+G7IkPP5YFYjGMI+Rxlu+9FHCJhUj7rJLK0EqnbgTt3EMbTW+L1tFw4L4P4uYVw== X-Received: by 2002:a5d:6292:: with SMTP id k18mr36425372wru.110.1632242032582; Tue, 21 Sep 2021 09:33:52 -0700 (PDT) Received: from localhost.localdomain ([94.73.35.139]) by smtp.gmail.com with ESMTPSA id z13sm23149308wrs.90.2021.09.21.09.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 09:33:52 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, rydberg@bitmath.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?Sm9z?= =?utf-8?b?w6kgRXhww7NzaXRv?= Subject: [PATCH RESEND 2/2] HID: magicmouse: fix checkpatch warnings Date: Tue, 21 Sep 2021 18:33:47 +0200 Message-Id: <20210921163347.7317-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210921163347.7317-1-jose.exposito89@gmail.com> References: <20210921163347.7317-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Fix warnings reported by checkpatch in hid-magicmouse.c: hid-magicmouse.c:39: WARNING: Missing a blank line after declarations hid-magicmouse.c:79: WARNING: Block comments use a trailing */ on a separate line hid-magicmouse.c:156: WARNING: Missing a blank line after declarations hid-magicmouse.c:190: WARNING: Missing a blank line after declarations hid-magicmouse.c:505: WARNING: Missing a blank line after declarations hid-magicmouse.c:756: WARNING: Possible unnecessary 'out of memory' message hid-magicmouse.c:825: WARNING: braces {} are not necessary for single statement blocks Ignore the following warning because in this case, the else statement is useful: hid-magicmouse.c:161: WARNING: else is not generally useful after a break or return Signed-off-by: José Expósito --- drivers/hid/hid-magicmouse.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index b1ae61f9e675..6fda883e23fb 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -36,6 +36,7 @@ static int param_set_scroll_speed(const char *val, const struct kernel_param *kp) { unsigned long speed; + if (!val || kstrtoul(val, 0, &speed) || speed > 63) return -EINVAL; scroll_speed = speed; @@ -76,7 +77,8 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie #define SCROLL_ACCEL_DEFAULT 7 /* Touch surface information. Dimension is in hundredths of a mm, min and max - * are in units. */ + * are in units. + */ #define MOUSE_DIMENSION_X ((float)9056) #define MOUSE_MIN_X -1100 #define MOUSE_MAX_X 1258 @@ -153,6 +155,7 @@ static int magicmouse_firm_touch(struct magicmouse_sc *msc) */ for (ii = 0; ii < msc->ntouches; ii++) { int idx = msc->tracking_ids[ii]; + if (msc->touches[idx].size < 8) { /* Ignore this touch. */ } else if (touch >= 0) { @@ -187,6 +190,7 @@ static void magicmouse_emit_buttons(struct magicmouse_sc *msc, int state) id = magicmouse_firm_touch(msc); if (id >= 0) { int x = msc->touches[id].x; + if (x < middle_button_start) state = 1; else if (x > middle_button_stop) @@ -502,6 +506,7 @@ static int magicmouse_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { struct magicmouse_sc *msc = hid_get_drvdata(hdev); + if (msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 && field->report->id == MOUSE2_REPORT_ID) { /* @@ -752,10 +757,8 @@ static int magicmouse_probe(struct hid_device *hdev, return -ENODEV; msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL); - if (msc == NULL) { - hid_err(hdev, "can't alloc magicmouse descriptor\n"); + if (msc == NULL) return -ENOMEM; - } msc->scroll_accel = SCROLL_ACCEL_DEFAULT; msc->hdev = hdev; @@ -822,9 +825,8 @@ static int magicmouse_probe(struct hid_device *hdev, hid_err(hdev, "unable to request touch data (%d)\n", ret); goto err_stop_hw; } - if (ret == -EIO && id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + if (ret == -EIO && id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) schedule_delayed_work(&msc->work, msecs_to_jiffies(500)); - } return 0; err_stop_hw: