From patchwork Fri Jul 20 09:49:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 1220251 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D8DB33FC5A for ; Fri, 20 Jul 2012 09:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224Ab2GTJtD (ORCPT ); Fri, 20 Jul 2012 05:49:03 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:36748 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752905Ab2GTJtC (ORCPT ); Fri, 20 Jul 2012 05:49:02 -0400 Received: by wibhq12 with SMTP id hq12so357012wib.1 for ; Fri, 20 Jul 2012 02:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=E30zGpWE8+1102VuurNk+iCU55jNbc0hWhGLks5eO1E=; b=vduLFHiwO3DSbc7ZvyoE1XXDvhiCGKP27B86GlwwyY3D8jIjr+ARwzjSEtSYGcdb4g 4nlkcQ8RUs5ZVdtC5QFaVbjBFr31bgejn27B0ZpIzHOp3kfOG32GGyq0JmvYarg9OR5B 5i2oo5OpRVOcTT+XOwK3EQqyznhpy53X0BIzKbhnYEjELn5XUM0nCGRLlh4YUz/2JvTL JiKpqHyOrKtYNziHhnRPxBFQjFBNxoBsFVbl3Oelax1FwT/7fu5MqBUJDNkg7xhXVWBO 1U8NIQ9EEsle7UhAlI56C614ib7iTvvnv1IFELP6yV8jaP/dUcQwzA62jh0Spooc4Mm7 uJEQ== Received: by 10.180.83.234 with SMTP id t10mr2993139wiy.0.1342777741158; Fri, 20 Jul 2012 02:49:01 -0700 (PDT) Received: from localhost.localdomain (stgt-5f719af5.pool.mediaWays.net. [95.113.154.245]) by mx.google.com with ESMTPS id de10sm13959300wib.7.2012.07.20.02.49.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 Jul 2012 02:49:00 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, rydberg@euromail.se, David Herrmann Subject: [PATCH v3] HID: Allow drivers to be their own listener Date: Fri, 20 Jul 2012 11:49:09 +0200 Message-Id: <1342777749-31457-1-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.11.2 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org hid-picolcd and hid-wiimote do not allow any of hidinput, hiddev or hidraw to claim the device but still want to remain on the bus. Hence, if a driver uses the raw_event callback but no other listener claimed the device, we still leave it on the bus as the driver handles everything by itself. It thus becomes its own listener. Under some circumstances (eg., hidinput_connect() fails and raw_event set) a device may be left on the bus even though it requires external listeners. But then if hidinput_connect() fails there are bigger issues than a device that is left unhandled. So we can safely use this heuristic to avoid adding another flag for special devices like hid-picolcd and hid-wiimote. This also removes the ugly hack from hid-picolcd as this is no longer required. Signed-off-by: David Herrmann --- Sorry for the delay. I had two exams this week that got into my way. Anyway, I hope this time the patch looks ok. Thanks to Henrik for reviewing it the previous times. drivers/hid/hid-core.c | 6 ++++-- drivers/hid/hid-picolcd.c | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9cdc74e..925774a 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1373,8 +1373,10 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) if ((connect_mask & HID_CONNECT_HIDRAW) && !hidraw_connect(hdev)) hdev->claimed |= HID_CLAIMED_HIDRAW; - if (!hdev->claimed) { - hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); + /* Drivers with the ->raw_event callback set are not required to connect + * to any other listener. */ + if (!hdev->claimed && !hdev->driver->raw_event) { + hid_err(hdev, "device has no listeners, quitting\n"); return -ENODEV; } diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c index 45c3433..74c388d 100644 --- a/drivers/hid/hid-picolcd.c +++ b/drivers/hid/hid-picolcd.c @@ -2613,11 +2613,7 @@ static int picolcd_probe(struct hid_device *hdev, goto err_cleanup_data; } - /* We don't use hidinput but hid_hw_start() fails if nothing is - * claimed. So spoof claimed input. */ - hdev->claimed = HID_CLAIMED_INPUT; error = hid_hw_start(hdev, 0); - hdev->claimed = 0; if (error) { hid_err(hdev, "hardware start failed\n"); goto err_cleanup_data;