platformdata.c 900 B

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