aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-04-06 17:03:09 +0000
committerGabor Juhos <juhosg@openwrt.org>2013-04-06 17:03:09 +0000
commitf5d8d80ca9423ff0780bc0dca91bb2eda39e50a1 (patch)
tree5df06f0193f0d256ef6f0aef2ac475c91830a1ca /target/linux
parent32d3b456f030a2ae55f2e60eb86f456984c7ce93 (diff)
downloadupstream-f5d8d80ca9423ff0780bc0dca91bb2eda39e50a1.tar.gz
upstream-f5d8d80ca9423ff0780bc0dca91bb2eda39e50a1.tar.bz2
upstream-f5d8d80ca9423ff0780bc0dca91bb2eda39e50a1.zip
generic: rtl8367b: fix rtl8367b_extif_init_of
* disable external interface if its property is not present * show an error message if the extif property is not valid * use proper error values intead of -1 * fix memory leak * wrap long lines Signed-off-by: Gabor Juhos <juhosg@openwrt.org> SVN-Revision: 36229
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8367b.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c
index 5775fa4e98..47c0ff94b9 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c
@@ -863,19 +863,26 @@ static int rtl8367b_extif_init(struct rtl8366_smi *smi, int id,
}
#ifdef CONFIG_OF
-static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id, const char *name)
+static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id,
+ const char *name)
{
struct rtl8367_extif_config *cfg;
const __be32 *prop;
int size;
+ int err;
prop = of_get_property(smi->parent->of_node, name, &size);
- if (!prop || size != (9 * sizeof(*prop)))
- return 0;
+ if (!prop)
+ return rtl8367b_extif_init(smi, id, NULL);
+
+ if (size != (9 * sizeof(*prop))) {
+ dev_err(smi->parent, "%s property is invalid\n", name);
+ return -EINVAL;
+ }
cfg = kzalloc(sizeof(struct rtl8367_extif_config), GFP_KERNEL);
if (!cfg)
- return -1;
+ return -ENOMEM;
cfg->txdelay = be32_to_cpup(prop++);
cfg->rxdelay = be32_to_cpup(prop++);
@@ -887,12 +894,16 @@ static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id, const char *n
cfg->ability.duplex = be32_to_cpup(prop++);
cfg->ability.speed = be32_to_cpup(prop++);
- return rtl8367b_extif_init(smi, id, cfg);
+ err = rtl8367b_extif_init(smi, id, cfg);
+ kfree(cfg);
+
+ return err;
}
#else
-static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id, const char *name)
+static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id,
+ const char *name)
{
- return -1;
+ return -EINVAL;
}
#endif