From: Akinobu Mita Date: Fri, 25 Jul 2008 08:48:23 +0000 (-0700) Subject: firmware: use memory_read_from_buffer() X-Git-Tag: v2.6.27-rc1~288 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f37e66173e0cc09b4e5a89eb0294abbefc15f435;p=linux-2.6 firmware: use memory_read_from_buffer() Signed-off-by: Akinobu Mita Cc: Greg Kroah-Hartman Cc: Markus Rechberger Cc: Kay Sievers Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index b0be1d18fe..c9c92b00fd 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, 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; @@ -192,14 +192,8 @@ firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, 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;