From patchwork Fri May 1 00:51:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 6307741 X-Patchwork-Delegate: jikos@jikos.cz 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA9839F373 for ; Fri, 1 May 2015 00:52:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDC3B20120 for ; Fri, 1 May 2015 00:52:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1015F2011D for ; Fri, 1 May 2015 00:52:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753075AbbEAAwX (ORCPT ); Thu, 30 Apr 2015 20:52:23 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:36558 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752997AbbEAAwU (ORCPT ); Thu, 30 Apr 2015 20:52:20 -0400 Received: by pdea3 with SMTP id a3so77096326pde.3; Thu, 30 Apr 2015 17:52:19 -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=wk0RTaqFFDgwPKHsgDW2tmd0OCd7PZAuGSzdPz2d5v8=; b=bY2SYFDbzpu9RgJuZ4gzx/PaiMMTaGH5UlsuD+WDikuRRabVrVWsOa5opSP+2srSDa 4gCinuxq2z2Im1jdbBOoYJOW4WkNRPy9xoO7u00RiwnQ7cCG/yKHD+2E+AMM2/5bDv2G nSJ09TuMZTl1HncDk6tMHK0YgT8w3weYvVapE8KK38ud9qR0rsb1wcKvNsHjvQmO+Hb+ eVvD+sGfp8nnxhQ3p/mFJbbCX1TpQ3ESxtxL8qV4Xc6LrBZOPeHkQgDF6itTFB1qBFC+ smwUinDXo+RLT2AccysOwt6oo29p7HrONjmt88bHH4jTHZ3Tav1tXpRqWbDIkEMeue3P iTLA== X-Received: by 10.66.252.3 with SMTP id zo3mr12908736pac.26.1430441539870; Thu, 30 Apr 2015 17:52:19 -0700 (PDT) Received: from wacom-arch2.localdomain ([67.51.163.2]) by mx.google.com with ESMTPSA id kn7sm3296368pab.10.2015.04.30.17.52.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Apr 2015 17:52:18 -0700 (PDT) From: Jason Gerecke To: Jiri Kosina , Ping Cheng , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Gerecke , Jason Gerecke Subject: [PATCH 3/3] HID: wacom: Fail probe if HID_GENERIC device has unknown device_type Date: Thu, 30 Apr 2015 17:51:55 -0700 Message-Id: <1430441515-30122-3-git-send-email-killertofu@gmail.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430441515-30122-1-git-send-email-killertofu@gmail.com> References: <1430441515-30122-1-git-send-email-killertofu@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=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 The last patch was careful to maintain backwards-compatible behavior by forcing device_type to BTN_TOOL_PEN (and printing a warning) if it were still uninitialized after scanning the HID descriptor and applying quirks. We should be more strict with HID_GENERIC devices, however, since there is no a priori guarantee that it is a tablet or touchpad. If the device_type is still uninitialized for a HID_GENERIC device then we assume that it isn't something the driver can work with and so fail the probe. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_sys.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 157aa7a..7abf52c 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1528,8 +1528,14 @@ static int wacom_probe(struct hid_device *hdev, wacom_setup_device_quirks(wacom); if (!features->device_type && features->type != WIRELESS) { + error = features->type == HID_GENERIC ? -ENODEV : 0; + dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.", - hdev->name, "Assuming pen"); + hdev->name, + error ? "Ignoring" : "Assuming pen"); + + if (error) + goto fail_shared_data; features->device_type = BTN_TOOL_PEN; }