Skip to content

Commit

Permalink
firmware: use memory_read_from_buffer()
Browse files Browse the repository at this point in the history
Signed-off-by: Akinobu Mita <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Markus Rechberger <[email protected]>
Cc: Kay Sievers <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Jul 25, 2008
1 parent ec905a1 commit f37e661
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions drivers/base/firmware_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,16 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr,
struct device *dev = to_dev(kobj);
struct firmware_priv *fw_priv = dev_get_drvdata(dev);
struct firmware *fw;
ssize_t ret_count = count;
ssize_t ret_count;

mutex_lock(&fw_lock);
fw = fw_priv->fw;
if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) {
ret_count = -ENODEV;
goto out;
}
if (offset > fw->size) {
ret_count = 0;
goto out;
}
if (offset + ret_count > fw->size)
ret_count = fw->size - offset;

memcpy(buffer, fw->data + offset, ret_count);
ret_count = memory_read_from_buffer(buffer, count, &offset,
fw->data, fw->size);
out:
mutex_unlock(&fw_lock);
return ret_count;
Expand Down

0 comments on commit f37e661

Please sign in to comment.