From b5a4e03b9fb6ef15f940f7aaffb1add936a860dd Mon Sep 17 00:00:00 2001 From: Ningkai Zhuang Date: Thu, 23 Jul 2020 15:40:15 +0800 Subject: [PATCH] fix ST NFC driver compile error Some API changed with Kernel 5.4 version fix ST NFC driver compile error on Kernel 5.4 Change-Id: I1be44a5405907e4d2abdf26c2723302b3063ec29 Signed-off-by: Ningkai Zhuang Reviewed-on: https://gerrit.mot.com/1702766 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Zishang Zhou Reviewed-by: Tao Sun Submit-Approved: Jira Key --- drivers/nfc/st21nfc/st21nfc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/nfc/st21nfc/st21nfc.c b/drivers/nfc/st21nfc/st21nfc.c index 5682b0b45ac3..090a755a208b 100644 --- a/drivers/nfc/st21nfc/st21nfc.c +++ b/drivers/nfc/st21nfc/st21nfc.c @@ -384,11 +384,19 @@ static long st21nfc_dev_ioctl(struct file *filp, unsigned int cmd, * from the kernel perspective; so they look reversed. */ if (_IOC_DIR(cmd) & _IOC_READ) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) + ret = !access_ok((void __user *)arg, _IOC_SIZE(cmd)); +#else ret = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd)); +#endif if (ret == 0 && _IOC_DIR(cmd) & _IOC_WRITE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) + ret = !access_ok((void __user *)arg, _IOC_SIZE(cmd)); +#else ret = !access_ok(VERIFY_READ, (void __user *)arg, _IOC_SIZE(cmd)); +#endif if (ret) return -EFAULT;