From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965278AbcFMIRE (ORCPT ); Mon, 13 Jun 2016 04:17:04 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:33937 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964842AbcFMIRB (ORCPT ); Mon, 13 Jun 2016 04:17:01 -0400 Subject: Re: [PATCH v10 09/14] usb: of: add an API to get OTG device from USB controller node To: Jun Li , "peter.chen@freescale.com" References: <1465564043-27163-1-git-send-email-rogerq@ti.com> <1465564043-27163-10-git-send-email-rogerq@ti.com> CC: "balbi@kernel.org" , "tony@atomide.com" , "gregkh@linuxfoundation.org" , "dan.j.williams@intel.com" , "mathias.nyman@linux.intel.com" , "Joao.Pinto@synopsys.com" , "sergei.shtylyov@cogentembedded.com" , "jun.li@freescale.com" , "grygorii.strashko@ti.com" , "yoshihiro.shimoda.uh@renesas.com" , "robh@kernel.org" , "nsekhar@ti.com" , "b-liu@ti.com" , "joe@perches.com" , "linux-usb@vger.kernel.org" , "linux-omap@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" From: Roger Quadros Message-ID: <575E6BE6.7020800@ti.com> Date: Mon, 13 Jun 2016 11:16:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/06/16 11:13, Jun Li wrote: > Hi > >> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c >> index e3d0161..d7ec471 100644 >> --- a/drivers/usb/common/common.c >> +++ b/drivers/usb/common/common.c >> @@ -238,6 +238,33 @@ int of_usb_update_otg_caps(struct device_node *np, } >> EXPORT_SYMBOL_GPL(of_usb_update_otg_caps); >> >> +#ifdef CONFIG_USB_OTG >> +/** >> + * of_usb_get_otg - get the OTG controller linked to the USB controller >> + * @np: Pointer to the device_node of the USB controller >> + * @otg_caps: Pointer to the target usb_otg_caps to be set > > Remove otg_caps. Sure. > >> + * >> + * Returns the OTG controller device or NULL on error. >> + */ >> +struct device *of_usb_get_otg(struct device_node *np) { >> + struct device_node *otg_np; >> + struct platform_device *pdev; >> + >> + otg_np = of_parse_phandle(np, "otg-controller", 0); >> + if (!otg_np) >> + return NULL; >> + >> + pdev = of_find_device_by_node(otg_np); >> + of_node_put(otg_np); >> + if (!pdev) >> + return NULL; >> + >> + return &pdev->dev; >> +} >> +EXPORT_SYMBOL_GPL(of_usb_get_otg); >> +#endif >> + >> #endif >> >> MODULE_LICENSE("GPL"); >> diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index >> de3237f..499a4e8 100644 >> --- a/include/linux/usb/of.h >> +++ b/include/linux/usb/of.h >> @@ -40,6 +40,15 @@ static inline struct device_node >> *usb_of_get_child_node } #endif >> >> +#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_OTG) struct device >> +*of_usb_get_otg(struct device_node *np); #else static inline struct >> +device *of_usb_get_otg(struct device_node *np) { >> + return NULL; >> +} >> +#endif >> + >> #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) enum >> usb_phy_interface of_usb_get_phy_mode(struct device_node *np); #else >> -- >> 2.7.4 > -- cheers, -roger