hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/char/ppdev.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * linux/drivers/char/ppdev.c
34 *
....@@ -5,11 +6,6 @@
56 * application to use the parport subsystem.
67 *
78 * Copyright (C) 1998-2000, 2002 Tim Waugh <tim@cyberelk.net>
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU General Public License
11
- * as published by the Free Software Foundation; either version
12
- * 2 of the License, or (at your option) any later version.
139 *
1410 * A /dev/parportx device node represents an arbitrary device
1511 * on port 'x'. The following operations are possible:
....@@ -359,14 +355,19 @@
359355 struct pp_struct *pp = file->private_data;
360356 struct parport *port;
361357 void __user *argp = (void __user *)arg;
358
+ struct ieee1284_info *info;
359
+ unsigned char reg;
360
+ unsigned char mask;
361
+ int mode;
362
+ s32 time32[2];
363
+ s64 time64[2];
364
+ struct timespec64 ts;
365
+ int ret;
362366
363367 /* First handle the cases that don't take arguments. */
364368 switch (cmd) {
365369 case PPCLAIM:
366370 {
367
- struct ieee1284_info *info;
368
- int ret;
369
-
370371 if (pp->flags & PP_CLAIMED) {
371372 dev_dbg(&pp->pdev->dev, "you've already got it!\n");
372373 return -EINVAL;
....@@ -517,15 +518,6 @@
517518
518519 port = pp->pdev->port;
519520 switch (cmd) {
520
- struct ieee1284_info *info;
521
- unsigned char reg;
522
- unsigned char mask;
523
- int mode;
524
- s32 time32[2];
525
- s64 time64[2];
526
- struct timespec64 ts;
527
- int ret;
528
-
529521 case PPRSTATUS:
530522 reg = parport_read_status(port);
531523 if (copy_to_user(argp, &reg, sizeof(reg)))
....@@ -682,14 +674,6 @@
682674 return ret;
683675 }
684676
685
-#ifdef CONFIG_COMPAT
686
-static long pp_compat_ioctl(struct file *file, unsigned int cmd,
687
- unsigned long arg)
688
-{
689
- return pp_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
690
-}
691
-#endif
692
-
693677 static int pp_open(struct inode *inode, struct file *file)
694678 {
695679 unsigned int minor = iminor(inode);
....@@ -749,7 +733,7 @@
749733 "negotiated back to compatibility mode because user-space forgot\n");
750734 }
751735
752
- if (pp->flags & PP_CLAIMED) {
736
+ if ((pp->flags & PP_CLAIMED) && pp->pdev) {
753737 struct ieee1284_info *info;
754738
755739 info = &pp->pdev->port->ieee1284;
....@@ -798,9 +782,7 @@
798782 .write = pp_write,
799783 .poll = pp_poll,
800784 .unlocked_ioctl = pp_ioctl,
801
-#ifdef CONFIG_COMPAT
802
- .compat_ioctl = pp_compat_ioctl,
803
-#endif
785
+ .compat_ioctl = compat_ptr_ioctl,
804786 .open = pp_open,
805787 .release = pp_release,
806788 };