From: Akinobu Mita Date: Fri, 25 Jul 2008 08:48:27 +0000 (-0700) Subject: dell_rbu: use memory_read_from_buffer() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=25377479de7539fdc871a0f0ecaa39da42353bbc;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git dell_rbu: use memory_read_from_buffer() Signed-off-by: Akinobu Mita Cc: Abhay Salunke Cc: Zhang Rui Cc: Matt Domsch Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c index 7430e218cda6..13946ebd77d6 100644 --- a/drivers/firmware/dell_rbu.c +++ b/drivers/firmware/dell_rbu.c @@ -507,11 +507,6 @@ static ssize_t read_packet_data(char *buffer, loff_t pos, size_t count) 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 +514,11 @@ static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) "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,