diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2009-10-26 17:17:13 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2009-10-26 17:17:13 +0000 |
commit | 7c7f004875752eda1985f274205412b01b4db318 (patch) | |
tree | 9c4038c189550265095626b8d5148134097448bd /target/linux/ramips/files | |
parent | c2cc2884e3e774f9eaa6d5c25ba754d009949852 (diff) | |
download | upstream-7c7f004875752eda1985f274205412b01b4db318.tar.gz upstream-7c7f004875752eda1985f274205412b01b4db318.tar.bz2 upstream-7c7f004875752eda1985f274205412b01b4db318.zip |
ramips: add error-path handling to the ramips_eth_plat_probe
SVN-Revision: 18165
Diffstat (limited to 'target/linux/ramips/files')
-rw-r--r-- | target/linux/ramips/files/drivers/net/ramips.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/target/linux/ramips/files/drivers/net/ramips.c b/target/linux/ramips/files/drivers/net/ramips.c index d3337da200..ae47230b7c 100644 --- a/target/linux/ramips/files/drivers/net/ramips.c +++ b/target/linux/ramips/files/drivers/net/ramips.c @@ -338,12 +338,24 @@ ramips_eth_plat_probe(struct platform_device *plat) { struct raeth_priv *priv; 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); if(!ramips_fe_base) return -ENOMEM; + ramips_dev = alloc_etherdev(sizeof(struct raeth_priv)); - if(!ramips_dev) - return -ENOMEM; + if(!ramips_dev) { + dev_err(&plat->dev, "alloc_etherdev failed\n"); + err = -ENOMEM; + goto err_unmap; + } + strcpy(ramips_dev->name, "eth%d"); ramips_dev->irq = data->irq; ramips_dev->addr_len = ETH_ALEN; @@ -351,16 +363,24 @@ ramips_eth_plat_probe(struct platform_device *plat) ramips_dev->init = ramips_eth_probe; priv = (struct raeth_priv*)netdev_priv(ramips_dev); priv->plat = data; - if(register_netdev(ramips_dev)) - { - printk(KERN_ERR "ramips_eth: error bringing up device\n"); - return -ENXIO; + + err = register_netdev(ramips_dev); + if (err) { + dev_err(&plat->dev, "error bringing up device\n"); + goto err_free_dev; } + #ifdef CONFIG_RALINK_RT305X rt305x_esw_init(); #endif printk(KERN_DEBUG "ramips_eth: loaded\n"); return 0; + + err_free_dev: + kfree(ramips_dev); + err_unmap: + iounmap(ramips_fe_base); + return err; } static int |