[PATCH 09/13] net: use container_of instead of dev->type_data
Sascha Hauer
s.hauer at pengutronix.de
Sat Feb 25 10:51:06 EST 2012
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/net/cs8900.c | 2 +-
include/net.h | 2 ++
net/eth.c | 5 ++---
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index da23755..291fd0a 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -360,7 +360,7 @@ static const char *yesno_str(int v)
static void cs8900_info(struct device_d *dev)
{
- struct eth_device *edev = (struct eth_device *)dev->type_data;
+ struct eth_device *edev = dev_to_edev(dev);
struct cs8900_priv *priv = (struct cs8900_priv *)edev->priv;
u16 v;
diff --git a/include/net.h b/include/net.h
index 1026793..2eec47f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -48,6 +48,8 @@ struct eth_device {
struct list_head list;
};
+#define dev_to_edev(d) container_of(d, struct eth_device, dev)
+
int eth_register(struct eth_device* dev); /* Register network device */
void eth_unregister(struct eth_device* dev); /* Unregister network device */
diff --git a/net/eth.c b/net/eth.c
index 20fdbf4..00b8836 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -147,7 +147,7 @@ int eth_rx(void)
static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const char *val)
{
- struct eth_device *edev = dev->type_data;
+ struct eth_device *edev = dev_to_edev(dev);
char ethaddr[sizeof("xx:xx:xx:xx:xx:xx")];
if (!val)
@@ -168,7 +168,7 @@ static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const ch
static int eth_set_ipaddr(struct device_d *dev, struct param_d *param, const char *val)
{
- struct eth_device *edev = dev->type_data;
+ struct eth_device *edev = dev_to_edev(dev);
IPaddr_t ip;
if (!val)
@@ -205,7 +205,6 @@ int eth_register(struct eth_device *edev)
register_device(&edev->dev);
- dev->type_data = edev;
dev_add_param(dev, "ipaddr", eth_set_ipaddr, NULL, 0);
dev_add_param(dev, "ethaddr", eth_set_ethaddr, NULL, 0);
dev_add_param(dev, "gateway", eth_set_ipaddr, NULL, 0);
--
1.7.9.1
More information about the barebox
mailing list