buttons.c 829 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Cobalt buttons platform device.
  4. *
  5. * Copyright (C) 2007 Yoichi Yuasa <[email protected]>
  6. */
  7. #include <linux/platform_device.h>
  8. #include <linux/errno.h>
  9. #include <linux/init.h>
  10. static struct resource cobalt_buttons_resource __initdata = {
  11. .start = 0x1d000000,
  12. .end = 0x1d000003,
  13. .flags = IORESOURCE_MEM,
  14. };
  15. static __init int cobalt_add_buttons(void)
  16. {
  17. struct platform_device *pd;
  18. int error;
  19. pd = platform_device_alloc("Cobalt buttons", -1);
  20. if (!pd)
  21. return -ENOMEM;
  22. error = platform_device_add_resources(pd, &cobalt_buttons_resource, 1);
  23. if (error)
  24. goto err_free_device;
  25. error = platform_device_add(pd);
  26. if (error)
  27. goto err_free_device;
  28. return 0;
  29. err_free_device:
  30. platform_device_put(pd);
  31. return error;
  32. }
  33. device_initcall(cobalt_add_buttons);