From patchwork Wed Jun 7 06:59:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9770677 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 51F7460234 for ; Wed, 7 Jun 2017 07:01:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC7D28472 for ; Wed, 7 Jun 2017 07:01:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 329F5284ED; Wed, 7 Jun 2017 07:01:55 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 C888D28472 for ; Wed, 7 Jun 2017 07:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751650AbdFGHBx (ORCPT ); Wed, 7 Jun 2017 03:01:53 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36446 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467AbdFGG7m (ORCPT ); Wed, 7 Jun 2017 02:59:42 -0400 Received: by mail-pg0-f65.google.com with SMTP id v18so629751pgb.3; Tue, 06 Jun 2017 23:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n5o6Q4QoG/Cws0WCMfHYL+khDF+3gCux0wsKk9eABqs=; b=LnfXRGwDAO2E5/uemUrkzOVEkUcBKsjqvRaPKZOulAAI6GsTFRTc8P3li9SzmyqoBV MWBvIVTagkUf8oepDuijfusgU+I0+hpR9CRatBNmTfuSMWX+tQlvLrsNqbTkAjhYSQbz AvID6qXFOlIZcewAAkFiv3CZDTISSxALkRQVX3xjT9NHtFIHFIJWr+fBVMQ1uGUifD1b oMd0vN0ltv7f/KOtftUYx2dnhZB5qNez77uV5Z7dDfX8/F4ZZK6aEuSPJhiEmTJT9Hgx Ty8RDPiwwcF7PIZIW6J0IquJVUcx1sWUDRU2rFIOSTJlAGUMIEy4F1mQKjZuiajuYV33 rdBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n5o6Q4QoG/Cws0WCMfHYL+khDF+3gCux0wsKk9eABqs=; b=CfSECQYWfnDNYllbwnu/xNhkFID6LiGEgKzvYOCWy2nIB3cJ2G53W/3rzqWO95hMrp vlTpb9LEW0cFmPh2KgHQTCuDk6ybXk6oB4eUWw5pxd1o8PC1nu69yEOQ34UuHl7mlS1L vy+P15MNgFjFRHOX1vlWUSjBWJ8g6eMIHmqOS8UoNHMy9gk4oNuMvuZI82QF2A7g1mVv gKbswUCDB9FDM6PaVyYxskKbAr9BcIet6uhZEJHgWYrwcbDx1mqUZyzUyJ4k7SPrYVtT ONtHgXbgGYrjdm/6NCCQfFXqdBetPdUZMadpOHsReehqwbwgaDJqehsJ0JkaHLL2abnp z4xQ== X-Gm-Message-State: AODbwcCrgkrYHOAOmkA07JVYPY13q8zOY4MxMhIiAxA8ZTaPaN7aS17I GBFCByfQzOCCLtxamxo= X-Received: by 10.99.136.195 with SMTP id l186mr26836267pgd.77.1496818781240; Tue, 06 Jun 2017 23:59:41 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id r86sm1873184pfi.77.2017.06.06.23.59.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Jun 2017 23:59:40 -0700 (PDT) From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH v2 1/8] HID: hiddev: use hid_hw_open/close instead of usbhid_open/close Date: Tue, 6 Jun 2017 23:59:31 -0700 Message-Id: <20170607065938.33332-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.13.0.506.g27d5fe0cd-goog In-Reply-To: <20170607065938.33332-1-dmitry.torokhov@gmail.com> References: <20170607065938.33332-1-dmitry.torokhov@gmail.com> 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 Instead of calling into usbhid code directly, let's use the standard accessors for the transport HID drivers, and stop clobbering their errors with -EIO. This also allows us make usbhid_open and close static. Signed-off-by: Dmitry Torokhov --- drivers/hid/usbhid/hid-core.c | 4 ++-- drivers/hid/usbhid/hiddev.c | 16 +++++++++------- drivers/hid/usbhid/usbhid.h | 2 -- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 83772fa7d92a..fb0cf5d70504 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -677,7 +677,7 @@ static int hid_get_class_descriptor(struct usb_device *dev, int ifnum, return result; } -int usbhid_open(struct hid_device *hid) +static int usbhid_open(struct hid_device *hid) { struct usbhid_device *usbhid = hid->driver_data; int res = 0; @@ -722,7 +722,7 @@ int usbhid_open(struct hid_device *hid) return res; } -void usbhid_close(struct hid_device *hid) +static void usbhid_close(struct hid_device *hid) { struct usbhid_device *usbhid = hid->driver_data; diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 0e06368d1fbb..b4f714752245 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c @@ -237,7 +237,7 @@ static int hiddev_release(struct inode * inode, struct file * file) mutex_lock(&list->hiddev->existancelock); if (!--list->hiddev->open) { if (list->hiddev->exist) { - usbhid_close(list->hiddev->hid); + hid_hw_close(list->hiddev->hid); usbhid_put_power(list->hiddev->hid); } else { mutex_unlock(&list->hiddev->existancelock); @@ -282,11 +282,9 @@ static int hiddev_open(struct inode *inode, struct file *file) */ if (list->hiddev->exist) { if (!list->hiddev->open++) { - res = usbhid_open(hiddev->hid); - if (res < 0) { - res = -EIO; + res = hid_hw_open(hiddev->hid); + if (res < 0) goto bail; - } } } else { res = -ENODEV; @@ -306,10 +304,14 @@ static int hiddev_open(struct inode *inode, struct file *file) res = -EIO; goto bail_unlock; } - usbhid_open(hid); + res = hid_hw_open(hid); + if (res < 0) + goto bail_put_power; } mutex_unlock(&hiddev->existancelock); return 0; +bail_put_power: + usbhid_put_power(hid); bail_unlock: mutex_unlock(&hiddev->existancelock); bail: @@ -935,7 +937,7 @@ void hiddev_disconnect(struct hid_device *hid) if (hiddev->open) { mutex_unlock(&hiddev->existancelock); - usbhid_close(hiddev->hid); + hid_hw_close(hiddev->hid); wake_up_interruptible(&hiddev->wait); } else { mutex_unlock(&hiddev->existancelock); diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index fa47d666cfcf..83ef5c14aa92 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h @@ -34,8 +34,6 @@ #include /* API provided by hid-core.c for USB HID drivers */ -void usbhid_close(struct hid_device *hid); -int usbhid_open(struct hid_device *hid); void usbhid_init_reports(struct hid_device *hid); int usbhid_get_power(struct hid_device *hid); void usbhid_put_power(struct hid_device *hid);