From: Felipe Balbi <balbi@ti.com>
To: Linux USB Mailing List <linux-usb@vger.kernel.org>
Cc: kgene.kim@samsung.com, eric.y.miao@gmail.com,
kuninori.morimoto.gx@renesas.com,
alexander.shishkin@linux.intel.com, gregkh@linuxfoundation.org,
yoshihiro.shimoda.uh@renesas.com, nicolas.ferre@atmel.com,
linux-geode@lists.infradead.org, haojian.zhuang@gmail.com,
Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
linux-samsung-soc@vger.kernel.org, Felipe Balbi <balbi@ti.com>,
ben-linux@fluff.org, dahlmann.thomas@arcor.de,
linux@arm.linux.org.uk, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: [RFC/PATCH 01/32] usb: gadget: udc-core: allow udc class register gadget device
Date: Thu, 24 Jan 2013 17:45:39 +0200 [thread overview]
Message-ID: <1359042370-4358-2-git-send-email-balbi@ti.com> (raw)
In-Reply-To: <1359042370-4358-1-git-send-email-balbi@ti.com>
Currently all UDC drivers are calling
device_register() before calling
usb_add_gadget_udc(). In order to avoid
code duplication, we can allow udc-core.c
register that device.
However that would become a really large patch,
so to cope with the meanwhile and allow us
to write bite-sized patches, we're adding
a flag which will be set by UDC driver once
it removes the code for registering the
gadget device.
Once all are converted, the new flag will
be removed.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/usb/gadget/udc-core.c | 23 +++++++++++++++++++----
include/linux/usb/gadget.h | 4 ++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 2a9cd36..9195054 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -173,6 +173,14 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
if (!udc)
goto err1;
+ if (gadget->register_my_device) {
+ dev_set_name(&gadget->dev, "gadget");
+
+ ret = device_register(&gadget->dev);
+ if (ret)
+ goto err2;
+ }
+
device_initialize(&udc->dev);
udc->dev.release = usb_udc_release;
udc->dev.class = udc_class;
@@ -180,7 +188,7 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
udc->dev.parent = parent;
ret = dev_set_name(&udc->dev, "%s", kobject_name(&parent->kobj));
if (ret)
- goto err2;
+ goto err3;
udc->gadget = gadget;
@@ -189,18 +197,22 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
ret = device_add(&udc->dev);
if (ret)
- goto err3;
+ goto err4;
mutex_unlock(&udc_lock);
return 0;
-err3:
+
+err4:
list_del(&udc->list);
mutex_unlock(&udc_lock);
-err2:
+err3:
put_device(&udc->dev);
+err2:
+ if (gadget->register_my_device)
+ put_device(&gadget->dev);
err1:
return ret;
}
@@ -254,6 +266,9 @@ found:
kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
device_unregister(&udc->dev);
+
+ if (gadget->register_my_device)
+ device_unregister(&gadget->dev);
}
EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 2e297e8..fcd9ef8 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -494,6 +494,9 @@ struct usb_gadget_ops {
* only supports HNP on a different root port.
* @b_hnp_enable: OTG device feature flag, indicating that the A-Host
* enabled HNP support.
+ * @register_my_device: Flag telling udc-core that UDC driver didn't
+ * register the gadget device to the driver model. Temporary until
+ * all UDC drivers are fixed up properly.
* @name: Identifies the controller hardware type. Used in diagnostics
* and sometimes configuration.
* @dev: Driver model state for this abstract device.
@@ -531,6 +534,7 @@ struct usb_gadget {
unsigned b_hnp_enable:1;
unsigned a_hnp_support:1;
unsigned a_alt_hnp_support:1;
+ unsigned register_my_device:1;
const char *name;
struct device dev;
unsigned out_epnum;
--
1.8.1.rc1.5.g7e0651a
next prev parent reply other threads:[~2013-01-24 15:46 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-24 15:45 [RFC/PATCH 00/32] usb: refactor gadget->dev registration Felipe Balbi
2013-01-24 15:45 ` Felipe Balbi [this message]
2013-01-24 18:57 ` [RFC/PATCH 01/32] usb: gadget: udc-core: allow udc class register gadget device Tomasz Figa
2013-01-24 15:45 ` [RFC/PATCH 02/32] usb: dwc3: gadget: let udc-core manage gadget->dev Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 03/32] usb: musb: gadget: let udc-core manage gadget-dev Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 04/32] usb: gadget: omap_udc: let udc-core manage gadget->dev Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 05/32] usb: gadget: amd5536udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 06/32] usb: gadget: at91_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 07/32] usb: gadget: atmel_usba_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 08/32] usb: gadget: bcm63xx_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 09/32] usb: gadget: dummy_hcd: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 10/32] usb: gadget: fsl_qe_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 11/32] usb: gadget: fsl_udc_core: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 12/32] usb: gadget: fusb300_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 13/32] usb: gadget: goku_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 14/32] usb: gadget: imx_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 15/32] usb: gadget: lpc32xx_udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 16/32] usb: gadget: m66592-udc: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 17/32] usb: gadget: mv_u3d_core: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 18/32] usb: gadget: mv_u3d_core: fix a compile warning Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 19/32] usb: gadget: mv_udc_core: let udc-core manage gadget->dev Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 20/32] usb: gadget: net2272: " Felipe Balbi
2013-01-24 15:45 ` [RFC/PATCH 21/32] usb: gadget: net2280: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 22/32] usb: gadget: pch_udc: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 23/32] usb: gadget: r8a66597-udc: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 24/32] usb: gadget: s3c-hsotg: " Felipe Balbi
2013-01-24 19:00 ` Tomasz Figa
2013-01-24 15:46 ` [RFC/PATCH 25/32] usb: gadget: s3c-hsudc: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 26/32] usb: gadget: s3c2410_udc: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 27/32] usb: renesas_usbhs: gadget: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 28/32] usb: gadget: pxa25x_udc: " Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 29/32] usb: gadget: pxa27x_udc: " Felipe Balbi
2013-01-28 20:18 ` Robert Jarzmik
2013-02-04 19:53 ` Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 30/32] usb: chipidea: register debugging syfs on our device Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 31/32] usb: chipidea: let udc-core manage gadget->dev Felipe Balbi
2013-01-24 15:46 ` [RFC/PATCH 32/32] usb: gadget: drop now unnecessary flag Felipe Balbi
2013-01-24 18:52 ` Tomasz Figa
2013-01-24 19:09 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1359042370-4358-2-git-send-email-balbi@ti.com \
--to=balbi@ti.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ben-linux@fluff.org \
--cc=dahlmann.thomas@arcor.de \
--cc=eric.y.miao@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=haojian.zhuang@gmail.com \
--cc=kgene.kim@samsung.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-geode@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nicolas.ferre@atmel.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).