From patchwork Thu Nov 17 08:09:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mugunthan V N X-Patchwork-Id: 696018 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3tKDLw4vG8z9s9Y for ; Thu, 17 Nov 2016 19:10:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F216B382D; Thu, 17 Nov 2016 09:09:59 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UKqymsKQCujJ; Thu, 17 Nov 2016 09:09:58 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 930FA4B9F9; Thu, 17 Nov 2016 09:09:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B8C6E4BD3D for ; Thu, 17 Nov 2016 09:09:54 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1lV-SaYoPPqK for ; Thu, 17 Nov 2016 09:09:54 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by theia.denx.de (Postfix) with ESMTPS id 248794B9F9 for ; Thu, 17 Nov 2016 09:09:51 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id uAH89jPl005105; Thu, 17 Nov 2016 02:09:45 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id uAH89j8x013444; Thu, 17 Nov 2016 02:09:45 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Thu, 17 Nov 2016 02:09:44 -0600 Received: from a0131834lt.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id uAH89CTW014525; Thu, 17 Nov 2016 02:09:40 -0600 From: Mugunthan V N To: Date: Thu, 17 Nov 2016 13:39:08 +0530 Message-ID: <20161117080909.14856-6-mugunthanvnm@ti.com> X-Mailer: git-send-email 2.11.0.rc1 In-Reply-To: <20161117080909.14856-1-mugunthanvnm@ti.com> References: <20161117080909.14856-1-mugunthanvnm@ti.com> MIME-Version: 1.0 Cc: Marek Vasut , Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v3 5/6] drivers: usb: gadget: ether: prepare driver for driver model migration X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" prepare driver for driver model migration Signed-off-by: Mugunthan V N --- drivers/usb/gadget/ether.c | 73 +++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 54b8b59b29..046ad8ca2b 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -2334,9 +2334,8 @@ int dm_usb_init(struct eth_dev *e_dev) } #endif -static int usb_eth_init(struct eth_device *netdev, bd_t *bd) +static int _usb_eth_init(struct ether_priv *priv) { - struct ether_priv *priv = (struct ether_priv *)netdev->priv; struct eth_dev *dev = &priv->ethdev; struct usb_gadget *gadget; unsigned long ts; @@ -2415,11 +2414,10 @@ fail: return -1; } -static int usb_eth_send(struct eth_device *netdev, void *packet, int length) +static int _usb_eth_send(struct ether_priv *priv, void *packet, int length) { int retval; void *rndis_pkt = NULL; - struct ether_priv *priv = (struct ether_priv *)netdev->priv; struct eth_dev *dev = &priv->ethdev; struct usb_request *req = dev->tx_req; unsigned long ts; @@ -2485,30 +2483,15 @@ drop: return -ENOMEM; } -static int usb_eth_recv(struct eth_device *netdev) +static int _usb_eth_recv(struct ether_priv *priv) { - struct ether_priv *priv = (struct ether_priv *)netdev->priv; - struct eth_dev *dev = &priv->ethdev; - usb_gadget_handle_interrupts(0); - if (packet_received) { - debug("%s: packet received\n", __func__); - if (dev->rx_req) { - net_process_received_packet(net_rx_packets[0], - dev->rx_req->length); - packet_received = 0; - - rx_submit(dev, dev->rx_req, 0); - } else - error("dev->rx_req invalid"); - } return 0; } -void usb_eth_halt(struct eth_device *netdev) +void _usb_eth_halt(struct ether_priv *priv) { - struct ether_priv *priv = (struct ether_priv *)netdev->priv; struct eth_dev *dev = &priv->ethdev; /* If the gadget not registered, simple return */ @@ -2544,6 +2527,54 @@ void usb_eth_halt(struct eth_device *netdev) #endif } +static int usb_eth_init(struct eth_device *netdev, bd_t *bd) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + + return _usb_eth_init(priv); +} + +static int usb_eth_send(struct eth_device *netdev, void *packet, int length) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + + return _usb_eth_send(priv, packet, length); +} + +static int usb_eth_recv(struct eth_device *netdev) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + struct eth_dev *dev = &priv->ethdev; + int ret; + + ret = _usb_eth_recv(priv); + if (ret) { + error("error packet receive\n"); + return ret; + } + + if (!packet_received) + return 0; + + if (dev->rx_req) { + net_process_received_packet(net_rx_packets[0], + dev->rx_req->length); + } else { + error("dev->rx_req invalid"); + } + packet_received = 0; + rx_submit(dev, dev->rx_req, 0); + + return 0; +} + +void usb_eth_halt(struct eth_device *netdev) +{ + struct ether_priv *priv = (struct ether_priv *)netdev->priv; + + _usb_eth_halt(priv); +} + int usb_eth_initialize(bd_t *bi) { struct eth_device *netdev = &l_priv->netdev;