From patchwork Fri Feb 8 14:37:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 2116101 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 A0F313FCA4 for ; Fri, 8 Feb 2013 14:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946550Ab3BHOim (ORCPT ); Fri, 8 Feb 2013 09:38:42 -0500 Received: from mail-wi0-f172.google.com ([209.85.212.172]:56251 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1946496Ab3BHOie (ORCPT ); Fri, 8 Feb 2013 09:38:34 -0500 Received: by mail-wi0-f172.google.com with SMTP id ez12so933529wid.11 for ; Fri, 08 Feb 2013 06:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=2V3ijRLIISY2hukKVJXvDxTXKtY8xJe0DDLmIEKE6A0=; b=GMTyd27oAApRu5wdbrEW28oBKSrcf+A/dthNhC1mEpVdbwDbOu2nfq+T10ajMdSeD8 SvHNuk+2DEhAmLxbOafnHQ9R51Ov/4oa+CkpOZczaKwiknu0W1KMmCXSRylFZDj1Kaz8 uA6k5NlAbWD1ZtjrqCGsBNCE9mcGg6iR3g8jzrFizRYA3q7wym1LfTv6S9Tx0lJOg5Ga e6Hc3VL42CoRdTxAoTmcdreqeQK7BumYCqv/eaoBmN9g51t6dLPTigMOel24NFRA1x9m sCmHAu4BIRbt8LR1kk85fNFfPv//LS4mqPzdZUZXJ4MLPp6AjWF/GkPabi2rgbWOjPji OvEg== X-Received: by 10.194.216.5 with SMTP id om5mr10269573wjc.27.1360334302893; Fri, 08 Feb 2013 06:38:22 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id o13sm9534562wie.10.2013.02.08.06.38.21 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 08 Feb 2013 06:38:22 -0800 (PST) From: Benjamin Tissoires To: Benjamin Tissoires , Dmitry Torokhov , Henrik Rydberg , Jiri Kosina , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] HID: Extend the interface with wait io request Date: Fri, 8 Feb 2013 15:37:31 +0100 Message-Id: <1360334256-22127-3-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360334256-22127-1-git-send-email-benjamin.tissoires@gmail.com> References: <1360334256-22127-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Some drivers need to wait for an io from the underlying device, creating an unwanted dependency on the underlying transport layer. This patch adds wait() to the interface, thereby removing usbhid from the lion share of the drivers. Signed-off-by: Benjamin Tissoires --- drivers/hid/usbhid/hid-core.c | 1 + include/linux/hid.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 366fd09..99d95d3 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1264,6 +1264,7 @@ static struct hid_ll_driver usb_hid_driver = { .power = usbhid_power, .hidinput_input_event = usb_hidinput_input_event, .request = usbhid_request, + .wait = usbhid_wait_io, }; static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id) diff --git a/include/linux/hid.h b/include/linux/hid.h index 261c713..7071eb3 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -663,6 +663,7 @@ struct hid_driver { * @parse: this method is called only once to parse the device data, * shouldn't allocate anything to not leak memory * @request: send report request to device (e.g. feature report) + * @wait: wait for buffered io to complete (send/recv reports) */ struct hid_ll_driver { int (*start)(struct hid_device *hdev); @@ -681,6 +682,8 @@ struct hid_ll_driver { void (*request)(struct hid_device *hdev, struct hid_report *report, int reqtype); + int (*wait)(struct hid_device *hdev); + }; #define PM_HINT_FULLON 1<<5 @@ -903,6 +906,17 @@ static inline void hid_hw_request(struct hid_device *hdev, hdev->ll_driver->request(hdev, report, reqtype); } +/** + * hid_hw_wait - wait for buffered io to complete + * + * @hdev: hid device + */ +static inline void hid_hw_wait(struct hid_device *hdev) +{ + if (hdev->ll_driver->wait) + hdev->ll_driver->wait(hdev); +} + int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, int interrupt);