sfsattrib.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include <linux/version.h>
  2. #include <linux/init.h>
  3. #include <linux/kernel.h>
  4. #include <linux/module.h>
  5. #include <linux/kobject.h>
  6. #include <linux/errno.h>
  7. #include <linux/sysfs.h>
  8. #include <linux/syscalls.h>
  9. #include "sfsattrib.h"
  10. /////////////////////////////////////////////////////////////////////////////
  11. int g_hw = 0, g_sw = 0;
  12. TIVA_ADC g_tadc;
  13. /////////////////////////////////////////////////////////////////////////////
  14. static ssize_t firmware_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  15. {
  16. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  17. return sprintf(buf, "HW: %08X SW: %08X", g_hw, g_sw);
  18. }
  19. /////////////////////////////////////////////////////////////////////////////
  20. static ssize_t UVers_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  21. {
  22. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  23. return sprintf(buf, "%d", g_tadc.UVers);
  24. }
  25. /////////////////////////////////////////////////////////////////////////////
  26. static ssize_t UBatV3_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  27. {
  28. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  29. return sprintf(buf, "%d", g_tadc.UBatV3);
  30. }
  31. /////////////////////////////////////////////////////////////////////////////
  32. static ssize_t Temp_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  33. {
  34. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  35. return sprintf(buf, "%d", g_tadc.Temp);
  36. }
  37. /////////////////////////////////////////////////////////////////////////////
  38. static ssize_t UV5Vsys_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  39. {
  40. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  41. return sprintf(buf, "%d", g_tadc.UV5Vsys);
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. static ssize_t UV3V6Bat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  45. {
  46. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  47. return sprintf(buf, "%d", g_tadc.UV3V6Bat);
  48. }
  49. /////////////////////////////////////////////////////////////////////////////
  50. static ssize_t TempTIVA_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
  51. {
  52. // printk(KERN_ALERT "%s, Ctx: \"%s\"-(%d)\n", __FUNCTION__, current->comm, current->pid);
  53. return sprintf(buf, "%d", g_tadc.TempTIVA);
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. struct kobj_attribute g_tivaFirmwareAtt = __ATTR_RO(firmware);
  57. struct kobj_attribute g_tivaUVersAtt = __ATTR_RO(UVers);
  58. struct kobj_attribute g_tivaUBatV3Att = __ATTR_RO(UBatV3);
  59. struct kobj_attribute g_tivaTempAtt = __ATTR_RO(Temp);
  60. struct kobj_attribute g_tivaUV5VsysAtt = __ATTR_RO(UV5Vsys);
  61. struct kobj_attribute g_tivaUV3V6BatAtt = __ATTR_RO(UV3V6Bat);
  62. struct kobj_attribute g_tivaTempTIVAAtt = __ATTR_RO(TempTIVA);