9
0
Fork 0

net: use container_of instead of dev->type_data

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-02-25 14:37:12 +01:00
parent 2c54046510
commit 67d938b2ea
3 changed files with 5 additions and 4 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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);