hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/drivers/net/hamradio/mkiss.c
....@@ -1,15 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
2
- * This program is free software; you can distribute it and/or modify it
3
- * under the terms of the GNU General Public License (Version 2) as
4
- * published by the Free Software Foundation.
5
- *
6
- * This program is distributed in the hope it will be useful, but WITHOUT
7
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9
- * for more details.
10
- *
11
- * You should have received a copy of the GNU General Public License along
12
- * with this program; if not, see <http://www.gnu.org/licenses/>.
133 *
144 * Copyright (C) Hans Alblas PE1AYX <hans@esrac.ele.tue.nl>
155 * Copyright (C) 2004, 05 Ralf Baechle DL5RB <ralf@linux-mips.org>
....@@ -35,12 +25,14 @@
3525 #include <linux/skbuff.h>
3626 #include <linux/if_arp.h>
3727 #include <linux/jiffies.h>
38
-#include <linux/compat.h>
28
+#include <linux/refcount.h>
3929
4030 #include <net/ax25.h>
4131
4232 #define AX_MTU 236
4333
34
+/* some arch define END as assembly function ending, just undef it */
35
+#undef END
4436 /* SLIP/KISS protocol characters. */
4537 #define END 0300 /* indicates end of frame */
4638 #define ESC 0333 /* indicates byte stuffing */
....@@ -81,8 +73,8 @@
8173 #define CRC_MODE_FLEX_TEST 3
8274 #define CRC_MODE_SMACK_TEST 4
8375
84
- atomic_t refcnt;
85
- struct semaphore dead_sem;
76
+ refcount_t refcnt;
77
+ struct completion dead;
8678 };
8779
8880 /*---------------------------------------------------------------------------*/
....@@ -492,7 +484,7 @@
492484 case CRC_MODE_SMACK_TEST:
493485 ax->crcmode = CRC_MODE_FLEX_TEST;
494486 printk(KERN_INFO "mkiss: %s: Trying crc-smack\n", ax->dev->name);
495
- // fall through
487
+ fallthrough;
496488 case CRC_MODE_SMACK:
497489 *p |= 0x80;
498490 crc = swab16(crc16(0, p, len));
....@@ -501,7 +493,7 @@
501493 case CRC_MODE_FLEX_TEST:
502494 ax->crcmode = CRC_MODE_NONE;
503495 printk(KERN_INFO "mkiss: %s: Trying crc-flexnet\n", ax->dev->name);
504
- // fall through
496
+ fallthrough;
505497 case CRC_MODE_FLEX:
506498 *p |= 0x20;
507499 crc = calc_crc_flex(p, len);
....@@ -679,7 +671,7 @@
679671 read_lock(&disc_data_lock);
680672 ax = tty->disc_data;
681673 if (ax)
682
- atomic_inc(&ax->refcnt);
674
+ refcount_inc(&ax->refcnt);
683675 read_unlock(&disc_data_lock);
684676
685677 return ax;
....@@ -687,8 +679,8 @@
687679
688680 static void mkiss_put(struct mkiss *ax)
689681 {
690
- if (atomic_dec_and_test(&ax->refcnt))
691
- up(&ax->dead_sem);
682
+ if (refcount_dec_and_test(&ax->refcnt))
683
+ complete(&ax->dead);
692684 }
693685
694686 static int crc_force = 0; /* Can be overridden with insmod */
....@@ -715,8 +707,8 @@
715707 ax->dev = dev;
716708
717709 spin_lock_init(&ax->buflock);
718
- atomic_set(&ax->refcnt, 1);
719
- sema_init(&ax->dead_sem, 0);
710
+ refcount_set(&ax->refcnt, 1);
711
+ init_completion(&ax->dead);
720712
721713 ax->tty = tty;
722714 tty->disc_data = ax;
....@@ -754,7 +746,6 @@
754746 ax->dev->name);
755747 break;
756748 case 0:
757
- /* fall through */
758749 default:
759750 crc_force = 0;
760751 printk(KERN_INFO "mkiss: %s: crc mode is auto.\n",
....@@ -795,8 +786,8 @@
795786 * We have now ensured that nobody can start using ap from now on, but
796787 * we have to wait for all existing users to finish.
797788 */
798
- if (!atomic_dec_and_test(&ax->refcnt))
799
- down(&ax->dead_sem);
789
+ if (!refcount_dec_and_test(&ax->refcnt))
790
+ wait_for_completion(&ax->dead);
800791 /*
801792 * Halt the transmit queue so that a new transmit cannot scribble
802793 * on our buffers
....@@ -877,23 +868,6 @@
877868 return err;
878869 }
879870
880
-#ifdef CONFIG_COMPAT
881
-static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
882
- unsigned int cmd, unsigned long arg)
883
-{
884
- switch (cmd) {
885
- case SIOCGIFNAME:
886
- case SIOCGIFENCAP:
887
- case SIOCSIFENCAP:
888
- case SIOCSIFHWADDR:
889
- return mkiss_ioctl(tty, file, cmd,
890
- (unsigned long)compat_ptr(arg));
891
- }
892
-
893
- return -ENOIOCTLCMD;
894
-}
895
-#endif
896
-
897871 /*
898872 * Handle the 'receiver data ready' interrupt.
899873 * This function is called by the 'tty_io' module in the kernel when
....@@ -968,9 +942,6 @@
968942 .open = mkiss_open,
969943 .close = mkiss_close,
970944 .ioctl = mkiss_ioctl,
971
-#ifdef CONFIG_COMPAT
972
- .compat_ioctl = mkiss_compat_ioctl,
973
-#endif
974945 .receive_buf = mkiss_receive_buf,
975946 .write_wakeup = mkiss_write_wakeup
976947 };