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>
This commit is contained in:
parent
ec905a1865
commit
f37e66173e
@ -184,7 +184,7 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
|
|||||||
struct device *dev = to_dev(kobj);
|
struct device *dev = to_dev(kobj);
|
||||||
struct firmware_priv *fw_priv = dev_get_drvdata(dev);
|
struct firmware_priv *fw_priv = dev_get_drvdata(dev);
|
||||||
struct firmware *fw;
|
struct firmware *fw;
|
||||||
ssize_t ret_count = count;
|
ssize_t ret_count;
|
||||||
|
|
||||||
mutex_lock(&fw_lock);
|
mutex_lock(&fw_lock);
|
||||||
fw = fw_priv->fw;
|
fw = fw_priv->fw;
|
||||||
@ -192,14 +192,8 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
|
|||||||
ret_count = -ENODEV;
|
ret_count = -ENODEV;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (offset > fw->size) {
|
ret_count = memory_read_from_buffer(buffer, count, &offset,
|
||||||
ret_count = 0;
|
fw->data, fw->size);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (offset + ret_count > fw->size)
|
|
||||||
ret_count = fw->size - offset;
|
|
||||||
|
|
||||||
memcpy(buffer, fw->data + offset, ret_count);
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&fw_lock);
|
mutex_unlock(&fw_lock);
|
||||||
return ret_count;
|
return ret_count;
|
||||||
|
Loading…
Reference in New Issue
Block a user