Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: most: hdm-usb: remove filtering of networking state

In case the networking interface goes down and up again, the USB HDM does
not report the state the MOST networking interface controller is in. This
might lead to nonfunctional network.

Since the networking AIM already takes care of hardware address checking
and tracing it can be removed from the HDM USB, which is what this patch is
doing.

Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andrey Shvetsov and committed by
Greg Kroah-Hartman
f28e6cd3 812b55e5

+33 -73
+33 -73
drivers/staging/most/hdm-usb/hdm_usb.c
··· 97 97 * @cap: channel capabilities 98 98 * @conf: channel configuration 99 99 * @dci: direct communication interface of hardware 100 - * @hw_addr: MAC address of hardware 101 100 * @ep_address: endpoint address table 102 - * @link_stat: link status of hardware 103 101 * @description: device description 104 102 * @suffix: suffix for channel name 105 103 * @channel_lock: synchronize channel access ··· 115 117 struct most_channel_capability *cap; 116 118 struct most_channel_config *conf; 117 119 struct most_dci_obj *dci; 118 - u8 hw_addr[6]; 119 120 u8 *ep_address; 120 - u16 link_stat; 121 121 char description[MAX_STRING_LEN]; 122 122 char suffix[MAX_NUM_ENDPOINTS][MAX_SUFFIX_LEN]; 123 123 spinlock_t channel_lock[MAX_NUM_ENDPOINTS]; /* sync channel access */ ··· 734 738 } 735 739 736 740 /** 737 - * hdm_update_netinfo - retrieve latest networking information 738 - * @mdev: device interface 739 - * 740 - * This triggers the USB vendor requests to read the hardware address and 741 - * the current link status of the attached device. 742 - */ 743 - static int hdm_update_netinfo(struct most_dev *mdev) 744 - { 745 - struct usb_device *usb_device = mdev->usb_device; 746 - struct device *dev = &usb_device->dev; 747 - u16 hi, mi, lo, link; 748 - 749 - if (!is_valid_ether_addr(mdev->hw_addr)) { 750 - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) { 751 - dev_err(dev, "Vendor request \"hw_addr_hi\" failed\n"); 752 - return -EFAULT; 753 - } 754 - 755 - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) { 756 - dev_err(dev, "Vendor request \"hw_addr_mid\" failed\n"); 757 - return -EFAULT; 758 - } 759 - 760 - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) { 761 - dev_err(dev, "Vendor request \"hw_addr_low\" failed\n"); 762 - return -EFAULT; 763 - } 764 - 765 - mutex_lock(&mdev->io_mutex); 766 - mdev->hw_addr[0] = hi >> 8; 767 - mdev->hw_addr[1] = hi; 768 - mdev->hw_addr[2] = mi >> 8; 769 - mdev->hw_addr[3] = mi; 770 - mdev->hw_addr[4] = lo >> 8; 771 - mdev->hw_addr[5] = lo; 772 - mutex_unlock(&mdev->io_mutex); 773 - } 774 - 775 - if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) { 776 - dev_err(dev, "Vendor request \"link status\" failed\n"); 777 - return -EFAULT; 778 - } 779 - 780 - mutex_lock(&mdev->io_mutex); 781 - mdev->link_stat = link; 782 - mutex_unlock(&mdev->io_mutex); 783 - return 0; 784 - } 785 - 786 - /** 787 741 * hdm_request_netinfo - request network information 788 742 * @iface: pointer to interface 789 743 * @channel: channel ID ··· 753 807 } 754 808 755 809 /** 756 - * link_stat_timer_handler - add work to link_stat work queue 810 + * link_stat_timer_handler - schedule work obtaining mac address and link status 757 811 * @data: pointer to USB device instance 758 812 * 759 813 * The handler runs in interrupt context. That's why we need to defer the ··· 769 823 } 770 824 771 825 /** 772 - * wq_netinfo - work queue function 826 + * wq_netinfo - work queue function to deliver latest networking information 773 827 * @wq_obj: object that holds data for our deferred work to do 774 828 * 775 829 * This retrieves the network interface status of the USB INIC 776 - * and compares it with the current status. If the status has 777 - * changed, it updates the status of the core. 778 830 */ 779 831 static void wq_netinfo(struct work_struct *wq_obj) 780 832 { 781 833 struct most_dev *mdev = to_mdev_from_work(wq_obj); 782 - int i, prev_link_stat = mdev->link_stat; 783 - u8 prev_hw_addr[6]; 834 + struct usb_device *usb_device = mdev->usb_device; 835 + struct device *dev = &usb_device->dev; 836 + u16 hi, mi, lo, link; 837 + u8 hw_addr[6]; 784 838 785 - for (i = 0; i < 6; i++) 786 - prev_hw_addr[i] = mdev->hw_addr[i]; 787 - 788 - if (hdm_update_netinfo(mdev) < 0) 839 + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) { 840 + dev_err(dev, "Vendor request 'hw_addr_hi' failed\n"); 789 841 return; 790 - if (prev_link_stat != mdev->link_stat || 791 - prev_hw_addr[0] != mdev->hw_addr[0] || 792 - prev_hw_addr[1] != mdev->hw_addr[1] || 793 - prev_hw_addr[2] != mdev->hw_addr[2] || 794 - prev_hw_addr[3] != mdev->hw_addr[3] || 795 - prev_hw_addr[4] != mdev->hw_addr[4] || 796 - prev_hw_addr[5] != mdev->hw_addr[5]) 797 - most_deliver_netinfo(&mdev->iface, mdev->link_stat, 798 - &mdev->hw_addr[0]); 842 + } 843 + 844 + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) { 845 + dev_err(dev, "Vendor request 'hw_addr_mid' failed\n"); 846 + return; 847 + } 848 + 849 + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) { 850 + dev_err(dev, "Vendor request 'hw_addr_low' failed\n"); 851 + return; 852 + } 853 + 854 + if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) { 855 + dev_err(dev, "Vendor request 'link status' failed\n"); 856 + return; 857 + } 858 + 859 + hw_addr[0] = hi >> 8; 860 + hw_addr[1] = hi; 861 + hw_addr[2] = mi >> 8; 862 + hw_addr[3] = mi; 863 + hw_addr[4] = lo >> 8; 864 + hw_addr[5] = lo; 865 + 866 + most_deliver_netinfo(&mdev->iface, link, hw_addr); 799 867 } 800 868 801 869 /**