diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_attr.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 9bc1f153f7ea..659a5d63467d 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -63,23 +63,29 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off, | |||
63 | ha->host_no); | 63 | ha->host_no); |
64 | 64 | ||
65 | vfree(ha->fw_dump_buffer); | 65 | vfree(ha->fw_dump_buffer); |
66 | free_pages((unsigned long)ha->fw_dump, | 66 | if (!IS_QLA24XX(ha) && !IS_QLA25XX(ha)) |
67 | ha->fw_dump_order); | 67 | free_pages((unsigned long)ha->fw_dump, |
68 | ha->fw_dump_order); | ||
68 | 69 | ||
69 | ha->fw_dump_reading = 0; | 70 | ha->fw_dump_reading = 0; |
70 | ha->fw_dump_buffer = NULL; | 71 | ha->fw_dump_buffer = NULL; |
71 | ha->fw_dump = NULL; | 72 | ha->fw_dump = NULL; |
73 | ha->fw_dumped = 0; | ||
72 | } | 74 | } |
73 | break; | 75 | break; |
74 | case 1: | 76 | case 1: |
75 | if (ha->fw_dump != NULL && !ha->fw_dump_reading) { | 77 | if ((ha->fw_dump || ha->fw_dumped) && !ha->fw_dump_reading) { |
76 | ha->fw_dump_reading = 1; | 78 | ha->fw_dump_reading = 1; |
77 | 79 | ||
78 | dump_size = FW_DUMP_SIZE_1M; | 80 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) |
79 | if (ha->fw_memory_size < 0x20000) | 81 | dump_size = FW_DUMP_SIZE_24XX; |
80 | dump_size = FW_DUMP_SIZE_128K; | 82 | else { |
81 | else if (ha->fw_memory_size < 0x80000) | 83 | dump_size = FW_DUMP_SIZE_1M; |
82 | dump_size = FW_DUMP_SIZE_512K; | 84 | if (ha->fw_memory_size < 0x20000) |
85 | dump_size = FW_DUMP_SIZE_128K; | ||
86 | else if (ha->fw_memory_size < 0x80000) | ||
87 | dump_size = FW_DUMP_SIZE_512K; | ||
88 | } | ||
83 | ha->fw_dump_buffer = (char *)vmalloc(dump_size); | 89 | ha->fw_dump_buffer = (char *)vmalloc(dump_size); |
84 | if (ha->fw_dump_buffer == NULL) { | 90 | if (ha->fw_dump_buffer == NULL) { |
85 | qla_printk(KERN_WARNING, ha, | 91 | qla_printk(KERN_WARNING, ha, |
@@ -93,10 +99,7 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off, | |||
93 | "Firmware dump ready for read on (%ld).\n", | 99 | "Firmware dump ready for read on (%ld).\n", |
94 | ha->host_no); | 100 | ha->host_no); |
95 | memset(ha->fw_dump_buffer, 0, dump_size); | 101 | memset(ha->fw_dump_buffer, 0, dump_size); |
96 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) | 102 | ha->isp_ops.ascii_fw_dump(ha); |
97 | qla2100_ascii_fw_dump(ha); | ||
98 | else | ||
99 | qla2300_ascii_fw_dump(ha); | ||
100 | ha->fw_dump_buffer_len = strlen(ha->fw_dump_buffer); | 103 | ha->fw_dump_buffer_len = strlen(ha->fw_dump_buffer); |
101 | } | 104 | } |
102 | break; | 105 | break; |
@@ -121,23 +124,15 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off, | |||
121 | { | 124 | { |
122 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 125 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, |
123 | struct device, kobj))); | 126 | struct device, kobj))); |
124 | uint16_t *witer; | ||
125 | unsigned long flags; | 127 | unsigned long flags; |
126 | uint16_t cnt; | ||
127 | 128 | ||
128 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t)) | 129 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) |
129 | return 0; | 130 | return 0; |
130 | 131 | ||
131 | /* Read NVRAM. */ | 132 | /* Read NVRAM. */ |
132 | spin_lock_irqsave(&ha->hardware_lock, flags); | 133 | spin_lock_irqsave(&ha->hardware_lock, flags); |
133 | qla2x00_lock_nvram_access(ha); | 134 | ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->nvram_base, |
134 | witer = (uint16_t *)buf; | 135 | ha->nvram_size); |
135 | for (cnt = 0; cnt < count / 2; cnt++) { | ||
136 | *witer = cpu_to_le16(qla2x00_get_nvram_word(ha, | ||
137 | cnt+ha->nvram_base)); | ||
138 | witer++; | ||
139 | } | ||
140 | qla2x00_unlock_nvram_access(ha); | ||
141 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 136 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
142 | 137 | ||
143 | return (count); | 138 | return (count); |
@@ -149,34 +144,38 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf, loff_t off, | |||
149 | { | 144 | { |
150 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 145 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, |
151 | struct device, kobj))); | 146 | struct device, kobj))); |
152 | uint8_t *iter; | ||
153 | uint16_t *witer; | ||
154 | unsigned long flags; | 147 | unsigned long flags; |
155 | uint16_t cnt; | 148 | uint16_t cnt; |
156 | uint8_t chksum; | ||
157 | 149 | ||
158 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t)) | 150 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) |
159 | return 0; | 151 | return 0; |
160 | 152 | ||
161 | /* Checksum NVRAM. */ | 153 | /* Checksum NVRAM. */ |
162 | iter = (uint8_t *)buf; | 154 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { |
163 | chksum = 0; | 155 | uint32_t *iter; |
164 | for (cnt = 0; cnt < count - 1; cnt++) | 156 | uint32_t chksum; |
165 | chksum += *iter++; | 157 | |
166 | chksum = ~chksum + 1; | 158 | iter = (uint32_t *)buf; |
167 | *iter = chksum; | 159 | chksum = 0; |
160 | for (cnt = 0; cnt < ((count >> 2) - 1); cnt++) | ||
161 | chksum += le32_to_cpu(*iter++); | ||
162 | chksum = ~chksum + 1; | ||
163 | *iter = cpu_to_le32(chksum); | ||
164 | } else { | ||
165 | uint8_t *iter; | ||
166 | uint8_t chksum; | ||
167 | |||
168 | iter = (uint8_t *)buf; | ||
169 | chksum = 0; | ||
170 | for (cnt = 0; cnt < count - 1; cnt++) | ||
171 | chksum += *iter++; | ||
172 | chksum = ~chksum + 1; | ||
173 | *iter = chksum; | ||
174 | } | ||
168 | 175 | ||
169 | /* Write NVRAM. */ | 176 | /* Write NVRAM. */ |
170 | spin_lock_irqsave(&ha->hardware_lock, flags); | 177 | spin_lock_irqsave(&ha->hardware_lock, flags); |
171 | qla2x00_lock_nvram_access(ha); | 178 | ha->isp_ops.write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); |
172 | qla2x00_release_nvram_protection(ha); | ||
173 | witer = (uint16_t *)buf; | ||
174 | for (cnt = 0; cnt < count / 2; cnt++) { | ||
175 | qla2x00_write_nvram_word(ha, cnt+ha->nvram_base, | ||
176 | cpu_to_le16(*witer)); | ||
177 | witer++; | ||
178 | } | ||
179 | qla2x00_unlock_nvram_access(ha); | ||
180 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 179 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
181 | 180 | ||
182 | return (count); | 181 | return (count); |
@@ -188,7 +187,7 @@ static struct bin_attribute sysfs_nvram_attr = { | |||
188 | .mode = S_IRUSR | S_IWUSR, | 187 | .mode = S_IRUSR | S_IWUSR, |
189 | .owner = THIS_MODULE, | 188 | .owner = THIS_MODULE, |
190 | }, | 189 | }, |
191 | .size = sizeof(nvram_t), | 190 | .size = 0, |
192 | .read = qla2x00_sysfs_read_nvram, | 191 | .read = qla2x00_sysfs_read_nvram, |
193 | .write = qla2x00_sysfs_write_nvram, | 192 | .write = qla2x00_sysfs_write_nvram, |
194 | }; | 193 | }; |
@@ -199,6 +198,7 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) | |||
199 | struct Scsi_Host *host = ha->host; | 198 | struct Scsi_Host *host = ha->host; |
200 | 199 | ||
201 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); | 200 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); |
201 | sysfs_nvram_attr.size = ha->nvram_size; | ||
202 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); | 202 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); |
203 | } | 203 | } |
204 | 204 | ||