Message ID | 20160510114415.2476-6-mugunthanvnm@ti.com |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show |
On 05/10/2016 01:44 PM, Mugunthan V N wrote: > prepare driver for driver model migration > > Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> > --- > drivers/usb/gadget/ether.c | 72 ++++++++++++++++++++++++++++++++-------------- > 1 file changed, 51 insertions(+), 21 deletions(-) > > diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c > index 47071c3..2f70ebf 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,53 @@ 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) { if (!packet_received) return 0; ... the rest ... > + 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; >
On Tuesday 10 May 2016 05:54 PM, Marek Vasut wrote: > On 05/10/2016 01:44 PM, Mugunthan V N wrote: >> prepare driver for driver model migration >> >> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> >> --- >> drivers/usb/gadget/ether.c | 72 ++++++++++++++++++++++++++++++++-------------- >> 1 file changed, 51 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c >> index 47071c3..2f70ebf 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,53 @@ 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) { > > if (!packet_received) > return 0; > ... the rest ... Will fix in next version. Regards Mugunthan V N
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 47071c3..2f70ebf 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,53 @@ 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) { + 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;
prepare driver for driver model migration Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> --- drivers/usb/gadget/ether.c | 72 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 21 deletions(-)