All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Jacques Hiblot <jjhiblot@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 1/7] usb: gadget: Do not call board_usb_xxx() directly in USB gadget drivers
Date: Tue, 29 May 2018 09:41:04 +0200	[thread overview]
Message-ID: <9213a49d-010a-b4a2-fcf3-38a983596007@ti.com> (raw)
In-Reply-To: <f2f26404-0ebe-45bd-0149-d0eb98dc9936@xilinx.com>



On 28/05/2018 10:35, Michal Simek wrote:
> On 25.5.2018 11:32, Jean-Jacques Hiblot wrote:
>> Add 2 functions to wrap the calls to board_usb_init() and
>> board_usb_cleanup().
> Here should be written why you need this change.
>
> M
I'll update the commit log.
It's a preparatory work for DM support for UDC drivers.
>
>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>> ---
>>
>>   cmd/fastboot.c             |  4 ++--
>>   cmd/rockusb.c              |  4 ++--
>>   cmd/thordown.c             |  4 ++--
>>   cmd/usb_gadget_sdp.c       |  4 ++--
>>   cmd/usb_mass_storage.c     |  4 ++--
>>   common/dfu.c               |  6 +++---
>>   drivers/usb/gadget/ether.c | 38 +++++---------------------------------
>>   include/linux/usb/gadget.h | 10 ++++++++++
>>   8 files changed, 28 insertions(+), 46 deletions(-)
>>
>> diff --git a/cmd/fastboot.c b/cmd/fastboot.c
>> index a5ec5f4..93f97fd 100644
>> --- a/cmd/fastboot.c
>> +++ b/cmd/fastboot.c
>> @@ -24,7 +24,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>>   	usb_controller = argv[1];
>>   	controller_index = simple_strtoul(usb_controller, NULL, 0);
>>   
>> -	ret = board_usb_init(controller_index, USB_INIT_DEVICE);
>> +	ret = usb_gadget_initialize(controller_index);
>>   	if (ret) {
>>   		pr_err("USB init failed: %d", ret);
>>   		return CMD_RET_FAILURE;
>> @@ -55,7 +55,7 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>>   exit:
>>   	g_dnl_unregister();
>>   	g_dnl_clear_detach();
>> -	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
>> +	usb_gadget_release(controller_index);
>>   
>>   	return ret;
>>   }
>> diff --git a/cmd/rockusb.c b/cmd/rockusb.c
>> index 8206643..e0c1480 100644
>> --- a/cmd/rockusb.c
>> +++ b/cmd/rockusb.c
>> @@ -33,7 +33,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>>   	dev_index = simple_strtoul(devnum, NULL, 0);
>>   	rockusb_dev_init(devtype, dev_index);
>>   
>> -	ret = board_usb_init(controller_index, USB_INIT_DEVICE);
>> +	ret = usb_gadget_initialize(controller_index);
>>   	if (ret) {
>>   		printf("USB init failed: %d\n", ret);
>>   		return CMD_RET_FAILURE;
>> @@ -62,7 +62,7 @@ static int do_rockusb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
>>   exit:
>>   	g_dnl_unregister();
>>   	g_dnl_clear_detach();
>> -	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
>> +	usb_gadget_release(controller_index);
>>   
>>   	return ret;
>>   }
>> diff --git a/cmd/thordown.c b/cmd/thordown.c
>> index e297de2..b7866d1 100644
>> --- a/cmd/thordown.c
>> +++ b/cmd/thordown.c
>> @@ -30,7 +30,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>   		goto done;
>>   
>>   	int controller_index = simple_strtoul(usb_controller, NULL, 0);
>> -	ret = board_usb_init(controller_index, USB_INIT_DEVICE);
>> +	ret = usb_gadget_initialize(controller_index);
>>   	if (ret) {
>>   		pr_err("USB init failed: %d", ret);
>>   		ret = CMD_RET_FAILURE;
>> @@ -55,7 +55,7 @@ int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>   
>>   exit:
>>   	g_dnl_unregister();
>> -	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
>> +	usb_gadget_realease(controller_index);
>>   done:
>>   	dfu_free_entities();
>>   
>> diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
>> index ba1f66a..808ed97 100644
>> --- a/cmd/usb_gadget_sdp.c
>> +++ b/cmd/usb_gadget_sdp.c
>> @@ -20,7 +20,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>   
>>   	char *usb_controller = argv[1];
>>   	int controller_index = simple_strtoul(usb_controller, NULL, 0);
>> -	board_usb_init(controller_index, USB_INIT_DEVICE);
>> +	usb_gadget_initialize(controller_index);
>>   
>>   	g_dnl_clear_detach();
>>   	g_dnl_register("usb_dnl_sdp");
>> @@ -37,7 +37,7 @@ static int do_sdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>>   
>>   exit:
>>   	g_dnl_unregister();
>> -	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
>> +	usb_gadget_release(controller_index);
>>   
>>   	return ret;
>>   }
>> diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
>> index 89b9ddf..7c6d0c6 100644
>> --- a/cmd/usb_mass_storage.c
>> +++ b/cmd/usb_mass_storage.c
>> @@ -160,7 +160,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
>>   
>>   	controller_index = (unsigned int)(simple_strtoul(
>>   				usb_controller,	NULL, 0));
>> -	if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
>> +	if (usb_gadget_initialize(controller_index)) {
>>   		pr_err("Couldn't init USB controller.");
>>   		rc = CMD_RET_FAILURE;
>>   		goto cleanup_ums_init;
>> @@ -231,7 +231,7 @@ static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
>>   cleanup_register:
>>   	g_dnl_unregister();
>>   cleanup_board:
>> -	board_usb_cleanup(controller_index, USB_INIT_DEVICE);
>> +	usb_gadget_release(controller_index);
>>   cleanup_ums_init:
>>   	ums_fini();
>>   
>> diff --git a/common/dfu.c b/common/dfu.c
>> index 2620d32..44d1484 100644
>> --- a/common/dfu.c
>> +++ b/common/dfu.c
>> @@ -23,9 +23,9 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>>   	bool dfu_reset = false;
>>   	int ret, i = 0;
>>   
>> -	ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE);
>> +	ret = usb_gadget_initialize(usbctrl_index);
>>   	if (ret) {
>> -		pr_err("board usb init failed\n");
>> +		pr_err("usb_gadget_initialize failed\n");
>>   		return CMD_RET_FAILURE;
>>   	}
>>   	g_dnl_clear_detach();
>> @@ -84,7 +84,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>>   	}
>>   exit:
>>   	g_dnl_unregister();
>> -	board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE);
>> +	usb_gadget_release(usbctrl_index);
>>   
>>   	if (dfu_reset)
>>   		do_reset(NULL, 0, 0, NULL);
>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>> index 8ab9b9f..1c438c3 100644
>> --- a/drivers/usb/gadget/ether.c
>> +++ b/drivers/usb/gadget/ether.c
>> @@ -105,9 +105,6 @@ struct eth_dev {
>>   	struct usb_gadget	*gadget;
>>   	struct usb_request	*req;		/* for control responses */
>>   	struct usb_request	*stat_req;	/* for cdc & rndis status */
>> -#ifdef CONFIG_DM_USB
>> -	struct udevice		*usb_udev;
>> -#endif
>>   
>>   	u8			config;
>>   	struct usb_ep		*in_ep, *out_ep, *status_ep;
>> @@ -2341,40 +2338,17 @@ fail:
>>   }
>>   
>>   /*-------------------------------------------------------------------------*/
>> -
>> -#ifdef CONFIG_DM_USB
>> -int dm_usb_init(struct eth_dev *e_dev)
>> -{
>> -	struct udevice *dev = NULL;
>> -	int ret;
>> -
>> -	ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
>> -	if (!dev || ret) {
>> -		pr_err("No USB device found\n");
>> -		return -ENODEV;
>> -	}
>> -
>> -	e_dev->usb_udev = dev;
>> -
>> -	return ret;
>> -}
>> -#endif
>> -
>>   static int _usb_eth_init(struct ether_priv *priv)
>>   {
>>   	struct eth_dev *dev = &priv->ethdev;
>>   	struct usb_gadget *gadget;
>>   	unsigned long ts;
>> +	int ret;
>>   	unsigned long timeout = USB_CONNECT_TIMEOUT;
>>   
>> -#ifdef CONFIG_DM_USB
>> -	if (dm_usb_init(dev)) {
>> -		pr_err("USB ether not found\n");
>> -		return -ENODEV;
>> -	}
>> -#else
>> -	board_usb_init(0, USB_INIT_DEVICE);
>> -#endif
>> +	ret = usb_gadget_initialize(0);
>> +	if (ret)
>> +		return ret;
>>   
>>   	/* Configure default mac-addresses for the USB ethernet device */
>>   #ifdef CONFIG_USBNET_DEV_ADDR
>> @@ -2546,9 +2520,7 @@ void _usb_eth_halt(struct ether_priv *priv)
>>   	}
>>   
>>   	usb_gadget_unregister_driver(&priv->eth_driver);
>> -#ifndef CONFIG_DM_USB
>> -	board_usb_cleanup(0, USB_INIT_DEVICE);
>> -#endif
>> +	usb_gadget_release(0);
>>   }
>>   
>>   #ifndef CONFIG_DM_ETH
>> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
>> index b824f13..40ca2d3 100644
>> --- a/include/linux/usb/gadget.h
>> +++ b/include/linux/usb/gadget.h
>> @@ -19,6 +19,7 @@
>>   #define __LINUX_USB_GADGET_H
>>   
>>   #include <errno.h>
>> +#include <usb.h>
>>   #include <linux/compat.h>
>>   #include <linux/list.h>
>>   
>> @@ -926,4 +927,13 @@ extern void usb_ep_autoconfig_reset(struct usb_gadget *);
>>   
>>   extern int usb_gadget_handle_interrupts(int index);
>>   
>> +static inline int usb_gadget_initialize(int index)
>> +{
>> +	return board_usb_init(index, USB_INIT_DEVICE);
>> +}
>> +
>> +static inline int usb_gadget_release(int index)
>> +{
>> +	return board_usb_cleanup(index, USB_INIT_DEVICE);
>> +}
>>   #endif	/* __LINUX_USB_GADGET_H */
>>
>

  reply	other threads:[~2018-05-29  7:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-25  9:32 [U-Boot] [PATCH v1 0/7] Improvements for the dwc3_generic driver Jean-Jacques Hiblot
2018-05-25  9:32 ` [U-Boot] [PATCH v1 1/7] usb: gadget: Do not call board_usb_xxx() directly in USB gadget drivers Jean-Jacques Hiblot
2018-05-28  8:35   ` Michal Simek
2018-05-29  7:41     ` Jean-Jacques Hiblot [this message]
2018-05-25  9:32 ` [U-Boot] [PATCH v1 2/7] usb: introduce a separate config option for DM USB device Jean-Jacques Hiblot
2018-05-28  8:37   ` Michal Simek
2018-05-29  7:40     ` Jean-Jacques Hiblot
2018-05-25  9:32 ` [U-Boot] [PATCH v1 3/7] usb: udc: implement DM versions of usb_gadget_initialize()/_release()/_handle_interrupt() Jean-Jacques Hiblot
2018-05-28  7:29   ` Lukasz Majewski
2018-05-25  9:32 ` [U-Boot] [PATCH v1 4/7] dwc3_generic: do not probe the USB device driver when it's bound Jean-Jacques Hiblot
2018-05-25  9:32 ` [U-Boot] [PATCH v1 5/7] dwc3: move phy operation to core.c Jean-Jacques Hiblot
2018-05-25  9:32 ` [U-Boot] [PATCH v1 6/7] dwc3-generic: Handle the PHYs, the clocks and the reset lines Jean-Jacques Hiblot
2018-05-25  9:32 ` [U-Boot] [PATCH v1 7/7] dwc3-generic: Add select_dr_mode operation Jean-Jacques Hiblot
2018-05-28  8:32 ` [U-Boot] [PATCH v1 0/7] Improvements for the dwc3_generic driver Michal Simek
2018-05-28  9:47   ` Jean-Jacques Hiblot
2018-05-28 10:25     ` Michal Simek
2018-05-29 11:03       ` Jean-Jacques Hiblot
2018-05-29 11:08         ` Michal Simek

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=9213a49d-010a-b4a2-fcf3-38a983596007@ti.com \
    --to=jjhiblot@ti.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.