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

Merge branch 'r8152-minor-adjustments'

Hayes Wang says:

====================
r8152: minor adjustments

These patches are used to adjust the code.
====================

Link: https://lore.kernel.org/r/1394712342-15778-341-Taiwan-albertk@realtek.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+46 -21
+46 -21
drivers/net/usb/r8152.c
··· 2632 2632 return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS); 2633 2633 } 2634 2634 2635 - static void rtl_set_eee_plus(struct r8152 *tp) 2635 + static void rtl_eee_plus_en(struct r8152 *tp, bool enable) 2636 2636 { 2637 2637 u32 ocp_data; 2638 - u8 speed; 2639 2638 2640 - speed = rtl8152_get_speed(tp); 2641 - if (speed & _10bps) { 2642 - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); 2639 + ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); 2640 + if (enable) 2643 2641 ocp_data |= EEEP_CR_EEEP_TX; 2644 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); 2645 - } else { 2646 - ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); 2642 + else 2647 2643 ocp_data &= ~EEEP_CR_EEEP_TX; 2648 - ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); 2649 - } 2644 + ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); 2645 + } 2646 + 2647 + static void rtl_set_eee_plus(struct r8152 *tp) 2648 + { 2649 + if (rtl8152_get_speed(tp) & _10bps) 2650 + rtl_eee_plus_en(tp, true); 2651 + else 2652 + rtl_eee_plus_en(tp, false); 2650 2653 } 2651 2654 2652 2655 static void rxdy_gated_en(struct r8152 *tp, bool enable) ··· 3153 3150 ocp_write_dword(tp, MCU_TYPE_USB, USB_UPS_FLAGS, ups_flags); 3154 3151 } 3155 3152 3156 - static void r8153b_green_en(struct r8152 *tp, bool enable) 3153 + static void rtl_green_en(struct r8152 *tp, bool enable) 3157 3154 { 3158 3155 u16 data; 3159 3156 3157 + data = sram_read(tp, SRAM_GREEN_CFG); 3158 + if (enable) 3159 + data |= GREEN_ETH_EN; 3160 + else 3161 + data &= ~GREEN_ETH_EN; 3162 + sram_write(tp, SRAM_GREEN_CFG, data); 3163 + 3164 + tp->ups_info.green = enable; 3165 + } 3166 + 3167 + static void r8153b_green_en(struct r8152 *tp, bool enable) 3168 + { 3160 3169 if (enable) { 3161 3170 sram_write(tp, 0x8045, 0); /* 10M abiq&ldvbias */ 3162 3171 sram_write(tp, 0x804d, 0x1222); /* 100M short abiq&ldvbias */ ··· 3179 3164 sram_write(tp, 0x805d, 0x2444); /* 1000M short abiq&ldvbias */ 3180 3165 } 3181 3166 3182 - data = sram_read(tp, SRAM_GREEN_CFG); 3183 - data |= GREEN_ETH_EN; 3184 - sram_write(tp, SRAM_GREEN_CFG, data); 3185 - 3186 - tp->ups_info.green = enable; 3167 + rtl_green_en(tp, true); 3187 3168 } 3188 3169 3189 3170 static u16 r8153_phy_status(struct r8152 *tp, u16 desired) ··· 3371 3360 r8153b_ups_en(tp, false); 3372 3361 r8153_queue_wake(tp, false); 3373 3362 rtl_runtime_suspend_enable(tp, false); 3374 - if (tp->udev->speed != USB_SPEED_HIGH) 3363 + if (tp->udev->speed >= USB_SPEED_SUPER) 3375 3364 r8153b_u1u2en(tp, true); 3376 3365 } 3377 3366 } ··· 5067 5056 5068 5057 r8153_aldps_en(tp, true); 5069 5058 5070 - if (tp->udev->speed != USB_SPEED_HIGH) 5059 + if (tp->udev->speed >= USB_SPEED_SUPER) 5071 5060 r8153b_u1u2en(tp, true); 5072 5061 } 5073 5062 ··· 5583 5572 ocp_data |= POLL_LINK_CHG; 5584 5573 ocp_write_word(tp, MCU_TYPE_PLA, PLA_EXTRA_STATUS, ocp_data); 5585 5574 5586 - if (tp->udev->speed != USB_SPEED_HIGH) 5575 + if (tp->udev->speed >= USB_SPEED_SUPER) 5587 5576 r8153b_u1u2en(tp, true); 5577 + 5588 5578 usb_enable_lpm(tp->udev); 5589 5579 5590 5580 /* MAC clock speed down */ ··· 5767 5755 { 5768 5756 struct net_device *netdev = tp->netdev; 5769 5757 int ret = 0; 5758 + 5759 + if (!tp->rtl_ops.autosuspend_en) 5760 + return -EBUSY; 5770 5761 5771 5762 set_bit(SELECTIVE_SUSPEND, &tp->flags); 5772 5763 smp_mb__after_atomic(); ··· 6170 6155 struct r8152 *tp = netdev_priv(net); 6171 6156 int ret; 6172 6157 6158 + if (!tp->rtl_ops.eee_get) { 6159 + ret = -EOPNOTSUPP; 6160 + goto out; 6161 + } 6162 + 6173 6163 ret = usb_autopm_get_interface(tp->intf); 6174 6164 if (ret < 0) 6175 6165 goto out; ··· 6196 6176 { 6197 6177 struct r8152 *tp = netdev_priv(net); 6198 6178 int ret; 6179 + 6180 + if (!tp->rtl_ops.eee_set) { 6181 + ret = -EOPNOTSUPP; 6182 + goto out; 6183 + } 6199 6184 6200 6185 ret = usb_autopm_get_interface(tp->intf); 6201 6186 if (ret < 0) ··· 6601 6576 6602 6577 default: 6603 6578 ret = -ENODEV; 6604 - netif_err(tp, probe, tp->netdev, "Unknown Device\n"); 6579 + dev_err(&tp->intf->dev, "Unknown Device\n"); 6605 6580 break; 6606 6581 } 6607 6582 ··· 6858 6833 6859 6834 ret = register_netdev(netdev); 6860 6835 if (ret != 0) { 6861 - netif_err(tp, probe, netdev, "couldn't register the device\n"); 6836 + dev_err(&intf->dev, "couldn't register the device\n"); 6862 6837 goto out1; 6863 6838 } 6864 6839