[patch -v2 15/23] dell_rbu: use memory_read_from_buffer

From: akinobu . mita
Date: Sun Jun 01 2008 - 19:32:44 EST


Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
Cc: Abhay Salunke <abhay_salunke@xxxxxxxx>
---
drivers/firmware/dell_rbu.c | 29 ++++-------------------------
1 file changed, 4 insertions(+), 25 deletions(-)

Index: 2.6-git/drivers/firmware/dell_rbu.c
===================================================================
--- 2.6-git.orig/drivers/firmware/dell_rbu.c
+++ 2.6-git/drivers/firmware/dell_rbu.c
@@ -44,6 +44,7 @@
#include <linux/moduleparam.h>
#include <linux/firmware.h>
#include <linux/dma-mapping.h>
+#include <linux/fs.h>

MODULE_AUTHOR("Abhay Salunke <abhay_salunke@xxxxxxxx>");
MODULE_DESCRIPTION("Driver for updating BIOS image on DELL systems");
@@ -507,11 +508,6 @@ static ssize_t read_packet_data(char *bu

static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count)
{
- unsigned char *ptemp = NULL;
- size_t bytes_left = 0;
- size_t data_length = 0;
- ssize_t ret_count = 0;
-
/* check to see if we have something to return */
if ((rbu_data.image_update_buffer == NULL) ||
(rbu_data.bios_image_size == 0)) {
@@ -519,28 +515,11 @@ static ssize_t read_rbu_mono_data(char *
"bios_image_size %lu\n",
rbu_data.image_update_buffer,
rbu_data.bios_image_size);
- ret_count = -ENOMEM;
- goto read_rbu_data_exit;
- }
-
- if (pos > rbu_data.bios_image_size) {
- ret_count = 0;
- goto read_rbu_data_exit;
+ return -ENOMEM;
}

- bytes_left = rbu_data.bios_image_size - pos;
- data_length = min(bytes_left, count);
-
- ptemp = rbu_data.image_update_buffer;
- memcpy(buffer, (ptemp + pos), data_length);
-
- if ((pos + count) > rbu_data.bios_image_size)
- /* this was the last copy */
- ret_count = bytes_left;
- else
- ret_count = count;
- read_rbu_data_exit:
- return ret_count;
+ return memory_read_from_buffer(buffer, count, &pos,
+ rbu_data.image_update_buffer, rbu_data.bios_image_size);
}

static ssize_t read_rbu_data(struct kobject *kobj,

--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/