* 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
-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;
{
struct rtl8367_extif_config *cfg;
const __be32 *prop;
int size;
prop = of_get_property(smi->parent->of_node, name, &size);
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)
cfg = kzalloc(sizeof(struct rtl8367_extif_config), GFP_KERNEL);
if (!cfg)
cfg->txdelay = be32_to_cpup(prop++);
cfg->rxdelay = be32_to_cpup(prop++);
cfg->txdelay = be32_to_cpup(prop++);
cfg->rxdelay = be32_to_cpup(prop++);
cfg->ability.duplex = be32_to_cpup(prop++);
cfg->ability.speed = be32_to_cpup(prop++);
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;
-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)