Skip to content

Commit ce684d9

Browse files
mitagregkh
authored andcommitted
devcoredump: use memory_read_from_buffer
Use memory_read_from_buffer() to simplify devcd_readv(). Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Link: https://lore.kernel.org/r/1564243146-5681-2-git-send-email-akinobu.mita@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://lore.kernel.org/r/20190731100007.32684-1-johannes@sipsolutions.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9c1c5e0 commit ce684d9

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/base/devcoredump.c

+1-10
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,7 @@ static struct class devcd_class = {
164164
static ssize_t devcd_readv(char *buffer, loff_t offset, size_t count,
165165
void *data, size_t datalen)
166166
{
167-
if (offset > datalen)
168-
return -EINVAL;
169-
170-
if (offset + count > datalen)
171-
count = datalen - offset;
172-
173-
if (count)
174-
memcpy(buffer, ((u8 *)data) + offset, count);
175-
176-
return count;
167+
return memory_read_from_buffer(buffer, count, &offset, data, datalen);
177168
}
178169

179170
static void devcd_freev(void *data)

0 commit comments

Comments
 (0)