Message ID | 20231020090237.201029-1-suhui@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp919702vqb; Fri, 20 Oct 2023 02:03:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOpTZxCEbSLzRkPh8wPSrKNKYmD/2J5+3k6Fb9R0MeKU3juJagjzR7HCxsqMIi7fTgJfWi X-Received: by 2002:a05:6e02:1be8:b0:357:97fb:b173 with SMTP id y8-20020a056e021be800b0035797fbb173mr1670427ilv.28.1697792613968; Fri, 20 Oct 2023 02:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697792613; cv=none; d=google.com; s=arc-20160816; b=r3M6+o/STZTjD5FTQauF7pEg1Pe3HN1B3kh2PRB/gIiDiTWcoTsoT58PCaEnQK92PG SgKRam0i3YSpAuRB3OGxHIW1T7y7o8UY9I5vY2BI/re34t23xBzeBKSRoPfXYUSkhBoy Mik8zui1iRiDxegECUBHtXb+D3QjK9YqDKvojx4fV4T7afvwWT1reM5dK4Lgr6XxEYsO NJnL5mFwIAeDJCrqYw55IUj4IMHTLLJv9I120uwc0pAmklfk6wB9vGGFy3uZzLbw7UXG jgnYZiNMEqTs7T2tPD+RI8lfh0CIAIHTGWUjwqH+IgI3/1L7QhL+dHkqCnrMtZwmrj6M 1how== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wBzBUXCTd/wDFAW8YBoecWm78OE0NcxPGxQpfig9dlw=; fh=E9sYvlP+TBJD7N0328pTkSurr+8vBd1ZTmxlWFB9Q64=; b=g2ddKin3DRAl6CWs14ZrgXBL0sv/Tctjc+famDPE8P4X/gBMOmPDVjmjVEQtMBV0dI jfVnHQs78uRAzWTWLfvF2qK5URRW6jO7mXakIomxOUT2KyoFJJ0uY/63rw+j0MP4IcuA 15xzNfHbKaUjRWL0EsLVw0u+0cUZGfN3b1BOiv02ejPpzGgbNtmmwvkdJ5cgS25ZapzE B12Ug57T35bIG98vzO4iHajdhhmVJcUnN+PIdneKCmBQOgvxkjgVbKmboSweEKDxEFWY yUlNYzzGec3ob6LRiugRyHq6ejLIvRxpXzjkmaqnsqGTjQXpTK1BE9Z2PPj+j4Tnvum5 MLzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n3-20020a6546c3000000b0056b024a4dd0si1333081pgr.614.2023.10.20.02.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C99568339648; Fri, 20 Oct 2023 02:03:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376575AbjJTJDN (ORCPT <rfc822;lkml4gm@gmail.com> + 25 others); Fri, 20 Oct 2023 05:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376523AbjJTJDL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 05:03:11 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id B937AD67; Fri, 20 Oct 2023 02:03:06 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 776BE60494CD8; Fri, 20 Oct 2023 17:03:03 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui <suhui@nfschina.com> To: ping.cheng@wacom.com, jason.gerecke@wacom.com, jikos@kernel.org, benjamin.tissoires@redhat.com Cc: Su Hui <suhui@nfschina.com>, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] HID: wacom_sys: add error code check in wacom_feature_mapping Date: Fri, 20 Oct 2023 17:02:38 +0800 Message-Id: <20231020090237.201029-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:03:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780264587923051501 X-GMAIL-MSGID: 1780264587923051501 |
Series |
HID: wacom_sys: add error code check in wacom_feature_mapping
|
|
Commit Message
Su Hui
Oct. 20, 2023, 9:02 a.m. UTC
hid_report_raw_event() can return error code like '-ENOMEM' if
failed, so check 'ret' to make sure all things work fine.
Signed-off-by: Su Hui <suhui@nfschina.com>
---
drivers/hid/wacom_sys.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Fri, 20 Oct, 2023 17:02:38 +0800 "Su Hui" <suhui@nfschina.com> wrote: > hid_report_raw_event() can return error code like '-ENOMEM' if > failed, so check 'ret' to make sure all things work fine. I can agree with adding logging for error cases personally. > > Signed-off-by: Su Hui <suhui@nfschina.com> > --- > drivers/hid/wacom_sys.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c > index 3f704b8072e8..1f898d4ee708 100644 > --- a/drivers/hid/wacom_sys.c > +++ b/drivers/hid/wacom_sys.c > @@ -320,6 +320,8 @@ static void wacom_feature_mapping(struct hid_device *hdev, > if (ret == n && features->type == HID_GENERIC) { > ret = hid_report_raw_event(hdev, > HID_FEATURE_REPORT, data, n, 0); > + if (ret) > + hid_warn(hdev, "failed to report feature\n"); I think we should report the returned error information as well. https://docs.kernel.org/core-api/printk-formats.html#error-pointers Typically what I do is use ERR_PTR in tandem with the %pe modifier for printing errors. > } else if (ret == 2 && features->type != HID_GENERIC) { > features->touch_max = data[1]; > } else { > @@ -381,6 +383,8 @@ static void wacom_feature_mapping(struct hid_device *hdev, > if (ret == n) { > ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, > data, n, 0); > + if (ret) > + hid_warn(hdev, "failed to report feature\n"); > } else { > hid_warn(hdev, "%s: could not retrieve sensor offsets\n", > __func__); -- Thanks for the patch, Rahul Rameshbabu
On 2023/11/6 11:57, Rahul Rameshbabu wrote: > On Fri, 20 Oct, 2023 17:02:38 +0800 "Su Hui" <suhui@nfschina.com> wrote: >> hid_report_raw_event() can return error code like '-ENOMEM' if >> failed, so check 'ret' to make sure all things work fine. > I can agree with adding logging for error cases personally. > >> Signed-off-by: Su Hui <suhui@nfschina.com> >> --- >> drivers/hid/wacom_sys.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c >> index 3f704b8072e8..1f898d4ee708 100644 >> --- a/drivers/hid/wacom_sys.c >> +++ b/drivers/hid/wacom_sys.c >> @@ -320,6 +320,8 @@ static void wacom_feature_mapping(struct hid_device *hdev, >> if (ret == n && features->type == HID_GENERIC) { >> ret = hid_report_raw_event(hdev, >> HID_FEATURE_REPORT, data, n, 0); >> + if (ret) >> + hid_warn(hdev, "failed to report feature\n"); > I think we should report the returned error information as well. Agreed, I will send v2 soon. Thanks for your suggestions! Su Hui > > https://docs.kernel.org/core-api/printk-formats.html#error-pointers > > Typically what I do is use ERR_PTR in tandem with the %pe modifier for > printing errors. > >> } else if (ret == 2 && features->type != HID_GENERIC) { >> features->touch_max = data[1]; >> } else { >> @@ -381,6 +383,8 @@ static void wacom_feature_mapping(struct hid_device *hdev, >> if (ret == n) { >> ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, >> data, n, 0); >> + if (ret) >> + hid_warn(hdev, "failed to report feature\n"); >> } else { >> hid_warn(hdev, "%s: could not retrieve sensor offsets\n", >> __func__); > -- > Thanks for the patch, > > Rahul Rameshbabu >
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 3f704b8072e8..1f898d4ee708 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -320,6 +320,8 @@ static void wacom_feature_mapping(struct hid_device *hdev, if (ret == n && features->type == HID_GENERIC) { ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, data, n, 0); + if (ret) + hid_warn(hdev, "failed to report feature\n"); } else if (ret == 2 && features->type != HID_GENERIC) { features->touch_max = data[1]; } else { @@ -381,6 +383,8 @@ static void wacom_feature_mapping(struct hid_device *hdev, if (ret == n) { ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, data, n, 0); + if (ret) + hid_warn(hdev, "failed to report feature\n"); } else { hid_warn(hdev, "%s: could not retrieve sensor offsets\n", __func__);