ql4_attr.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2011 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #include "ql4_def.h"
  8. #include "ql4_glbl.h"
  9. #include "ql4_dbg.h"
  10. /* Scsi_Host attributes. */
  11. static ssize_t
  12. qla4xxx_fw_version_show(struct device *dev,
  13. struct device_attribute *attr, char *buf)
  14. {
  15. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  16. if (is_qla8022(ha))
  17. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
  18. ha->firmware_version[0],
  19. ha->firmware_version[1],
  20. ha->patch_number, ha->build_number);
  21. else
  22. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
  23. ha->firmware_version[0],
  24. ha->firmware_version[1],
  25. ha->patch_number, ha->build_number);
  26. }
  27. static ssize_t
  28. qla4xxx_serial_num_show(struct device *dev, struct device_attribute *attr,
  29. char *buf)
  30. {
  31. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  32. return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
  33. }
  34. static ssize_t
  35. qla4xxx_iscsi_version_show(struct device *dev, struct device_attribute *attr,
  36. char *buf)
  37. {
  38. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  39. return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->iscsi_major,
  40. ha->iscsi_minor);
  41. }
  42. static ssize_t
  43. qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr,
  44. char *buf)
  45. {
  46. struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
  47. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
  48. ha->bootload_major, ha->bootload_minor,
  49. ha->bootload_patch, ha->bootload_build);
  50. }
  51. static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL);
  52. static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL);
  53. static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL);
  54. static DEVICE_ATTR(optrom_version, S_IRUGO, qla4xxx_optrom_version_show, NULL);
  55. struct device_attribute *qla4xxx_host_attrs[] = {
  56. &dev_attr_fw_version,
  57. &dev_attr_serial_num,
  58. &dev_attr_iscsi_version,
  59. &dev_attr_optrom_version,
  60. NULL,
  61. };