mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 13:49:24 -04:00
utags: add kernel version independent read call
Function kernel_read prototype is different in kernel 4.9 and 4.14. Adding conversion function based on LINUX_VERSION_CODE Change-Id: Ic993ae91ddbc4db4608822009954208923abe205 Signed-off-by: Konstantin Makariev <hcv867@motorola.com> Reviewed-on: https://gerrit.mot.com/1194418 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Konstantin Makariev <kmakariev@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
27e46b7985
commit
20934360c1
1 changed files with 16 additions and 2 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include <linux/sched.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#define MAX_UTAG_SIZE 1024
|
||||
#define MAX_UTAG_NAME 32
|
||||
|
|
@ -143,6 +144,19 @@ struct ctrl {
|
|||
struct utag *head;
|
||||
};
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
|
||||
static inline ssize_t kernel_read_stub(struct file *file, void *addr, size_t count)
|
||||
{
|
||||
loff_t pos = 0;
|
||||
return kernel_read(file, addr, count, &pos);
|
||||
}
|
||||
#else
|
||||
static inline ssize_t kernel_read_stub(struct file *file, void *addr, size_t count)
|
||||
{
|
||||
return kernel_read(file, 0, addr, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int build_utags_directory(struct ctrl *ctrl);
|
||||
static void clear_utags_directory(struct ctrl *ctrl);
|
||||
|
||||
|
|
@ -220,7 +234,7 @@ static int read_head(struct blkdev *cb, struct utag *htag)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
bytes = kernel_read(cb->filep, 0, (void *) &buf, UTAG_MIN_TAG_SIZE);
|
||||
bytes = kernel_read_stub(cb->filep, (void *) &buf, UTAG_MIN_TAG_SIZE);
|
||||
if ((int) UTAG_MIN_TAG_SIZE > bytes) {
|
||||
pr_err("ERR file (%s) read failed ret %d\n", cb->name, bytes);
|
||||
return -EIO;
|
||||
|
|
@ -912,7 +926,7 @@ static struct utag *load_utags(struct blkdev *cb)
|
|||
if (!data)
|
||||
return NULL;
|
||||
|
||||
ret_bytes = kernel_read(cb->filep, 0, data, bytes);
|
||||
ret_bytes = kernel_read_stub(cb->filep, data, bytes);
|
||||
if (bytes != ret_bytes) {
|
||||
pr_err("(%s) read failed ret %d\n", cb->name, ret_bytes);
|
||||
goto free_data;
|
||||
|
|
|
|||
Loading…
Reference in a new issue