# \[PATCH 08/30\] compat: Use COMPAT\_USE\_64BIT\_TIME in the lp driver

- From: H. Peter Anvin \<hpa@zytor.com\>
- Date: 2012-02-20 00:12:41 
- List: linux-arch
- Page: https://ratatoskr.run/linux-arch/2012/02/3824376
- Thread: https://ratatoskr.run/linux-arch/2012/02/3824368/t.md

```text
From: "H. J. Lu" <redacted>

Enable the lp driver to be used with a compat ABI with 64-bit time.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <redacted>
---
 drivers/char/lp.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index f434856..a111ff2 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -706,18 +706,26 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
 {
 	unsigned int minor;
 	struct timeval par_timeout;
-	struct compat_timeval __user *tc;
 	int ret;
 
 	minor = iminor(file->f_path.dentry->d_inode);
 	mutex_lock(&lp_mutex);
 	switch (cmd) {
 	case LPSETTIMEOUT:
-		tc = compat_ptr(arg);
-		if (get_user(par_timeout.tv_sec, &tc->tv_sec) ||
-		    get_user(par_timeout.tv_usec, &tc->tv_usec)) {
-			ret = -EFAULT;
-			break;
+		if (COMPAT_USE_64BIT_TIME) {
+			if (copy_from_user(&par_timeout, (void __user *)arg,
+						sizeof (struct timeval))) {
+				ret = -EFAULT;
+				break;
+			}
+		} else {
+			struct compat_timeval __user *tc;
+			tc = compat_ptr(arg);
+			if (get_user(par_timeout.tv_sec, &tc->tv_sec) ||
+			    get_user(par_timeout.tv_usec, &tc->tv_usec)) {
+				ret = -EFAULT;
+				break;
+			}
 		}
 		ret = lp_set_timeout(minor, &par_timeout);
 		break;
-- 
1.7.6.5
```
