blob: 9037ca49c328d88abbb85301707abaca0d6d451a [file] [log] [blame]
Ben Dooks3911dab2010-06-10 12:57:15 +09001/* linux/arch/arm/plat-samsung/platformdata.c
2 *
3 * Copyright 2010 Ben Dooks <ben-linux <at> fluff.org>
4 *
5 * Helper for platform data setting
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
Paul Gortmaker3d46cce2011-07-31 18:16:56 -040013#include <linux/slab.h>
Ben Dooks3911dab2010-06-10 12:57:15 +090014#include <linux/string.h>
15#include <linux/platform_device.h>
16
17#include <plat/devs.h>
18
19void __init *s3c_set_platdata(void *pd, size_t pdsize,
20 struct platform_device *pdev)
21{
22 void *npd;
23
24 if (!pd) {
25 /* too early to use dev_name(), may not be registered */
26 printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
27 return NULL;
28 }
29
30 npd = kmemdup(pd, pdsize, GFP_KERNEL);
31 if (!npd) {
32 printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name);
33 return NULL;
34 }
35
36 pdev->dev.platform_data = npd;
37 return npd;
38}