Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dell_rbu: use memory_read_from_buffer()

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Abhay Salunke <Abhay_Salunke@dell.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Matt Domsch <Matt_Domsch@dell.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Akinobu Mita and committed by
Linus Torvalds
25377479 d9916962

+3 -25
+3 -25
drivers/firmware/dell_rbu.c
··· 507 507 508 508 static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) 509 509 { 510 - unsigned char *ptemp = NULL; 511 - size_t bytes_left = 0; 512 - size_t data_length = 0; 513 - ssize_t ret_count = 0; 514 - 515 510 /* check to see if we have something to return */ 516 511 if ((rbu_data.image_update_buffer == NULL) || 517 512 (rbu_data.bios_image_size == 0)) { ··· 514 519 "bios_image_size %lu\n", 515 520 rbu_data.image_update_buffer, 516 521 rbu_data.bios_image_size); 517 - ret_count = -ENOMEM; 518 - goto read_rbu_data_exit; 522 + return -ENOMEM; 519 523 } 520 524 521 - if (pos > rbu_data.bios_image_size) { 522 - ret_count = 0; 523 - goto read_rbu_data_exit; 524 - } 525 - 526 - bytes_left = rbu_data.bios_image_size - pos; 527 - data_length = min(bytes_left, count); 528 - 529 - ptemp = rbu_data.image_update_buffer; 530 - memcpy(buffer, (ptemp + pos), data_length); 531 - 532 - if ((pos + count) > rbu_data.bios_image_size) 533 - /* this was the last copy */ 534 - ret_count = bytes_left; 535 - else 536 - ret_count = count; 537 - read_rbu_data_exit: 538 - return ret_count; 525 + return memory_read_from_buffer(buffer, count, &pos, 526 + rbu_data.image_update_buffer, rbu_data.bios_image_size); 539 527 } 540 528 541 529 static ssize_t read_rbu_data(struct kobject *kobj,