diff options
author | Thomas Meyer <thomas@m3y3r.de> | 2011-11-17 17:43:40 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-07-23 08:55:55 -0400 |
commit | a6196bab646537f594ef269bf9e1c92fe0e165a6 (patch) | |
tree | 6c680ab85f339ceac5074d6e3581ac17da7579c5 /arch/mips/alchemy/common/platform.c | |
parent | a551fafba2bd3c395bf56e4fafc828a13e994588 (diff) |
MIPS: Alchemy: Use kmemdup rather than duplicating its implementation
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/3058/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy/common/platform.c')
-rw-r--r-- | arch/mips/alchemy/common/platform.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c index 95cb9113b12c..c0f3ce6dcb56 100644 --- a/arch/mips/alchemy/common/platform.c +++ b/arch/mips/alchemy/common/platform.c | |||
@@ -334,13 +334,12 @@ static void __init alchemy_setup_macs(int ctype) | |||
334 | if (alchemy_get_macs(ctype) < 1) | 334 | if (alchemy_get_macs(ctype) < 1) |
335 | return; | 335 | return; |
336 | 336 | ||
337 | macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); | 337 | macres = kmemdup(au1xxx_eth0_resources[ctype], |
338 | sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); | ||
338 | if (!macres) { | 339 | if (!macres) { |
339 | printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n"); | 340 | printk(KERN_INFO "Alchemy: no memory for MAC0 resources\n"); |
340 | return; | 341 | return; |
341 | } | 342 | } |
342 | memcpy(macres, au1xxx_eth0_resources[ctype], | ||
343 | sizeof(struct resource) * MAC_RES_COUNT); | ||
344 | au1xxx_eth0_device.resource = macres; | 343 | au1xxx_eth0_device.resource = macres; |
345 | 344 | ||
346 | i = prom_get_ethernet_addr(ethaddr); | 345 | i = prom_get_ethernet_addr(ethaddr); |
@@ -356,13 +355,12 @@ static void __init alchemy_setup_macs(int ctype) | |||
356 | if (alchemy_get_macs(ctype) < 2) | 355 | if (alchemy_get_macs(ctype) < 2) |
357 | return; | 356 | return; |
358 | 357 | ||
359 | macres = kmalloc(sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); | 358 | macres = kmemdup(au1xxx_eth1_resources[ctype], |
359 | sizeof(struct resource) * MAC_RES_COUNT, GFP_KERNEL); | ||
360 | if (!macres) { | 360 | if (!macres) { |
361 | printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n"); | 361 | printk(KERN_INFO "Alchemy: no memory for MAC1 resources\n"); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | memcpy(macres, au1xxx_eth1_resources[ctype], | ||
365 | sizeof(struct resource) * MAC_RES_COUNT); | ||
366 | au1xxx_eth1_device.resource = macres; | 364 | au1xxx_eth1_device.resource = macres; |
367 | 365 | ||
368 | ethaddr[5] += 1; /* next addr for 2nd MAC */ | 366 | ethaddr[5] += 1; /* next addr for 2nd MAC */ |