nilfs2: unbreak compat ioctl
[zen-stable.git] / drivers / scsi / qla4xxx / ql4_attr.c
blob0b0a7d42137d7b3fef646ec376175d9c7a97454e
1 /*
2 * QLogic iSCSI HBA Driver
3 * Copyright (c) 2003-2011 QLogic Corporation
5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */
8 #include "ql4_def.h"
9 #include "ql4_glbl.h"
10 #include "ql4_dbg.h"
12 /* Scsi_Host attributes. */
13 static ssize_t
14 qla4xxx_fw_version_show(struct device *dev,
15 struct device_attribute *attr, char *buf)
17 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
19 if (is_qla8022(ha))
20 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
21 ha->firmware_version[0],
22 ha->firmware_version[1],
23 ha->patch_number, ha->build_number);
24 else
25 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
26 ha->firmware_version[0],
27 ha->firmware_version[1],
28 ha->patch_number, ha->build_number);
31 static ssize_t
32 qla4xxx_serial_num_show(struct device *dev, struct device_attribute *attr,
33 char *buf)
35 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
36 return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number);
39 static ssize_t
40 qla4xxx_iscsi_version_show(struct device *dev, struct device_attribute *attr,
41 char *buf)
43 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
44 return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->iscsi_major,
45 ha->iscsi_minor);
48 static ssize_t
49 qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr,
50 char *buf)
52 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
53 return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n",
54 ha->bootload_major, ha->bootload_minor,
55 ha->bootload_patch, ha->bootload_build);
58 static ssize_t
59 qla4xxx_board_id_show(struct device *dev, struct device_attribute *attr,
60 char *buf)
62 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
63 return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id);
66 static ssize_t
67 qla4xxx_fw_state_show(struct device *dev, struct device_attribute *attr,
68 char *buf)
70 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
72 qla4xxx_get_firmware_state(ha);
73 return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state,
74 ha->addl_fw_state);
77 static ssize_t
78 qla4xxx_phy_port_cnt_show(struct device *dev, struct device_attribute *attr,
79 char *buf)
81 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
83 if (!is_qla8022(ha))
84 return -ENOSYS;
86 return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt);
89 static ssize_t
90 qla4xxx_phy_port_num_show(struct device *dev, struct device_attribute *attr,
91 char *buf)
93 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
95 if (!is_qla8022(ha))
96 return -ENOSYS;
98 return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num);
101 static ssize_t
102 qla4xxx_iscsi_func_cnt_show(struct device *dev, struct device_attribute *attr,
103 char *buf)
105 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
107 if (!is_qla8022(ha))
108 return -ENOSYS;
110 return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt);
113 static ssize_t
114 qla4xxx_hba_model_show(struct device *dev, struct device_attribute *attr,
115 char *buf)
117 struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
119 return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name);
122 static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL);
123 static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL);
124 static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL);
125 static DEVICE_ATTR(optrom_version, S_IRUGO, qla4xxx_optrom_version_show, NULL);
126 static DEVICE_ATTR(board_id, S_IRUGO, qla4xxx_board_id_show, NULL);
127 static DEVICE_ATTR(fw_state, S_IRUGO, qla4xxx_fw_state_show, NULL);
128 static DEVICE_ATTR(phy_port_cnt, S_IRUGO, qla4xxx_phy_port_cnt_show, NULL);
129 static DEVICE_ATTR(phy_port_num, S_IRUGO, qla4xxx_phy_port_num_show, NULL);
130 static DEVICE_ATTR(iscsi_func_cnt, S_IRUGO, qla4xxx_iscsi_func_cnt_show, NULL);
131 static DEVICE_ATTR(hba_model, S_IRUGO, qla4xxx_hba_model_show, NULL);
133 struct device_attribute *qla4xxx_host_attrs[] = {
134 &dev_attr_fw_version,
135 &dev_attr_serial_num,
136 &dev_attr_iscsi_version,
137 &dev_attr_optrom_version,
138 &dev_attr_board_id,
139 &dev_attr_fw_state,
140 &dev_attr_phy_port_cnt,
141 &dev_attr_phy_port_num,
142 &dev_attr_iscsi_func_cnt,
143 &dev_attr_hba_model,
144 NULL,