From patchwork Tue Apr 14 10:41:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 6214841 Return-Path: X-Original-To: patchwork-linux-omap@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 ED9589F1C4 for ; Tue, 14 Apr 2015 10:44:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E18A2021F for ; Tue, 14 Apr 2015 10:44:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6537F202DD for ; Tue, 14 Apr 2015 10:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755185AbbDNKor (ORCPT ); Tue, 14 Apr 2015 06:44:47 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:46205 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753613AbbDNKmb (ORCPT ); Tue, 14 Apr 2015 06:42:31 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t3EAgPdX010859; Tue, 14 Apr 2015 05:42:25 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t3EAgOuI025980; Tue, 14 Apr 2015 05:42:24 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Tue, 14 Apr 2015 05:42:24 -0500 Received: from rockdesk.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t3EAg1wM025336; Tue, 14 Apr 2015 05:42:21 -0500 From: Roger Quadros To: , , CC: , , , , , , , , Roger Quadros Subject: [RFC][PATCH v2 06/13] usb: hcd: Add hcd add/remove functions for OTG use Date: Tue, 14 Apr 2015 13:41:53 +0300 Message-ID: <1429008120-5395-7-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1429008120-5395-1-git-send-email-rogerq@ti.com> References: <1429008120-5395-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 existing usb_add/remove_hcd() functionality remains unchanged for non-OTG devices. For OTG devices they only register the HCD with the OTG core. Introduce _usb_add/remove_hcd() for use by OTG core. These functions actually add/remove the HCD. Signed-off-by: Roger Quadros --- drivers/usb/common/usb-otg.c | 14 +++++++------- drivers/usb/core/hcd.c | 24 ++++++++++++++++++++++-- include/linux/usb/hcd.h | 3 +++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/usb/common/usb-otg.c b/drivers/usb/common/usb-otg.c index e848e08..860e2e7 100644 --- a/drivers/usb/common/usb-otg.c +++ b/drivers/usb/common/usb-otg.c @@ -198,18 +198,18 @@ static int usb_otg_start_host(struct otg_fsm *fsm, int on) otgd->start_host(fsm, on); /* start host */ - usb_add_hcd(otgd->primary_hcd.hcd, otgd->primary_hcd.irqnum, - otgd->primary_hcd.irqflags); + _usb_add_hcd(otgd->primary_hcd.hcd, otgd->primary_hcd.irqnum, + otgd->primary_hcd.irqflags); if (otgd->shared_hcd.hcd) { - usb_add_hcd(otgd->shared_hcd.hcd, - otgd->shared_hcd.irqnum, - otgd->shared_hcd.irqflags); + _usb_add_hcd(otgd->shared_hcd.hcd, + otgd->shared_hcd.irqnum, + otgd->shared_hcd.irqflags); } } else { /* stop host */ if (otgd->shared_hcd.hcd) - usb_remove_hcd(otgd->shared_hcd.hcd); - usb_remove_hcd(otgd->primary_hcd.hcd); + _usb_remove_hcd(otgd->shared_hcd.hcd); + _usb_remove_hcd(otgd->primary_hcd.hcd); /* OTG device operations */ if (otgd->start_host) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 45a915c..9a9c0f7 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -46,6 +46,7 @@ #include #include #include +#include #include "usb.h" @@ -2622,7 +2623,7 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd) * buffers of consistent memory, register the bus, request the IRQ line, * and call the driver's reset() and start() routines. */ -int usb_add_hcd(struct usb_hcd *hcd, +int _usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags) { int retval; @@ -2827,6 +2828,17 @@ err_phy: } return retval; } +EXPORT_SYMBOL_GPL(_usb_add_hcd); + +int usb_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags) +{ + /* If OTG device, OTG core takes care of adding HCD */ + if (usb_otg_register_hcd(hcd, irqnum, irqflags)) + return _usb_add_hcd(hcd, irqnum, irqflags); + + return 0; +} EXPORT_SYMBOL_GPL(usb_add_hcd); /** @@ -2837,7 +2849,7 @@ EXPORT_SYMBOL_GPL(usb_add_hcd); * Disconnects the root hub, then reverses the effects of usb_add_hcd(), * invoking the HCD's stop() method. */ -void usb_remove_hcd(struct usb_hcd *hcd) +void _usb_remove_hcd(struct usb_hcd *hcd) { struct usb_device *rhdev = hcd->self.root_hub; @@ -2911,6 +2923,14 @@ void usb_remove_hcd(struct usb_hcd *hcd) usb_put_invalidate_rhdev(hcd); } +EXPORT_SYMBOL_GPL(_usb_remove_hcd); + +void usb_remove_hcd(struct usb_hcd *hcd) +{ + /* If OTG device, OTG core takes care of stopping HCD */ + if (usb_otg_unregister_hcd(hcd)) + _usb_remove_hcd(hcd); +} EXPORT_SYMBOL_GPL(usb_remove_hcd); void diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 68b1e83..7993ae7 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -433,7 +433,10 @@ extern void usb_put_hcd(struct usb_hcd *hcd); extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd); extern int usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags); +extern int _usb_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags); extern void usb_remove_hcd(struct usb_hcd *hcd); +extern void _usb_remove_hcd(struct usb_hcd *hcd); extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); struct platform_device;