platformdata.c 924 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* 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. #include <linux/kernel.h>
  12. #include <linux/slab.h>
  13. #include <linux/string.h>
  14. #include <linux/platform_device.h>
  15. #include <plat/devs.h>
  16. void __init *s3c_set_platdata(void *pd, size_t pdsize,
  17. struct platform_device *pdev)
  18. {
  19. void *npd;
  20. if (!pd) {
  21. /* too early to use dev_name(), may not be registered */
  22. printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
  23. return NULL;
  24. }
  25. npd = kmemdup(pd, pdsize, GFP_KERNEL);
  26. if (!npd) {
  27. printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name);
  28. return NULL;
  29. }
  30. pdev->dev.platform_data = npd;
  31. return npd;
  32. }