forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/net/plip/plip.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* $Id: plip.c,v 1.3.6.2 1997/04/16 15:07:56 phil Exp $ */
23 /* PLIP: A parallel port "network" driver for Linux. */
34 /* This driver is for parallel port with 5-bit cable (LapLink (R) cable). */
....@@ -29,11 +30,6 @@
2930 * Al Viro
3031 * - Changed {enable,disable}_irq handling to make it work
3132 * with new ("stack") semantics.
32
- *
33
- * This program is free software; you can redistribute it and/or
34
- * modify it under the terms of the GNU General Public License
35
- * as published by the Free Software Foundation; either version
36
- * 2 of the License, or (at your option) any later version.
3733 */
3834
3935 /*
....@@ -146,7 +142,7 @@
146142 static void plip_interrupt(void *dev_id);
147143
148144 /* Functions for DEV methods */
149
-static int plip_tx_packet(struct sk_buff *skb, struct net_device *dev);
145
+static netdev_tx_t plip_tx_packet(struct sk_buff *skb, struct net_device *dev);
150146 static int plip_hard_header(struct sk_buff *skb, struct net_device *dev,
151147 unsigned short type, const void *daddr,
152148 const void *saddr, unsigned len);
....@@ -448,12 +444,12 @@
448444 }
449445 rcv->state = PLIP_PK_DONE;
450446 if (rcv->skb) {
451
- kfree_skb(rcv->skb);
447
+ dev_kfree_skb_irq(rcv->skb);
452448 rcv->skb = NULL;
453449 }
454450 snd->state = PLIP_PK_DONE;
455451 if (snd->skb) {
456
- dev_kfree_skb(snd->skb);
452
+ dev_consume_skb_irq(snd->skb);
457453 snd->skb = NULL;
458454 }
459455 spin_unlock_irq(&nl->lock);
....@@ -502,7 +498,7 @@
502498 *data_p = (c0 >> 3) & 0x0f;
503499 write_data (dev, 0x10); /* send ACK */
504500 *ns_p = PLIP_NB_1;
505
- /* fall through */
501
+ fallthrough;
506502
507503 case PLIP_NB_1:
508504 cx = nibble_timeout;
....@@ -598,7 +594,7 @@
598594 printk(KERN_DEBUG "%s: receive start\n", dev->name);
599595 rcv->state = PLIP_PK_LENGTH_LSB;
600596 rcv->nibble = PLIP_NB_BEGIN;
601
- /* fall through */
597
+ fallthrough;
602598
603599 case PLIP_PK_LENGTH_LSB:
604600 if (snd->state != PLIP_PK_DONE) {
....@@ -619,7 +615,7 @@
619615 return TIMEOUT;
620616 }
621617 rcv->state = PLIP_PK_LENGTH_MSB;
622
- /* fall through */
618
+ fallthrough;
623619
624620 case PLIP_PK_LENGTH_MSB:
625621 if (plip_receive(nibble_timeout, dev,
....@@ -642,7 +638,7 @@
642638 rcv->state = PLIP_PK_DATA;
643639 rcv->byte = 0;
644640 rcv->checksum = 0;
645
- /* fall through */
641
+ fallthrough;
646642
647643 case PLIP_PK_DATA:
648644 lbuf = rcv->skb->data;
....@@ -655,7 +651,7 @@
655651 rcv->checksum += lbuf[--rcv->byte];
656652 } while (rcv->byte);
657653 rcv->state = PLIP_PK_CHECKSUM;
658
- /* fall through */
654
+ fallthrough;
659655
660656 case PLIP_PK_CHECKSUM:
661657 if (plip_receive(nibble_timeout, dev,
....@@ -668,7 +664,7 @@
668664 return ERROR;
669665 }
670666 rcv->state = PLIP_PK_DONE;
671
- /* fall through */
667
+ fallthrough;
672668
673669 case PLIP_PK_DONE:
674670 /* Inform the upper layer for the arrival of a packet. */
....@@ -714,7 +710,7 @@
714710 case PLIP_NB_BEGIN:
715711 write_data (dev, data & 0x0f);
716712 *ns_p = PLIP_NB_1;
717
- /* fall through */
713
+ fallthrough;
718714
719715 case PLIP_NB_1:
720716 write_data (dev, 0x10 | (data & 0x0f));
....@@ -729,7 +725,7 @@
729725 }
730726 write_data (dev, 0x10 | (data >> 4));
731727 *ns_p = PLIP_NB_2;
732
- /* fall through */
728
+ fallthrough;
733729
734730 case PLIP_NB_2:
735731 write_data (dev, (data >> 4));
....@@ -818,7 +814,7 @@
818814 &snd->nibble, snd->length.b.lsb))
819815 return TIMEOUT;
820816 snd->state = PLIP_PK_LENGTH_MSB;
821
- /* fall through */
817
+ fallthrough;
822818
823819 case PLIP_PK_LENGTH_MSB:
824820 if (plip_send(nibble_timeout, dev,
....@@ -827,7 +823,7 @@
827823 snd->state = PLIP_PK_DATA;
828824 snd->byte = 0;
829825 snd->checksum = 0;
830
- /* fall through */
826
+ fallthrough;
831827
832828 case PLIP_PK_DATA:
833829 do {
....@@ -839,7 +835,7 @@
839835 snd->checksum += lbuf[--snd->byte];
840836 } while (snd->byte);
841837 snd->state = PLIP_PK_CHECKSUM;
842
- /* fall through */
838
+ fallthrough;
843839
844840 case PLIP_PK_CHECKSUM:
845841 if (plip_send(nibble_timeout, dev,
....@@ -850,7 +846,7 @@
850846 dev_kfree_skb(snd->skb);
851847 dev->stats.tx_packets++;
852848 snd->state = PLIP_PK_DONE;
853
- /* fall through */
849
+ fallthrough;
854850
855851 case PLIP_PK_DONE:
856852 /* Close the connection */
....@@ -939,7 +935,7 @@
939935 switch (nl->connection) {
940936 case PLIP_CN_CLOSING:
941937 netif_wake_queue (dev);
942
- /* fall through */
938
+ fallthrough;
943939 case PLIP_CN_NONE:
944940 case PLIP_CN_SEND:
945941 rcv->state = PLIP_PK_TRIGGER;
....@@ -962,7 +958,7 @@
962958 spin_unlock_irqrestore(&nl->lock, flags);
963959 }
964960
965
-static int
961
+static netdev_tx_t
966962 plip_tx_packet(struct sk_buff *skb, struct net_device *dev)
967963 {
968964 struct net_local *nl = netdev_priv(dev);
....@@ -1012,7 +1008,7 @@
10121008 in_dev = __in_dev_get_rcu(dev);
10131009 if (in_dev) {
10141010 /* Any address will do - we take the first */
1015
- const struct in_ifaddr *ifa = in_dev->ifa_list;
1011
+ const struct in_ifaddr *ifa = rcu_dereference(in_dev->ifa_list);
10161012 if (ifa) {
10171013 memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
10181014 memset(eth->h_dest, 0xfc, 2);
....@@ -1107,7 +1103,7 @@
11071103 /* Any address will do - we take the first. We already
11081104 have the first two bytes filled with 0xfc, from
11091105 plip_init_dev(). */
1110
- struct in_ifaddr *ifa=in_dev->ifa_list;
1106
+ const struct in_ifaddr *ifa = rtnl_dereference(in_dev->ifa_list);
11111107 if (ifa != NULL) {
11121108 memcpy(dev->dev_addr+2, &ifa->ifa_local, 4);
11131109 }