aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2008-07-25 04:48:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:44 -0400
commitf37e66173e0cc09b4e5a89eb0294abbefc15f435 (patch)
treea96d0e759aca8ad9edeff0620765d99ed24d632f /drivers
parentec905a18656daa4d9300bad2bebc02d5dba7883d (diff)
firmware: use memory_read_from_buffer()
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Greg Kroah-Hartman <gregkh@suse.de> Cc: Markus Rechberger <markus.rechberger@amd.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/firmware_class.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index b0be1d18fee2..c9c92b00fd55 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -184,7 +184,7 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
184 struct device *dev = to_dev(kobj); 184 struct device *dev = to_dev(kobj);
185 struct firmware_priv *fw_priv = dev_get_drvdata(dev); 185 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
186 struct firmware *fw; 186 struct firmware *fw;
187 ssize_t ret_count = count; 187 ssize_t ret_count;
188 188
189 mutex_lock(&fw_lock); 189 mutex_lock(&fw_lock);
190 fw = fw_priv->fw; 190 fw = fw_priv->fw;
@@ -192,14 +192,8 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
192 ret_count = -ENODEV; 192 ret_count = -ENODEV;
193 goto out; 193 goto out;
194 } 194 }
195 if (offset > fw->size) { 195 ret_count = memory_read_from_buffer(buffer, count, &offset,
196 ret_count = 0; 196 fw->data, fw->size);
197 goto out;
198 }
199 if (offset + ret_count > fw->size)
200 ret_count = fw->size - offset;
201
202 memcpy(buffer, fw->data + offset, ret_count);
203out: 197out:
204 mutex_unlock(&fw_lock); 198 mutex_unlock(&fw_lock);
205 return ret_count; 199 return ret_count;