net: Get rid of the network driver dev_data field.

The information being put in it can be retrieved in other, less type unsafe
ways.

Change-Id: Ia4d6089e1a80534d3a56f3a7424da18797192b1f
diff --git a/src/drivers/net/asix.c b/src/drivers/net/asix.c
index a404bb0..5d54cfa 100644
--- a/src/drivers/net/asix.c
+++ b/src/drivers/net/asix.c
@@ -324,8 +324,8 @@
 
 static int asix_send(NetDevice *net_dev, void *buf, uint16_t len)
 {
-	GenericUsbDevice *gen_dev = (GenericUsbDevice *)net_dev->dev_data;
-	UsbDev *usb_dev = gen_dev->dev;
+	UsbEthDevice *eth = container_of(net_dev, UsbEthDevice, net_dev);
+	UsbDev *usb_dev = eth->gen_dev->dev;
 
 	uint32_t packet_len;
 	static uint8_t msg[CONFIG_UIP_BUFSIZE + sizeof(packet_len)];
@@ -353,8 +353,8 @@
 
 static int asix_recv(NetDevice *net_dev, void *buf, uint16_t *len, int maxlen)
 {
-	GenericUsbDevice *gen_dev = (GenericUsbDevice *)net_dev->dev_data;
-	UsbDev *usb_dev = gen_dev->dev;
+	UsbEthDevice *eth = container_of(net_dev, UsbEthDevice, net_dev);
+	UsbDev *usb_dev = eth->gen_dev->dev;
 
 	uint32_t packet_len;
 	static int32_t buf_size = 0;
@@ -401,8 +401,8 @@
 
 static const uip_eth_addr *asix_get_mac(NetDevice *net_dev)
 {
-	GenericUsbDevice *gen_dev = (GenericUsbDevice *)net_dev->dev_data;
-	UsbDev *usb_dev = gen_dev->dev;
+	AsixDev *asix = container_of(net_dev, AsixDev, usb_eth_dev.net_dev);
+	UsbDev *usb_dev = asix->usb_eth_dev.gen_dev->dev;
 
 	if (usb_eth_read_reg(usb_dev, NodeIdRead, 0, 0, sizeof(uip_eth_addr),
 			&asix_dev.mac_addr)) {
diff --git a/src/drivers/net/net.h b/src/drivers/net/net.h
index 19c67eb..013de9a 100644
--- a/src/drivers/net/net.h
+++ b/src/drivers/net/net.h
@@ -35,7 +35,6 @@
 		int maxlen);
 	int (*send)(struct NetDevice *dev, void *buf, uint16_t len);
 	const uip_eth_addr *(*get_mac)(struct NetDevice *dev);
-	void *dev_data;
 } NetDevice;
 
 typedef struct NetPoller {
diff --git a/src/drivers/net/smsc95xx.c b/src/drivers/net/smsc95xx.c
index e01a961..021ac72 100644
--- a/src/drivers/net/smsc95xx.c
+++ b/src/drivers/net/smsc95xx.c
@@ -407,8 +407,8 @@
 
 static int smsc95xx_send(NetDevice *net_dev, void *buf, uint16_t len)
 {
-	GenericUsbDevice *gen_dev = (GenericUsbDevice *)net_dev->dev_data;
-	UsbDev *usb_dev = gen_dev->dev;
+	UsbEthDevice *eth = container_of(net_dev, UsbEthDevice, net_dev);
+	UsbDev *usb_dev = eth->gen_dev->dev;
 
 	uint32_t tx_cmd_a;
 	uint32_t tx_cmd_b;
@@ -440,8 +440,8 @@
 static int smsc95xx_recv(NetDevice *net_dev, void *buf, uint16_t *len,
 			 int maxlen)
 {
-	GenericUsbDevice *gen_dev = (GenericUsbDevice *)net_dev->dev_data;
-	UsbDev *usb_dev = gen_dev->dev;
+	UsbEthDevice *eth = container_of(net_dev, UsbEthDevice, net_dev);
+	UsbDev *usb_dev = eth->gen_dev->dev;
 
 	uint32_t rx_status;
 	uint32_t packet_len;
@@ -490,8 +490,9 @@
 
 static const uip_eth_addr *smsc95xx_get_mac(NetDevice *net_dev)
 {
-	GenericUsbDevice *gen_dev = (GenericUsbDevice *)net_dev->dev_data;
-	UsbDev *usb_dev = gen_dev->dev;
+	UsbEthDevice *eth = container_of(net_dev, UsbEthDevice, net_dev);
+	UsbDev *usb_dev = eth->gen_dev->dev;
+
 	uint32_t addrh;
 	uint32_t addrl;
 
diff --git a/src/drivers/net/usb_eth.c b/src/drivers/net/usb_eth.c
index 4385eae..bf4588a 100644
--- a/src/drivers/net/usb_eth.c
+++ b/src/drivers/net/usb_eth.c
@@ -96,7 +96,6 @@
 			   dd->idProduct == eth_dev->supported_ids[i].product) {
 
 				usb_eth_net_device = &eth_dev->net_dev;
-				usb_eth_net_device->dev_data = dev;
 
 				eth_dev->gen_dev = dev;