dummy.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * dummy.c
  3. *
  4. * Copyright 2010 Wolfson Microelectronics PLC.
  5. *
  6. * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This is useful for systems with mixed controllable and
  14. * non-controllable regulators, as well as for allowing testing on
  15. * systems with no controllable regulators.
  16. */
  17. #include <linux/err.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/regulator/driver.h>
  20. #include <linux/regulator/machine.h>
  21. #include "dummy.h"
  22. struct regulator_dev *dummy_regulator_rdev;
  23. static struct regulator_init_data dummy_initdata;
  24. static struct regulator_ops dummy_ops;
  25. static struct regulator_desc dummy_desc = {
  26. .name = "dummy",
  27. .id = -1,
  28. .type = REGULATOR_VOLTAGE,
  29. .owner = THIS_MODULE,
  30. .ops = &dummy_ops,
  31. };
  32. static struct platform_device *dummy_pdev;
  33. void __init regulator_dummy_init(void)
  34. {
  35. int ret;
  36. dummy_pdev = platform_device_alloc("reg-dummy", -1);
  37. if (!dummy_pdev) {
  38. pr_err("Failed to allocate dummy regulator device\n");
  39. return;
  40. }
  41. ret = platform_device_add(dummy_pdev);
  42. if (ret != 0) {
  43. pr_err("Failed to register dummy regulator device: %d\n", ret);
  44. platform_device_put(dummy_pdev);
  45. return;
  46. }
  47. dummy_regulator_rdev = regulator_register(&dummy_desc, NULL,
  48. &dummy_initdata, NULL);
  49. if (IS_ERR(dummy_regulator_rdev)) {
  50. ret = PTR_ERR(dummy_regulator_rdev);
  51. pr_err("Failed to register regulator: %d\n", ret);
  52. platform_device_unregister(dummy_pdev);
  53. return;
  54. }
  55. }