From: Peter Chen <peter.chen@freescale.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Ruslan Bilovol" <ruslan.bilovol@gmail.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH v6 2/4] usb: gadget: configfs: pass UDC name via usb_gadget_driver struct
Date: Fri, 20 Nov 2015 17:22:06 +0800 [thread overview]
Message-ID: <20151120092205.GE30829@shlinux2> (raw)
In-Reply-To: <1448009652-14716-3-git-send-email-m.szyprowski@samsung.com>
On Fri, Nov 20, 2015 at 09:54:10AM +0100, Marek Szyprowski wrote:
> From: Ruslan Bilovol <ruslan.bilovol@gmail.com>
>
> Now when udc-core supports binding to specific UDC by passing
> its name via 'udc_name' member of usb_gadget_driver struct,
> switch to this generic approach.
>
> Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> drivers/usb/gadget/configfs.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
> index 163d305..0bc6865 100644
> --- a/drivers/usb/gadget/configfs.c
> +++ b/drivers/usb/gadget/configfs.c
> @@ -56,7 +56,6 @@ struct gadget_info {
> struct list_head string_list;
> struct list_head available_func;
>
> - const char *udc_name;
> struct usb_composite_driver composite;
> struct usb_composite_dev cdev;
> bool use_os_desc;
> @@ -233,21 +232,21 @@ static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item,
>
> static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page)
> {
> - return sprintf(page, "%s\n", to_gadget_info(item)->udc_name ?: "");
> + return sprintf(page, "%s\n", to_gadget_info(item)->composite.gadget_driver.udc_name ?: "");
> }
>
> static int unregister_gadget(struct gadget_info *gi)
> {
> int ret;
>
> - if (!gi->udc_name)
> + if (!gi->composite.gadget_driver.udc_name)
> return -ENODEV;
>
> ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver);
> if (ret)
> return ret;
> - kfree(gi->udc_name);
> - gi->udc_name = NULL;
> + kfree(gi->composite.gadget_driver.udc_name);
> + gi->composite.gadget_driver.udc_name = NULL;
> return 0;
> }
>
> @@ -271,14 +270,16 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
> if (ret)
> goto err;
> } else {
> - if (gi->udc_name) {
> + if (gi->composite.gadget_driver.udc_name) {
> ret = -EBUSY;
> goto err;
> }
> - ret = usb_udc_attach_driver(name, &gi->composite.gadget_driver);
> - if (ret)
> + gi->composite.gadget_driver.udc_name = name;
> + ret = usb_gadget_probe_driver(&gi->composite.gadget_driver);
> + if (ret) {
> + gi->composite.gadget_driver.udc_name = NULL;
> goto err;
> - gi->udc_name = name;
> + }
> }
> mutex_unlock(&gi->lock);
> return len;
> @@ -427,9 +428,9 @@ static int config_usb_cfg_unlink(
> * remove the function.
> */
> mutex_lock(&gi->lock);
> - if (gi->udc_name)
> + if (gi->composite.gadget_driver.udc_name)
> unregister_gadget(gi);
> - WARN_ON(gi->udc_name);
> + WARN_ON(gi->composite.gadget_driver.udc_name);
>
> list_for_each_entry(f, &cfg->func_list, list) {
> if (f->fi == fi) {
> @@ -873,10 +874,10 @@ static int os_desc_unlink(struct config_item *os_desc_ci,
> struct usb_composite_dev *cdev = &gi->cdev;
>
> mutex_lock(&gi->lock);
> - if (gi->udc_name)
> + if (gi->composite.gadget_driver.udc_name)
> unregister_gadget(gi);
> cdev->os_desc_config = NULL;
> - WARN_ON(gi->udc_name);
> + WARN_ON(gi->composite.gadget_driver.udc_name);
> mutex_unlock(&gi->lock);
> return 0;
> }
> --
Applying: usb: gadget: configfs: pass UDC name via usb_gadget_driver
struct
WARNING: line over 80 characters
#18: FILE: drivers/usb/gadget/configfs.c:235:
+ return sprintf(page, "%s\n",
to_gadget_info(item)->composite.gadget_driver.udc_name ?: "");
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2015-11-20 9:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-20 8:54 [PATCH v6 0/4] usb/gadget: independent registration of gadgets and gadget drivers Marek Szyprowski
2015-11-20 8:54 ` [PATCH v6 1/4] usb: gadget: bind UDC by name passed via usb_gadget_driver structure Marek Szyprowski
2015-11-20 9:21 ` Peter Chen
2015-11-20 8:54 ` [PATCH v6 2/4] usb: gadget: configfs: pass UDC name via usb_gadget_driver struct Marek Szyprowski
2015-11-20 9:22 ` Peter Chen [this message]
2015-11-20 8:54 ` [PATCH v6 3/4] usb: gadget: udc-core: remove unused usb_udc_attach_driver() Marek Szyprowski
2015-11-20 8:54 ` [PATCH v6 4/4] usb: gadget: udc-core: independent registration of gadgets and gadget drivers Marek Szyprowski
2015-11-20 9:26 ` Peter Chen
2015-11-20 9:45 ` Marek Szyprowski
2015-11-20 9:51 ` Peter Chen
2015-11-20 16:27 ` Alan Stern
2015-11-23 7:40 ` Peter Chen
2015-11-23 7:44 ` Peter Chen
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=20151120092205.GE30829@shlinux2 \
--to=peter.chen@freescale.com \
--cc=b.zolnierkie@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=ruslan.bilovol@gmail.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