From patchwork Mon Jul 18 14:29:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger-Novakovic X-Patchwork-Id: 9234695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2371A60865 for ; Mon, 18 Jul 2016 14:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16968228C8 for ; Mon, 18 Jul 2016 14:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B92726B41; Mon, 18 Jul 2016 14:30:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E607A228C8 for ; Mon, 18 Jul 2016 14:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbcGROaJ (ORCPT ); Mon, 18 Jul 2016 10:30:09 -0400 Received: from mout02.posteo.de ([185.67.36.66]:44804 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752029AbcGRO3Y (ORCPT ); Mon, 18 Jul 2016 10:29:24 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id F0A6E20F7C for ; Mon, 18 Jul 2016 16:29:20 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 3rtQXt3HR9z104S; Mon, 18 Jul 2016 16:29:18 +0200 (CEST) From: Martin Kepplinger To: dmitry.torokhov@gmail.com Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Martin Kepplinger Subject: [PATCH 1/4] input: tablet: pegasus_notetaker: Track usb control msg errors Date: Mon, 18 Jul 2016 16:29:06 +0200 Message-Id: <1468852149-2614-2-git-send-email-martink@posteo.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1468852149-2614-1-git-send-email-martink@posteo.de> References: <1468852149-2614-1-git-send-email-martink@posteo.de> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Martin Kepplinger --- drivers/input/tablet/pegasus_notetaker.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c index 83aa583..27cb352 100644 --- a/drivers/input/tablet/pegasus_notetaker.c +++ b/drivers/input/tablet/pegasus_notetaker.c @@ -79,7 +79,7 @@ struct pegasus { struct work_struct init; }; -static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len) +static int pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len) { const int sizeof_buf = len + 2; int result; @@ -87,7 +87,7 @@ static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len) cmd_buf = kmalloc(sizeof_buf, GFP_KERNEL); if (!cmd_buf) - return; + return -ENOMEM; cmd_buf[0] = NOTETAKER_REPORT_ID; cmd_buf[1] = len; @@ -100,17 +100,23 @@ static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len) 0, 0, cmd_buf, sizeof_buf, USB_CTRL_SET_TIMEOUT); - if (result != sizeof_buf) - dev_err(&pegasus->usbdev->dev, "control msg error\n"); + if (result != sizeof_buf) { + if (result >= 0) + result = -EIO; + dev_err(&pegasus->usbdev->dev, "control msg error: %d\n", + result); + } kfree(cmd_buf); + + return result; } -static void pegasus_set_mode(struct pegasus *pegasus, u8 mode, u8 led) +static int pegasus_set_mode(struct pegasus *pegasus, u8 mode, u8 led) { u8 cmd[] = {NOTETAKER_SET_CMD, NOTETAKER_SET_MODE, led, mode}; - pegasus_control_msg(pegasus, cmd, sizeof(cmd)); + return pegasus_control_msg(pegasus, cmd, sizeof(cmd)); } static void pegasus_parse_packet(struct pegasus *pegasus) @@ -184,8 +190,12 @@ static void pegasus_irq(struct urb *urb) static void pegasus_init(struct work_struct *work) { struct pegasus *pegasus = container_of(work, struct pegasus, init); + int retval; - pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); + retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); + if (retval < 0) + dev_err(&pegasus->usbdev->dev, "pegasus_set_mode error: %d\n", + retval); } static int pegasus_open(struct input_dev *dev) @@ -201,7 +211,7 @@ static int pegasus_open(struct input_dev *dev) if (usb_submit_urb(pegasus->irq, GFP_KERNEL)) retval = -EIO; - pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); + retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE); usb_autopm_put_interface(pegasus->intf);