diff options
author | Andrew Vasquez <andrew.vasquez@qlogic.com> | 2005-07-06 13:31:07 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.(none)> | 2005-07-14 10:56:54 -0400 |
commit | 459c537807bd72cce7b007fb218bb5a658a6c3c1 (patch) | |
tree | 18a05e5f8fb73651219860f7056c6f73a885d623 /drivers/scsi/qla2xxx/qla_attr.c | |
parent | 1c7c63574ff3e568ca374e9f05e30b8d7d64273e (diff) |
[SCSI] qla2xxx: Add ISP24xx flash-manipulation routines.
Add ISP24xx flash-manipulation routines.
Add read/write flash manipulation routines for the ISP24xx.
Update sysfs NVRAM objects to use generalized accessor
functions.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_attr.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_attr.c | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 30c381c3abcc..9361f4255e62 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c | |||
@@ -118,23 +118,15 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj, char *buf, loff_t off, | |||
118 | { | 118 | { |
119 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 119 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, |
120 | struct device, kobj))); | 120 | struct device, kobj))); |
121 | uint16_t *witer; | ||
122 | unsigned long flags; | 121 | unsigned long flags; |
123 | uint16_t cnt; | ||
124 | 122 | ||
125 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t)) | 123 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) |
126 | return 0; | 124 | return 0; |
127 | 125 | ||
128 | /* Read NVRAM. */ | 126 | /* Read NVRAM. */ |
129 | spin_lock_irqsave(&ha->hardware_lock, flags); | 127 | spin_lock_irqsave(&ha->hardware_lock, flags); |
130 | qla2x00_lock_nvram_access(ha); | 128 | ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->nvram_base, |
131 | witer = (uint16_t *)buf; | 129 | ha->nvram_size); |
132 | for (cnt = 0; cnt < count / 2; cnt++) { | ||
133 | *witer = cpu_to_le16(qla2x00_get_nvram_word(ha, | ||
134 | cnt+ha->nvram_base)); | ||
135 | witer++; | ||
136 | } | ||
137 | qla2x00_unlock_nvram_access(ha); | ||
138 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 130 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
139 | 131 | ||
140 | return (count); | 132 | return (count); |
@@ -146,34 +138,38 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj, char *buf, loff_t off, | |||
146 | { | 138 | { |
147 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, | 139 | struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, |
148 | struct device, kobj))); | 140 | struct device, kobj))); |
149 | uint8_t *iter; | ||
150 | uint16_t *witer; | ||
151 | unsigned long flags; | 141 | unsigned long flags; |
152 | uint16_t cnt; | 142 | uint16_t cnt; |
153 | uint8_t chksum; | ||
154 | 143 | ||
155 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != sizeof(nvram_t)) | 144 | if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size) |
156 | return 0; | 145 | return 0; |
157 | 146 | ||
158 | /* Checksum NVRAM. */ | 147 | /* Checksum NVRAM. */ |
159 | iter = (uint8_t *)buf; | 148 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha)) { |
160 | chksum = 0; | 149 | uint32_t *iter; |
161 | for (cnt = 0; cnt < count - 1; cnt++) | 150 | uint32_t chksum; |
162 | chksum += *iter++; | 151 | |
163 | chksum = ~chksum + 1; | 152 | iter = (uint32_t *)buf; |
164 | *iter = chksum; | 153 | chksum = 0; |
154 | for (cnt = 0; cnt < ((count >> 2) - 1); cnt++) | ||
155 | chksum += le32_to_cpu(*iter++); | ||
156 | chksum = ~chksum + 1; | ||
157 | *iter = cpu_to_le32(chksum); | ||
158 | } else { | ||
159 | uint8_t *iter; | ||
160 | uint8_t chksum; | ||
161 | |||
162 | iter = (uint8_t *)buf; | ||
163 | chksum = 0; | ||
164 | for (cnt = 0; cnt < count - 1; cnt++) | ||
165 | chksum += *iter++; | ||
166 | chksum = ~chksum + 1; | ||
167 | *iter = chksum; | ||
168 | } | ||
165 | 169 | ||
166 | /* Write NVRAM. */ | 170 | /* Write NVRAM. */ |
167 | spin_lock_irqsave(&ha->hardware_lock, flags); | 171 | spin_lock_irqsave(&ha->hardware_lock, flags); |
168 | qla2x00_lock_nvram_access(ha); | 172 | ha->isp_ops.write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); |
169 | qla2x00_release_nvram_protection(ha); | ||
170 | witer = (uint16_t *)buf; | ||
171 | for (cnt = 0; cnt < count / 2; cnt++) { | ||
172 | qla2x00_write_nvram_word(ha, cnt+ha->nvram_base, | ||
173 | cpu_to_le16(*witer)); | ||
174 | witer++; | ||
175 | } | ||
176 | qla2x00_unlock_nvram_access(ha); | ||
177 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 173 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
178 | 174 | ||
179 | return (count); | 175 | return (count); |
@@ -185,7 +181,7 @@ static struct bin_attribute sysfs_nvram_attr = { | |||
185 | .mode = S_IRUSR | S_IWUSR, | 181 | .mode = S_IRUSR | S_IWUSR, |
186 | .owner = THIS_MODULE, | 182 | .owner = THIS_MODULE, |
187 | }, | 183 | }, |
188 | .size = sizeof(nvram_t), | 184 | .size = 0, |
189 | .read = qla2x00_sysfs_read_nvram, | 185 | .read = qla2x00_sysfs_read_nvram, |
190 | .write = qla2x00_sysfs_write_nvram, | 186 | .write = qla2x00_sysfs_write_nvram, |
191 | }; | 187 | }; |
@@ -196,6 +192,7 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha) | |||
196 | struct Scsi_Host *host = ha->host; | 192 | struct Scsi_Host *host = ha->host; |
197 | 193 | ||
198 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); | 194 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_fw_dump_attr); |
195 | sysfs_nvram_attr.size = ha->nvram_size; | ||
199 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); | 196 | sysfs_create_bin_file(&host->shost_gendev.kobj, &sysfs_nvram_attr); |
200 | } | 197 | } |
201 | 198 | ||