From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422708AbcFMHiX (ORCPT ); Mon, 13 Jun 2016 03:38:23 -0400 Received: from bear.ext.ti.com ([198.47.19.11]:35862 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030203AbcFMHiV (ORCPT ); Mon, 13 Jun 2016 03:38:21 -0400 Subject: Re: [PATCH v10 13/14] usb: gadget: udc: adapt to OTG core To: Peter Chen References: <1465564043-27163-1-git-send-email-rogerq@ti.com> <1465564043-27163-14-git-send-email-rogerq@ti.com> <20160612113655.GC32615@shlinux2> <575E5D57.7010700@ti.com> <20160613072019.GB19728@shlinux2> CC: , , , , , , , , , , , , , , , , , , From: Roger Quadros Message-ID: <575E62D7.8010409@ti.com> Date: Mon, 13 Jun 2016 10:37:59 +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: <20160613072019.GB19728@shlinux2> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/06/16 10:20, Peter Chen wrote: > On Mon, Jun 13, 2016 at 10:14:31AM +0300, Roger Quadros wrote: >> On 12/06/16 14:36, Peter Chen wrote: >>> On Fri, Jun 10, 2016 at 04:07:22PM +0300, Roger Quadros wrote: >>>> >>>> +/** >>>> + * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list >>>> + * @parent: the parent device to this udc. Usually the controller >>>> + * driver's device. >>> >>> It seems it should be udc device >> >> Parent and udc->dev are not the same right? > > Sure, udc's parent is otg device. > >> >> I guess i'll omit the second statement to avoid confusion. So. >> >> @parent: the parent device to this udc. > > Where you call below APIs? It seems to be a udc driver, right? > So, when you try to get "otg-controller" from the node, this node > should be udc. @parent is actually the device that represents the USB Device controller in the device tree. When you call usb_add_gadget_udc_release() a new udc->dev device is created as it's child. See explanation for the @parent argument in usb_add_gadget_udc_release(). As we want to keep the parent argument identical to that I will not make any changes then. > > /** > * usb_otg_add_gadget_udc - adds a new gadget to the udc class driver list > * @parent: the parent device to this udc. Usually the controller > * driver's device. > * @gadget: the gadget to be added to the list > * @otg_dev: the OTG controller device > * > * If otg_dev is NULL then device tree node is checked > * for OTG controller via the otg-controller property. > * Returns zero on success, negative errno otherwise. > */ > int usb_otg_add_gadget_udc(struct device *parent, struct usb_gadget *gadget, > struct device *otg_dev) > { > if (!otg_dev) { > gadget->otg_dev = of_usb_get_otg(parent->of_node); > if (!gadget->otg_dev) > return -ENODEV; > } else { > gadget->otg_dev = otg_dev; > } > > return usb_add_gadget_udc_release(parent, gadget, NULL); > } > EXPORT_SYMBOL_GPL(usb_otg_add_gadget_udc); > -- cheers, -roger