Skip to content

Commit

Permalink
driver core: platform_device_add_data(): use kmemdup()
Browse files Browse the repository at this point in the history
Instead of open-coding it.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andrew Morton authored and Greg Kroah-Hartman committed Sep 15, 2009
1 parent 4622709 commit daa4122
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* information.
*/

#include <linux/string.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/init.h>
Expand Down Expand Up @@ -213,14 +214,13 @@ EXPORT_SYMBOL_GPL(platform_device_add_resources);
int platform_device_add_data(struct platform_device *pdev, const void *data,
size_t size)
{
void *d;
void *d = kmemdup(data, size, GFP_KERNEL);

d = kmalloc(size, GFP_KERNEL);
if (d) {
memcpy(d, data, size);
pdev->dev.platform_data = d;
return 0;
}
return d ? 0 : -ENOMEM;
return -ENOMEM;
}
EXPORT_SYMBOL_GPL(platform_device_add_data);

Expand Down

0 comments on commit daa4122

Please sign in to comment.