platform.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2009 Lemote Inc.
  3. * Author: Wu Zhangjin, wuzhangjin@gmail.com
  4. * Xiang Yu, xiangy@lemote.com
  5. * Chen Huacai, chenhc@lemote.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/err.h>
  13. #include <linux/slab.h>
  14. #include <linux/platform_device.h>
  15. #include <asm/bootinfo.h>
  16. #include <boot_param.h>
  17. #include <loongson_hwmon.h>
  18. #include <workarounds.h>
  19. static int __init loongson3_platform_init(void)
  20. {
  21. int i;
  22. struct platform_device *pdev;
  23. if (loongson_sysconf.ecname[0] != '\0')
  24. platform_device_register_simple(loongson_sysconf.ecname, -1, NULL, 0);
  25. for (i = 0; i < loongson_sysconf.nr_sensors; i++) {
  26. if (loongson_sysconf.sensors[i].type > SENSOR_FAN)
  27. continue;
  28. pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
  29. if (!pdev)
  30. return -ENOMEM;
  31. pdev->name = loongson_sysconf.sensors[i].name;
  32. pdev->id = loongson_sysconf.sensors[i].id;
  33. pdev->dev.platform_data = &loongson_sysconf.sensors[i];
  34. platform_device_register(pdev);
  35. }
  36. return 0;
  37. }
  38. arch_initcall(loongson3_platform_init);