summaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorOliver Neukum <oneukum@suse.com>2019-05-09 05:08:17 -0400
committerDavid S. Miller <davem@davemloft.net>2019-05-09 12:35:40 -0400
commit369b46e9fbcfa5136f2cb5f486c90e5f7fa92630 (patch)
tree663c9aa968f9db9bb68e3495c66839c9cf915d70 /drivers/net/usb
parentb8b277525e9df2fd2dc3d1f4fe01c6796bb107fc (diff)
aqc111: fix writing to the phy on BE
When writing to the phy on BE architectures an internal data structure was directly given, leading to it being byte swapped in the wrong way for the CPU in 50% of all cases. A temporary buffer must be used. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/aqc111.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index 408df2d335e3..599d560a8450 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -320,6 +320,7 @@ static int aqc111_get_link_ksettings(struct net_device *net,
320static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed) 320static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
321{ 321{
322 struct aqc111_data *aqc111_data = dev->driver_priv; 322 struct aqc111_data *aqc111_data = dev->driver_priv;
323 u32 phy_on_the_wire;
323 324
324 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; 325 aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
325 aqc111_data->phy_cfg |= AQ_PAUSE; 326 aqc111_data->phy_cfg |= AQ_PAUSE;
@@ -361,7 +362,8 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
361 } 362 }
362 } 363 }
363 364
364 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &aqc111_data->phy_cfg); 365 phy_on_the_wire = aqc111_data->phy_cfg;
366 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, &phy_on_the_wire);
365} 367}
366 368
367static int aqc111_set_link_ksettings(struct net_device *net, 369static int aqc111_set_link_ksettings(struct net_device *net,
@@ -755,6 +757,7 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
755{ 757{
756 struct aqc111_data *aqc111_data = dev->driver_priv; 758 struct aqc111_data *aqc111_data = dev->driver_priv;
757 u16 reg16; 759 u16 reg16;
760 u32 phy_on_the_wire;
758 761
759 /* Force bz */ 762 /* Force bz */
760 reg16 = SFR_PHYPWR_RSTCTL_BZ; 763 reg16 = SFR_PHYPWR_RSTCTL_BZ;
@@ -768,8 +771,9 @@ static void aqc111_unbind(struct usbnet *dev, struct usb_interface *intf)
768 aqc111_data->phy_cfg &= ~AQ_ADV_MASK; 771 aqc111_data->phy_cfg &= ~AQ_ADV_MASK;
769 aqc111_data->phy_cfg |= AQ_LOW_POWER; 772 aqc111_data->phy_cfg |= AQ_LOW_POWER;
770 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN; 773 aqc111_data->phy_cfg &= ~AQ_PHY_POWER_EN;
774 phy_on_the_wire = aqc111_data->phy_cfg;
771 aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0, 775 aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0,
772 &aqc111_data->phy_cfg); 776 &phy_on_the_wire);
773 777
774 kfree(aqc111_data); 778 kfree(aqc111_data);
775} 779}
@@ -992,6 +996,7 @@ static int aqc111_reset(struct usbnet *dev)
992{ 996{
993 struct aqc111_data *aqc111_data = dev->driver_priv; 997 struct aqc111_data *aqc111_data = dev->driver_priv;
994 u8 reg8 = 0; 998 u8 reg8 = 0;
999 u32 phy_on_the_wire;
995 1000
996 dev->rx_urb_size = URB_SIZE; 1001 dev->rx_urb_size = URB_SIZE;
997 1002
@@ -1004,8 +1009,9 @@ static int aqc111_reset(struct usbnet *dev)
1004 1009
1005 /* Power up ethernet PHY */ 1010 /* Power up ethernet PHY */
1006 aqc111_data->phy_cfg = AQ_PHY_POWER_EN; 1011 aqc111_data->phy_cfg = AQ_PHY_POWER_EN;
1012 phy_on_the_wire = aqc111_data->phy_cfg;
1007 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1013 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1008 &aqc111_data->phy_cfg); 1014 &phy_on_the_wire);
1009 1015
1010 /* Set the MAC address */ 1016 /* Set the MAC address */
1011 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN, 1017 aqc111_write_cmd(dev, AQ_ACCESS_MAC, SFR_NODE_ID, ETH_ALEN,
@@ -1036,6 +1042,7 @@ static int aqc111_stop(struct usbnet *dev)
1036{ 1042{
1037 struct aqc111_data *aqc111_data = dev->driver_priv; 1043 struct aqc111_data *aqc111_data = dev->driver_priv;
1038 u16 reg16 = 0; 1044 u16 reg16 = 0;
1045 u32 phy_on_the_wire;
1039 1046
1040 aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE, 1047 aqc111_read16_cmd(dev, AQ_ACCESS_MAC, SFR_MEDIUM_STATUS_MODE,
1041 2, &reg16); 1048 2, &reg16);
@@ -1047,8 +1054,9 @@ static int aqc111_stop(struct usbnet *dev)
1047 1054
1048 /* Put PHY to low power*/ 1055 /* Put PHY to low power*/
1049 aqc111_data->phy_cfg |= AQ_LOW_POWER; 1056 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1057 phy_on_the_wire = aqc111_data->phy_cfg;
1050 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1058 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1051 &aqc111_data->phy_cfg); 1059 &phy_on_the_wire);
1052 1060
1053 netif_carrier_off(dev->net); 1061 netif_carrier_off(dev->net);
1054 1062
@@ -1324,6 +1332,7 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
1324 u16 temp_rx_ctrl = 0x00; 1332 u16 temp_rx_ctrl = 0x00;
1325 u16 reg16; 1333 u16 reg16;
1326 u8 reg8; 1334 u8 reg8;
1335 u32 phy_on_the_wire;
1327 1336
1328 usbnet_suspend(intf, message); 1337 usbnet_suspend(intf, message);
1329 1338
@@ -1395,12 +1404,14 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
1395 1404
1396 aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0, 1405 aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0,
1397 WOL_CFG_SIZE, &wol_cfg); 1406 WOL_CFG_SIZE, &wol_cfg);
1407 phy_on_the_wire = aqc111_data->phy_cfg;
1398 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1408 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1399 &aqc111_data->phy_cfg); 1409 &phy_on_the_wire);
1400 } else { 1410 } else {
1401 aqc111_data->phy_cfg |= AQ_LOW_POWER; 1411 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1412 phy_on_the_wire = aqc111_data->phy_cfg;
1402 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0, 1413 aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1403 &aqc111_data->phy_cfg); 1414 &phy_on_the_wire);
1404 1415
1405 /* Disable RX path */ 1416 /* Disable RX path */
1406 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC, 1417 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC,