1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-09-17 21:14:39 +03:00

ramips: add error-path handling to the ramips_eth_plat_probe

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@18165 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2009-10-26 17:17:13 +00:00
parent c3dbd7adde
commit 90e4aa2386

View File

@ -338,12 +338,24 @@ ramips_eth_plat_probe(struct platform_device *plat)
{ {
struct raeth_priv *priv; struct raeth_priv *priv;
struct ramips_eth_platform_data *data = plat->dev.platform_data; struct ramips_eth_platform_data *data = plat->dev.platform_data;
int err;
if (!data) {
dev_err(&plat->dev, "no platform data specified\n");
return -EINVAL;
}
ramips_fe_base = ioremap_nocache(data->base_addr, PAGE_SIZE); ramips_fe_base = ioremap_nocache(data->base_addr, PAGE_SIZE);
if(!ramips_fe_base) if(!ramips_fe_base)
return -ENOMEM; return -ENOMEM;
ramips_dev = alloc_etherdev(sizeof(struct raeth_priv)); ramips_dev = alloc_etherdev(sizeof(struct raeth_priv));
if(!ramips_dev) if(!ramips_dev) {
return -ENOMEM; dev_err(&plat->dev, "alloc_etherdev failed\n");
err = -ENOMEM;
goto err_unmap;
}
strcpy(ramips_dev->name, "eth%d"); strcpy(ramips_dev->name, "eth%d");
ramips_dev->irq = data->irq; ramips_dev->irq = data->irq;
ramips_dev->addr_len = ETH_ALEN; ramips_dev->addr_len = ETH_ALEN;
@ -351,16 +363,24 @@ ramips_eth_plat_probe(struct platform_device *plat)
ramips_dev->init = ramips_eth_probe; ramips_dev->init = ramips_eth_probe;
priv = (struct raeth_priv*)netdev_priv(ramips_dev); priv = (struct raeth_priv*)netdev_priv(ramips_dev);
priv->plat = data; priv->plat = data;
if(register_netdev(ramips_dev))
{ err = register_netdev(ramips_dev);
printk(KERN_ERR "ramips_eth: error bringing up device\n"); if (err) {
return -ENXIO; dev_err(&plat->dev, "error bringing up device\n");
goto err_free_dev;
} }
#ifdef CONFIG_RALINK_RT305X #ifdef CONFIG_RALINK_RT305X
rt305x_esw_init(); rt305x_esw_init();
#endif #endif
printk(KERN_DEBUG "ramips_eth: loaded\n"); printk(KERN_DEBUG "ramips_eth: loaded\n");
return 0; return 0;
err_free_dev:
kfree(ramips_dev);
err_unmap:
iounmap(ramips_fe_base);
return err;
} }
static int static int