aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2008-07-24 11:31:47 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-26 15:30:22 -0400
commitb3dc9088f3714642284245a6c580305a1415e0e3 (patch)
treea85c33a6b7666697c2b59875e3137d1aa62263c4
parent8201e207997b4665a5fcb375bab293fddb2e6adb (diff)
[SCSI] qla2xxx: use memory_read_from_buffer()
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 612e3d0c7bd1..fcec43a32be3 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -20,18 +20,12 @@ qla2x00_sysfs_read_fw_dump(struct kobject *kobj,
20{ 20{
21 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 21 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
22 struct device, kobj))); 22 struct device, kobj)));
23 char *rbuf = (char *)ha->fw_dump;
24 23
25 if (ha->fw_dump_reading == 0) 24 if (ha->fw_dump_reading == 0)
26 return 0; 25 return 0;
27 if (off > ha->fw_dump_len)
28 return 0;
29 if (off + count > ha->fw_dump_len)
30 count = ha->fw_dump_len - off;
31 26
32 memcpy(buf, &rbuf[off], count); 27 return memory_read_from_buffer(buf, count, &off, ha->fw_dump,
33 28 ha->fw_dump_len);
34 return (count);
35} 29}
36 30
37static ssize_t 31static ssize_t
@@ -94,20 +88,13 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
94{ 88{
95 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 89 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
96 struct device, kobj))); 90 struct device, kobj)));
97 int size = ha->nvram_size;
98 char *nvram_cache = ha->nvram;
99 91
100 if (!capable(CAP_SYS_ADMIN) || off > size || count == 0) 92 if (!capable(CAP_SYS_ADMIN))
101 return 0; 93 return 0;
102 if (off + count > size) {
103 size -= off;
104 count = size;
105 }
106 94
107 /* Read NVRAM data from cache. */ 95 /* Read NVRAM data from cache. */
108 memcpy(buf, &nvram_cache[off], count); 96 return memory_read_from_buffer(buf, count, &off, ha->nvram,
109 97 ha->nvram_size);
110 return count;
111} 98}
112 99
113static ssize_t 100static ssize_t
@@ -175,14 +162,9 @@ qla2x00_sysfs_read_optrom(struct kobject *kobj,
175 162
176 if (ha->optrom_state != QLA_SREADING) 163 if (ha->optrom_state != QLA_SREADING)
177 return 0; 164 return 0;
178 if (off > ha->optrom_region_size)
179 return 0;
180 if (off + count > ha->optrom_region_size)
181 count = ha->optrom_region_size - off;
182 165
183 memcpy(buf, &ha->optrom_buffer[off], count); 166 return memory_read_from_buffer(buf, count, &off, ha->optrom_buffer,
184 167 ha->optrom_region_size);
185 return count;
186} 168}
187 169
188static ssize_t 170static ssize_t
@@ -374,20 +356,12 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj,
374{ 356{
375 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj, 357 struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
376 struct device, kobj))); 358 struct device, kobj)));
377 int size = ha->vpd_size;
378 char *vpd_cache = ha->vpd;
379 359
380 if (!capable(CAP_SYS_ADMIN) || off > size || count == 0) 360 if (!capable(CAP_SYS_ADMIN))
381 return 0; 361 return 0;
382 if (off + count > size) {
383 size -= off;
384 count = size;
385 }
386 362
387 /* Read NVRAM data from cache. */ 363 /* Read NVRAM data from cache. */
388 memcpy(buf, &vpd_cache[off], count); 364 return memory_read_from_buffer(buf, count, &off, ha->vpd, ha->vpd_size);
389
390 return count;
391} 365}
392 366
393static ssize_t 367static ssize_t