From patchwork Wed May 31 20:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9758141 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 BBB5E60390 for ; Wed, 31 May 2017 21:01:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD7FE284C5 for ; Wed, 31 May 2017 21:01:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A21B0284C6; Wed, 31 May 2017 21:01:21 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 3F06E284C5 for ; Wed, 31 May 2017 21:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751053AbdEaVBH (ORCPT ); Wed, 31 May 2017 17:01:07 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33617 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751245AbdEaVAA (ORCPT ); Wed, 31 May 2017 17:00:00 -0400 Received: by mail-pf0-f193.google.com with SMTP id f27so4204533pfe.0; Wed, 31 May 2017 13:59:55 -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=8cNWTom72i7vHVu/AZVfYcI2kKGfNCGkvRAt3PkTkIE=; b=IaPRPvVoD9/ESYBRInA2VhRH9I+CdosEAaKPXhjr5iKniLAVImSEtjRKLvHK4HYnxo KBVBZ5bywEIa8jnYmqNRAMNTJ6ttPblT7GQ48y8AEBPFNUpi/08d9h0qLNwSftPDG/bT EwhbS+0abedb797tqi0hY4r61C0NZQYrgwckLrRKsI5z+CZtOUum9wph1asDbxIJn92c Sd/yIdkGtbqO24RjbAgrsGyH4+gYvuOOJEHQLCoQJJKDJ2amOpzSDNllnVKGR7ka5dkz 2ow8LMmcJ1MTG1EMC+1BLStpO1jv2TBMcBcR0iP885B8RhhuqxT1TyaZQQoD8zrxtJzx ndFQ== 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=8cNWTom72i7vHVu/AZVfYcI2kKGfNCGkvRAt3PkTkIE=; b=DIE8XJqW1xwXd1zbkhHHa9JJgHcMj3zFG8Uiiaqcrk2zngKoEBQNJ7uc9Jl921VSQI Zwhv6ut/clVieMFUHAZNSJ/Q/7JitxuMV8b/EEugopuTZ5lK33gzrZyrm17/GjuZSVA0 lNEvxL/vfLXiOaPrs7kfpX8iOk+13534i5VerMqmxXLHY0dr/IhLQHZyc1WwdHXuHv88 9BO3zs59jr9rTUxAXIvsZ+S74F7l/B0v6Ocs7veYAEVW1neWU3HwrqfBnBjqzyWrcTQP 9p3ZmIyJDOujwBgZe4PXTVbxpr6ckFMIXQG6D0Jge99wvk5XkmCuGqtbgDttIoygR9Md 5xAA== X-Gm-Message-State: AODbwcAuBBJanFs+M6WmdFvjRsZuJZBEf0f/VSv3VF4+d5pcNkxQyUVu QvUY01X1DSNSxISXe98= X-Received: by 10.101.90.78 with SMTP id z14mr13629353pgs.44.1496264394689; Wed, 31 May 2017 13:59:54 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id i5sm28547444pfj.41.2017.05.31.13.59.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 13:59:54 -0700 (PDT) From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] HID: hiddev: use hid_hw_power instead of usbhid_get/put_power Date: Wed, 31 May 2017 13:59:46 -0700 Message-Id: <20170531205951.30852-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.13.0.506.g27d5fe0cd-goog In-Reply-To: <20170531205951.30852-1-dmitry.torokhov@gmail.com> References: <20170531205951.30852-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. This also allows us to remove usbhid_get/put_power(), leaving only usbhid_power(). Signed-off-by: Dmitry Torokhov --- drivers/hid/usbhid/hid-core.c | 22 +++++----------------- drivers/hid/usbhid/hiddev.c | 4 ++-- drivers/hid/usbhid/usbhid.h | 2 -- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index fb0cf5d70504..62b660622265 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1203,16 +1203,19 @@ static void usbhid_stop(struct hid_device *hid) static int usbhid_power(struct hid_device *hid, int lvl) { + struct usbhid_device *usbhid = hid->driver_data; int r = 0; switch (lvl) { case PM_HINT_FULLON: - r = usbhid_get_power(hid); + r = usb_autopm_get_interface(usbhid->intf); break; + case PM_HINT_NORMAL: - usbhid_put_power(hid); + usb_autopm_put_interface(usbhid->intf); break; } + return r; } @@ -1492,21 +1495,6 @@ static int hid_post_reset(struct usb_interface *intf) return 0; } -int usbhid_get_power(struct hid_device *hid) -{ - struct usbhid_device *usbhid = hid->driver_data; - - return usb_autopm_get_interface(usbhid->intf); -} - -void usbhid_put_power(struct hid_device *hid) -{ - struct usbhid_device *usbhid = hid->driver_data; - - usb_autopm_put_interface(usbhid->intf); -} - - #ifdef CONFIG_PM static int hid_resume_common(struct hid_device *hid, bool driver_suspended) { diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index d949ac13af9e..8b62174582b5 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c @@ -238,7 +238,7 @@ static int hiddev_release(struct inode * inode, struct file * file) if (!--list->hiddev->open) { if (list->hiddev->exist) { hid_hw_close(list->hiddev->hid); - usbhid_put_power(list->hiddev->hid); + hid_hw_power(list->hiddev->hid, PM_HINT_NORMAL); } else { mutex_unlock(&list->hiddev->existancelock); kfree(list->hiddev); @@ -301,7 +301,7 @@ static int hiddev_open(struct inode *inode, struct file *file) if (!list->hiddev->open++) if (list->hiddev->exist) { struct hid_device *hid = hiddev->hid; - res = usbhid_get_power(hid); + res = hid_hw_power(hid, PM_HINT_FULLON); if (res < 0) { res = -EIO; goto bail_unlock; diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index 83ef5c14aa92..ffcd329b3c3b 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h @@ -35,8 +35,6 @@ /* API provided by hid-core.c for USB HID drivers */ void usbhid_init_reports(struct hid_device *hid); -int usbhid_get_power(struct hid_device *hid); -void usbhid_put_power(struct hid_device *hid); struct usb_interface *usbhid_find_interface(int minor); /* iofl flags */