All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/17] drivers: usb: gadget: ether: consolidate global devices to single struct
Date: Mon, 29 Feb 2016 09:14:13 +0530	[thread overview]
Message-ID: <1456717460-3132-11-git-send-email-mugunthanvnm@ti.com> (raw)
In-Reply-To: <1456717460-3132-1-git-send-email-mugunthanvnm@ti.com>

Consolidate the net device, usb eth device and gadget device
struct to single struct and a single global variable so that the
same can be passed as priv of ethernet driver.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 drivers/usb/gadget/ether.c | 53 +++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 89e5ab8..b40d99a 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -141,9 +141,14 @@ struct eth_dev {
  */
 
 /*-------------------------------------------------------------------------*/
-static struct eth_dev l_ethdev;
-static struct eth_device l_netdev;
-static struct usb_gadget_driver eth_driver;
+struct ether_priv {
+	struct eth_dev ethdev;
+	struct eth_device netdev;
+	struct usb_gadget_driver eth_driver;
+};
+
+struct ether_priv eth_priv;
+struct ether_priv *l_priv = &eth_priv;
 
 /*-------------------------------------------------------------------------*/
 
@@ -1848,7 +1853,7 @@ static char rndis_resp_buf[8] __attribute__((aligned(sizeof(__le32))));
 
 static int rndis_control_ack(struct eth_device *net)
 {
-	struct eth_dev		*dev = &l_ethdev;
+	struct eth_dev		*dev = &l_priv->ethdev;
 	int                     length;
 	struct usb_request      *resp = dev->stat_req;
 
@@ -1989,7 +1994,7 @@ static int get_ether_addr(const char *str, u8 *dev_addr)
 
 static int eth_bind(struct usb_gadget *gadget)
 {
-	struct eth_dev		*dev = &l_ethdev;
+	struct eth_dev		*dev = &l_priv->ethdev;
 	u8			cdc = 1, zlp = 1, rndis = 1;
 	struct usb_ep		*in_ep, *out_ep, *status_ep = NULL;
 	int			status = -ENOMEM;
@@ -2182,7 +2187,7 @@ autoconf_fail:
 
 
 	/* network device setup */
-	dev->net = &l_netdev;
+	dev->net = &l_priv->netdev;
 
 	dev->cdc = cdc;
 	dev->zlp = zlp;
@@ -2330,7 +2335,7 @@ int dm_usb_init(struct eth_dev *e_dev)
 
 static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
 {
-	struct eth_dev *dev = &l_ethdev;
+	struct eth_dev *dev = &l_priv->ethdev;
 	struct usb_gadget *gadget;
 	unsigned long ts;
 	unsigned long timeout = USB_CONNECT_TIMEOUT;
@@ -2374,7 +2379,15 @@ static int usb_eth_init(struct eth_device *netdev, bd_t *bd)
 		goto fail;
 	}
 
-	if (usb_gadget_register_driver(&eth_driver) < 0)
+	l_priv->eth_driver.speed	= DEVSPEED;
+	l_priv->eth_driver.bind		= eth_bind;
+	l_priv->eth_driver.unbind	= eth_unbind;
+	l_priv->eth_driver.setup	= eth_setup;
+	l_priv->eth_driver.reset	= eth_disconnect;
+	l_priv->eth_driver.disconnect	= eth_disconnect;
+	l_priv->eth_driver.suspend	= eth_suspend;
+	l_priv->eth_driver.resume	= eth_resume;
+	if (usb_gadget_register_driver(&l_priv->eth_driver) < 0)
 		goto fail;
 
 	dev->network_started = 0;
@@ -2409,7 +2422,7 @@ static int usb_eth_send(struct eth_device *netdev, void *packet, int length)
 {
 	int			retval;
 	void			*rndis_pkt = NULL;
-	struct eth_dev		*dev = &l_ethdev;
+	struct eth_dev		*dev = &l_priv->ethdev;
 	struct usb_request	*req = dev->tx_req;
 	unsigned long ts;
 	unsigned long timeout = USB_CONNECT_TIMEOUT;
@@ -2476,7 +2489,7 @@ drop:
 
 static int usb_eth_recv(struct eth_device *netdev)
 {
-	struct eth_dev *dev = &l_ethdev;
+	struct eth_dev *dev = &l_priv->ethdev;
 
 	usb_gadget_handle_interrupts(0);
 
@@ -2496,7 +2509,7 @@ static int usb_eth_recv(struct eth_device *netdev)
 
 void usb_eth_halt(struct eth_device *netdev)
 {
-	struct eth_dev *dev = &l_ethdev;
+	struct eth_dev *dev = &l_priv->ethdev;
 
 	if (!netdev) {
 		error("received NULL ptr");
@@ -2528,7 +2541,7 @@ void usb_eth_halt(struct eth_device *netdev)
 		dev->network_started = 0;
 	}
 
-	usb_gadget_unregister_driver(&eth_driver);
+	usb_gadget_unregister_driver(&l_priv->eth_driver);
 #ifdef CONFIG_DM_USB
 	device_remove(dev->usb_udev);
 #else
@@ -2536,23 +2549,9 @@ void usb_eth_halt(struct eth_device *netdev)
 #endif
 }
 
-static struct usb_gadget_driver eth_driver = {
-	.speed		= DEVSPEED,
-
-	.bind		= eth_bind,
-	.unbind		= eth_unbind,
-
-	.setup		= eth_setup,
-	.reset		= eth_disconnect,
-	.disconnect	= eth_disconnect,
-
-	.suspend	= eth_suspend,
-	.resume		= eth_resume,
-};
-
 int usb_eth_initialize(bd_t *bi)
 {
-	struct eth_device *netdev = &l_netdev;
+	struct eth_device *netdev = &l_priv->netdev;
 
 	strlcpy(netdev->name, USB_NET_NAME, sizeof(netdev->name));
 
-- 
2.7.2.333.g70bd996

  parent reply	other threads:[~2016-02-29  3:44 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29  3:44 [U-Boot] [PATCH 00/17] driver model bring-up of musb on AM335x GP and BBB and usb_ether DM conversion Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 01/17] configs: am335x: usb: do not define CONFIG_DM_USB for spl Mugunthan V N
2016-03-01  1:57   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 02/17] am33xx: board: do not register usb devices when CONFIG_DM_USB is defined Mugunthan V N
2016-03-01  1:57   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 03/17] drivers: usb: musb: add ti musb misc driver for wrapper Mugunthan V N
2016-02-29  8:46   ` Mugunthan V N
2016-02-29 12:02   ` Marek Vasut
2016-02-29 13:21     ` Mugunthan V N
2016-02-29 14:42       ` Tom Rini
2016-02-29 14:42         ` Marek Vasut
2016-02-29  3:44 ` [U-Boot] [PATCH 04/17] am33xx: board: probe misc drivers to register musb devices Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 05/17] drivers: usb: musb: adopt musb backend driver to driver model Mugunthan V N
2016-02-29 12:04   ` Marek Vasut
2016-02-29 13:26     ` Mugunthan V N
2016-02-29 13:34       ` Marek Vasut
2016-02-29 14:43         ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 06/17] drivers: usb: musb: add ti musb host driver with driver model support Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 07/17] drivers: usb: musb: add ti musb peripheral " Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 08/17] drivers: usb: gadget: ether: adopt to usb driver model Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 09/17] drivers: usb: gadget: ether: access network_started using local variable Mugunthan V N
2016-02-29  3:44 ` Mugunthan V N [this message]
2016-02-29  3:44 ` [U-Boot] [PATCH 11/17] drivers: usb: gadget: ether: use net device priv to pass usb ether priv Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 12/17] drivers: usb: gadget: ether: prepare driver for driver model migration Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 13/17] drivers: usb: gadget: ether/rndis: convert driver to adopt device driver model Mugunthan V N
2016-02-29  3:44 ` [U-Boot] [PATCH 14/17] am33xx: board: init usb ether gadget for rndis support Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 15/17] am335x_evm: enable usb ether gadget as it supports DM_ETH Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 16/17] defconfig: am335x_boneblack: enable usb driver model Mugunthan V N
2016-03-01  1:58   ` Tom Rini
2016-02-29  3:44 ` [U-Boot] [PATCH 17/17] defconfig: am335x_gp_evm: " Mugunthan V N
2016-03-01  1:58   ` Tom Rini

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=1456717460-3132-11-git-send-email-mugunthanvnm@ti.com \
    --to=mugunthanvnm@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.