Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 368658
b: refs/heads/master
c: 2116824
h: refs/heads/master
v: v3
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Mar 25, 2013
1 parent e0d80dd commit 8dc9884
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4c64f1f70cf3e7860bae12d62a31c137a6a4f4a7
refs/heads/master: 21168245031062212c0b805d0bd466ee6dd4a16f
38 changes: 18 additions & 20 deletions trunk/net/dsa/dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
return ret;
}

static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
{
int i;
int port_index;

for (i = 0; i < pd->nr_chips; i++) {
port_index = 0;
while (pd->chip[i].port_names &&
pd->chip[i].port_names[++port_index])
kfree(pd->chip[i].port_names[port_index]);
kfree(pd->chip[i].rtable);
}
kfree(pd->chip);
}

static int dsa_of_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
Expand All @@ -354,7 +369,7 @@ static int dsa_of_probe(struct platform_device *pdev)
const char *port_name;
int chip_index, port_index;
const unsigned int *sw_addr, *port_reg;
int ret, i;
int ret;

mdio = of_parse_phandle(np, "dsa,mii-bus", 0);
if (!mdio)
Expand Down Expand Up @@ -439,14 +454,7 @@ static int dsa_of_probe(struct platform_device *pdev)
return 0;

out_free_chip:
for (i = 0; i < pd->nr_chips; i++) {
port_index = 0;
while (pd->chip[i].port_names &&
pd->chip[i].port_names[++port_index])
kfree(pd->chip[i].port_names[port_index]);
kfree(pd->chip[i].rtable);
}
kfree(pd->chip);
dsa_of_free_platform_data(pd);
out_free:
kfree(pd);
pdev->dev.platform_data = NULL;
Expand All @@ -456,21 +464,11 @@ static int dsa_of_probe(struct platform_device *pdev)
static void dsa_of_remove(struct platform_device *pdev)
{
struct dsa_platform_data *pd = pdev->dev.platform_data;
int i;
int port_index;

if (!pdev->dev.of_node)
return;

for (i = 0; i < pd->nr_chips; i++) {
port_index = 0;
while (pd->chip[i].port_names &&
pd->chip[i].port_names[++port_index])
kfree(pd->chip[i].port_names[port_index]);
kfree(pd->chip[i].rtable);
}

kfree(pd->chip);
dsa_of_free_platform_data(pd);
kfree(pd);
}
#else
Expand Down

0 comments on commit 8dc9884

Please sign in to comment.