| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* $Id: plip.c,v 1.3.6.2 1997/04/16 15:07:56 phil Exp $ */ |
|---|
| 2 | 3 | /* PLIP: A parallel port "network" driver for Linux. */ |
|---|
| 3 | 4 | /* This driver is for parallel port with 5-bit cable (LapLink (R) cable). */ |
|---|
| .. | .. |
|---|
| 29 | 30 | * Al Viro |
|---|
| 30 | 31 | * - Changed {enable,disable}_irq handling to make it work |
|---|
| 31 | 32 | * 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. |
|---|
| 37 | 33 | */ |
|---|
| 38 | 34 | |
|---|
| 39 | 35 | /* |
|---|
| .. | .. |
|---|
| 146 | 142 | static void plip_interrupt(void *dev_id); |
|---|
| 147 | 143 | |
|---|
| 148 | 144 | /* 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); |
|---|
| 150 | 146 | static int plip_hard_header(struct sk_buff *skb, struct net_device *dev, |
|---|
| 151 | 147 | unsigned short type, const void *daddr, |
|---|
| 152 | 148 | const void *saddr, unsigned len); |
|---|
| .. | .. |
|---|
| 448 | 444 | } |
|---|
| 449 | 445 | rcv->state = PLIP_PK_DONE; |
|---|
| 450 | 446 | if (rcv->skb) { |
|---|
| 451 | | - kfree_skb(rcv->skb); |
|---|
| 447 | + dev_kfree_skb_irq(rcv->skb); |
|---|
| 452 | 448 | rcv->skb = NULL; |
|---|
| 453 | 449 | } |
|---|
| 454 | 450 | snd->state = PLIP_PK_DONE; |
|---|
| 455 | 451 | if (snd->skb) { |
|---|
| 456 | | - dev_kfree_skb(snd->skb); |
|---|
| 452 | + dev_consume_skb_irq(snd->skb); |
|---|
| 457 | 453 | snd->skb = NULL; |
|---|
| 458 | 454 | } |
|---|
| 459 | 455 | spin_unlock_irq(&nl->lock); |
|---|
| .. | .. |
|---|
| 502 | 498 | *data_p = (c0 >> 3) & 0x0f; |
|---|
| 503 | 499 | write_data (dev, 0x10); /* send ACK */ |
|---|
| 504 | 500 | *ns_p = PLIP_NB_1; |
|---|
| 505 | | - /* fall through */ |
|---|
| 501 | + fallthrough; |
|---|
| 506 | 502 | |
|---|
| 507 | 503 | case PLIP_NB_1: |
|---|
| 508 | 504 | cx = nibble_timeout; |
|---|
| .. | .. |
|---|
| 598 | 594 | printk(KERN_DEBUG "%s: receive start\n", dev->name); |
|---|
| 599 | 595 | rcv->state = PLIP_PK_LENGTH_LSB; |
|---|
| 600 | 596 | rcv->nibble = PLIP_NB_BEGIN; |
|---|
| 601 | | - /* fall through */ |
|---|
| 597 | + fallthrough; |
|---|
| 602 | 598 | |
|---|
| 603 | 599 | case PLIP_PK_LENGTH_LSB: |
|---|
| 604 | 600 | if (snd->state != PLIP_PK_DONE) { |
|---|
| .. | .. |
|---|
| 619 | 615 | return TIMEOUT; |
|---|
| 620 | 616 | } |
|---|
| 621 | 617 | rcv->state = PLIP_PK_LENGTH_MSB; |
|---|
| 622 | | - /* fall through */ |
|---|
| 618 | + fallthrough; |
|---|
| 623 | 619 | |
|---|
| 624 | 620 | case PLIP_PK_LENGTH_MSB: |
|---|
| 625 | 621 | if (plip_receive(nibble_timeout, dev, |
|---|
| .. | .. |
|---|
| 642 | 638 | rcv->state = PLIP_PK_DATA; |
|---|
| 643 | 639 | rcv->byte = 0; |
|---|
| 644 | 640 | rcv->checksum = 0; |
|---|
| 645 | | - /* fall through */ |
|---|
| 641 | + fallthrough; |
|---|
| 646 | 642 | |
|---|
| 647 | 643 | case PLIP_PK_DATA: |
|---|
| 648 | 644 | lbuf = rcv->skb->data; |
|---|
| .. | .. |
|---|
| 655 | 651 | rcv->checksum += lbuf[--rcv->byte]; |
|---|
| 656 | 652 | } while (rcv->byte); |
|---|
| 657 | 653 | rcv->state = PLIP_PK_CHECKSUM; |
|---|
| 658 | | - /* fall through */ |
|---|
| 654 | + fallthrough; |
|---|
| 659 | 655 | |
|---|
| 660 | 656 | case PLIP_PK_CHECKSUM: |
|---|
| 661 | 657 | if (plip_receive(nibble_timeout, dev, |
|---|
| .. | .. |
|---|
| 668 | 664 | return ERROR; |
|---|
| 669 | 665 | } |
|---|
| 670 | 666 | rcv->state = PLIP_PK_DONE; |
|---|
| 671 | | - /* fall through */ |
|---|
| 667 | + fallthrough; |
|---|
| 672 | 668 | |
|---|
| 673 | 669 | case PLIP_PK_DONE: |
|---|
| 674 | 670 | /* Inform the upper layer for the arrival of a packet. */ |
|---|
| .. | .. |
|---|
| 714 | 710 | case PLIP_NB_BEGIN: |
|---|
| 715 | 711 | write_data (dev, data & 0x0f); |
|---|
| 716 | 712 | *ns_p = PLIP_NB_1; |
|---|
| 717 | | - /* fall through */ |
|---|
| 713 | + fallthrough; |
|---|
| 718 | 714 | |
|---|
| 719 | 715 | case PLIP_NB_1: |
|---|
| 720 | 716 | write_data (dev, 0x10 | (data & 0x0f)); |
|---|
| .. | .. |
|---|
| 729 | 725 | } |
|---|
| 730 | 726 | write_data (dev, 0x10 | (data >> 4)); |
|---|
| 731 | 727 | *ns_p = PLIP_NB_2; |
|---|
| 732 | | - /* fall through */ |
|---|
| 728 | + fallthrough; |
|---|
| 733 | 729 | |
|---|
| 734 | 730 | case PLIP_NB_2: |
|---|
| 735 | 731 | write_data (dev, (data >> 4)); |
|---|
| .. | .. |
|---|
| 818 | 814 | &snd->nibble, snd->length.b.lsb)) |
|---|
| 819 | 815 | return TIMEOUT; |
|---|
| 820 | 816 | snd->state = PLIP_PK_LENGTH_MSB; |
|---|
| 821 | | - /* fall through */ |
|---|
| 817 | + fallthrough; |
|---|
| 822 | 818 | |
|---|
| 823 | 819 | case PLIP_PK_LENGTH_MSB: |
|---|
| 824 | 820 | if (plip_send(nibble_timeout, dev, |
|---|
| .. | .. |
|---|
| 827 | 823 | snd->state = PLIP_PK_DATA; |
|---|
| 828 | 824 | snd->byte = 0; |
|---|
| 829 | 825 | snd->checksum = 0; |
|---|
| 830 | | - /* fall through */ |
|---|
| 826 | + fallthrough; |
|---|
| 831 | 827 | |
|---|
| 832 | 828 | case PLIP_PK_DATA: |
|---|
| 833 | 829 | do { |
|---|
| .. | .. |
|---|
| 839 | 835 | snd->checksum += lbuf[--snd->byte]; |
|---|
| 840 | 836 | } while (snd->byte); |
|---|
| 841 | 837 | snd->state = PLIP_PK_CHECKSUM; |
|---|
| 842 | | - /* fall through */ |
|---|
| 838 | + fallthrough; |
|---|
| 843 | 839 | |
|---|
| 844 | 840 | case PLIP_PK_CHECKSUM: |
|---|
| 845 | 841 | if (plip_send(nibble_timeout, dev, |
|---|
| .. | .. |
|---|
| 850 | 846 | dev_kfree_skb(snd->skb); |
|---|
| 851 | 847 | dev->stats.tx_packets++; |
|---|
| 852 | 848 | snd->state = PLIP_PK_DONE; |
|---|
| 853 | | - /* fall through */ |
|---|
| 849 | + fallthrough; |
|---|
| 854 | 850 | |
|---|
| 855 | 851 | case PLIP_PK_DONE: |
|---|
| 856 | 852 | /* Close the connection */ |
|---|
| .. | .. |
|---|
| 939 | 935 | switch (nl->connection) { |
|---|
| 940 | 936 | case PLIP_CN_CLOSING: |
|---|
| 941 | 937 | netif_wake_queue (dev); |
|---|
| 942 | | - /* fall through */ |
|---|
| 938 | + fallthrough; |
|---|
| 943 | 939 | case PLIP_CN_NONE: |
|---|
| 944 | 940 | case PLIP_CN_SEND: |
|---|
| 945 | 941 | rcv->state = PLIP_PK_TRIGGER; |
|---|
| .. | .. |
|---|
| 962 | 958 | spin_unlock_irqrestore(&nl->lock, flags); |
|---|
| 963 | 959 | } |
|---|
| 964 | 960 | |
|---|
| 965 | | -static int |
|---|
| 961 | +static netdev_tx_t |
|---|
| 966 | 962 | plip_tx_packet(struct sk_buff *skb, struct net_device *dev) |
|---|
| 967 | 963 | { |
|---|
| 968 | 964 | struct net_local *nl = netdev_priv(dev); |
|---|
| .. | .. |
|---|
| 1012 | 1008 | in_dev = __in_dev_get_rcu(dev); |
|---|
| 1013 | 1009 | if (in_dev) { |
|---|
| 1014 | 1010 | /* 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); |
|---|
| 1016 | 1012 | if (ifa) { |
|---|
| 1017 | 1013 | memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); |
|---|
| 1018 | 1014 | memset(eth->h_dest, 0xfc, 2); |
|---|
| .. | .. |
|---|
| 1107 | 1103 | /* Any address will do - we take the first. We already |
|---|
| 1108 | 1104 | have the first two bytes filled with 0xfc, from |
|---|
| 1109 | 1105 | plip_init_dev(). */ |
|---|
| 1110 | | - struct in_ifaddr *ifa=in_dev->ifa_list; |
|---|
| 1106 | + const struct in_ifaddr *ifa = rtnl_dereference(in_dev->ifa_list); |
|---|
| 1111 | 1107 | if (ifa != NULL) { |
|---|
| 1112 | 1108 | memcpy(dev->dev_addr+2, &ifa->ifa_local, 4); |
|---|
| 1113 | 1109 | } |
|---|