rtl83xx: make use of BIT() in the dsa driver
authorJohn Crispin <john@phrozen.org>
Tue, 24 Nov 2020 13:05:42 +0000 (14:05 +0100)
committerJohn Crispin <john@phrozen.org>
Tue, 24 Nov 2020 14:16:38 +0000 (15:16 +0100)
Signed-off-by: John Crispin <john@phrozen.org>
target/linux/rtl838x/files-5.4/drivers/net/dsa/rtl83xx/common.c
target/linux/rtl838x/files-5.4/drivers/net/dsa/rtl83xx/dsa.c
target/linux/rtl838x/files-5.4/drivers/net/dsa/rtl83xx/phy.c
target/linux/rtl838x/files-5.4/drivers/net/dsa/rtl83xx/rtl838x.c
target/linux/rtl838x/files-5.4/drivers/net/dsa/rtl83xx/rtl839x.c
target/linux/rtl838x/files-5.4/drivers/net/dsa/rtl83xx/storm.c

index d60f7c12799db9ceb116cf4614c2b46fa4020565..9a995834b131bcff0907907172e1b51543fe6789 100644 (file)
@@ -59,12 +59,12 @@ static void rtl83xx_port_get_stp_state(struct rtl838x_switch_priv *priv, int por
        bit = (pos << 1) % 32;
 
        if (priv->family_id == RTL8380_FAMILY_ID) {
-               cmd = 1 << 15 /* Execute cmd */
-                       | 1 << 14 /* Read */
+               cmd = BIT(15) /* Execute cmd */
+                       | BIT(14) /* Read */
                        | 2 << 12 /* Table type 0b10 */
                        | (msti & 0xfff);
        } else {
-               cmd = 1 << 16 /* Execute cmd */
+               cmd = BIT(16) /* Execute cmd */
                        | 0 << 15 /* Read */
                        | 5 << 12 /* Table type 0b101 */
                        | (msti & 0xfff);
@@ -245,10 +245,10 @@ static int __init rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
        /* Enable PHY control via SoC */
        if (priv->family_id == RTL8380_FAMILY_ID) {
                /* Enable PHY control via SoC */
-               sw_w32_mask(0, 1 << 15, RTL838X_SMI_GLB_CTRL);
+               sw_w32_mask(0, BIT(15), RTL838X_SMI_GLB_CTRL);
        } else {
                /* Disable PHY polling via SoC */
-               sw_w32_mask(1 << 7, 0, RTL839X_SMI_GLB_CTRL);
+               sw_w32_mask(BIT(7), 0, RTL839X_SMI_GLB_CTRL);
        }
 
        /* Power on fibre ports and reset them if necessary */
index bc340e94cb7960f3f6f9f2ab769154f472ee6d15..3600bbbd1b9a7df4d3f5b94e71612bf45009b79b 100644 (file)
@@ -51,9 +51,9 @@ static void rtl83xx_init_stats(struct rtl838x_switch_priv *priv)
 
 static void rtl83xx_write_cam(int idx, u32 *r)
 {
-       u32 cmd = 1 << 16 /* Execute cmd */
-               | 1 << 15 /* Read */
-               | 1 << 13 /* Table type 0b01 */
+       u32 cmd = BIT(16) /* Execute cmd */
+               | BIT(15) /* Read */
+               | BIT(13) /* Table type 0b01 */
                | (idx & 0x3f);
 
        sw_w32(r[0], RTL838X_TBL_ACCESS_L2_DATA(0));
@@ -61,7 +61,7 @@ static void rtl83xx_write_cam(int idx, u32 *r)
        sw_w32(r[2], RTL838X_TBL_ACCESS_L2_DATA(2));
 
        sw_w32(cmd, RTL838X_TBL_ACCESS_L2_CTRL);
-       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & (1 << 16));
+       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & BIT(16));
 }
 
 static u64 rtl83xx_hash_key(struct rtl838x_switch_priv *priv, u64 mac, u32 vid)
@@ -74,7 +74,7 @@ static u64 rtl83xx_hash_key(struct rtl838x_switch_priv *priv, u64 mac, u32 vid)
 
 static void rtl83xx_write_hash(int idx, u32 *r)
 {
-       u32 cmd = 1 << 16 /* Execute cmd */
+       u32 cmd = BIT(16) /* Execute cmd */
                | 0 << 15 /* Write */
                | 0 << 13 /* Table type 0b00 */
                | (idx & 0x1fff);
@@ -83,7 +83,7 @@ static void rtl83xx_write_hash(int idx, u32 *r)
        sw_w32(0, RTL838X_TBL_ACCESS_L2_DATA(1));
        sw_w32(0, RTL838X_TBL_ACCESS_L2_DATA(2));
        sw_w32(cmd, RTL838X_TBL_ACCESS_L2_CTRL);
-       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & (1 << 16));
+       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & BIT(16));
 }
 
 static void rtl83xx_enable_phy_polling(struct rtl838x_switch_priv *priv)
@@ -95,7 +95,7 @@ static void rtl83xx_enable_phy_polling(struct rtl838x_switch_priv *priv)
        /* Enable all ports with a PHY, including the SFP-ports */
        for (i = 0; i < priv->cpu_port; i++) {
                if (priv->ports[i].phy)
-                       v |= 1 << i;
+                       v |= BIT(i);
        }
 
        pr_info("%s: %16llx\n", __func__, v);
@@ -103,7 +103,7 @@ static void rtl83xx_enable_phy_polling(struct rtl838x_switch_priv *priv)
 
        /* PHY update complete */
        if (priv->family_id == RTL8390_FAMILY_ID)
-               sw_w32_mask(0, 1 << 7, RTL839X_SMI_GLB_CTRL);
+               sw_w32_mask(0, BIT(7), RTL839X_SMI_GLB_CTRL);
        else
                sw_w32_mask(0, 0x8000, RTL838X_SMI_GLB_CTRL);
 }
@@ -173,7 +173,7 @@ static int rtl83xx_setup(struct dsa_switch *ds)
 {
        int i;
        struct rtl838x_switch_priv *priv = ds->priv;
-       u64 port_bitmap = 1ULL << priv->cpu_port;
+       u64 port_bitmap = BIT_ULL(priv->cpu_port);
 
        pr_info("%s called\n", __func__);
 
@@ -190,9 +190,9 @@ static int rtl83xx_setup(struct dsa_switch *ds)
         */
        for (i = 0; i < priv->cpu_port; i++) {
                if (priv->ports[i].phy) {
-                       priv->r->set_port_reg_be(1ULL << priv->cpu_port | 1ULL << i,
+                       priv->r->set_port_reg_be(BIT_ULL(priv->cpu_port) | BIT(i),
                                              priv->r->port_iso_ctrl(i));
-                       port_bitmap |= 1ULL << i;
+                       port_bitmap |= BIT_ULL(i);
                }
        }
        priv->r->set_port_reg_be(port_bitmap, priv->r->port_iso_ctrl(priv->cpu_port));
@@ -272,10 +272,10 @@ static int rtl83xx_phylink_mac_link_state(struct dsa_switch *ds, int port,
                return -EINVAL;
 
        state->link = 0;
-       if (priv->r->get_port_reg_le(priv->r->mac_link_sts) & (1ULL << port))
+       if (priv->r->get_port_reg_le(priv->r->mac_link_sts) & BIT_ULL(port))
                state->link = 1;
        state->duplex = 0;
-       if (priv->r->get_port_reg_le(priv->r->mac_link_dup_sts) & (1ULL << port))
+       if (priv->r->get_port_reg_le(priv->r->mac_link_dup_sts) & BIT_ULL(port))
                state->duplex = 1;
 
        speed = priv->r->get_port_reg_le(priv->r->mac_link_spd_sts(port));
@@ -298,9 +298,9 @@ static int rtl83xx_phylink_mac_link_state(struct dsa_switch *ds, int port,
        }
 
        state->pause &= (MLO_PAUSE_RX | MLO_PAUSE_TX);
-       if (priv->r->get_port_reg_le(priv->r->mac_rx_pause_sts) & (1ULL << port))
+       if (priv->r->get_port_reg_le(priv->r->mac_rx_pause_sts) & BIT_ULL(port))
                state->pause |= MLO_PAUSE_RX;
-       if (priv->r->get_port_reg_le(priv->r->mac_tx_pause_sts) & (1ULL << port))
+       if (priv->r->get_port_reg_le(priv->r->mac_tx_pause_sts) & BIT_ULL(port))
                state->pause |= MLO_PAUSE_TX;
        return 1;
 }
@@ -336,7 +336,7 @@ static void rtl83xx_phylink_mac_config(struct dsa_switch *ds, int port,
        if (priv->family_id == RTL8380_FAMILY_ID) {
                if (mode == MLO_AN_PHY) {
                        pr_info("PHY autonegotiates\n");
-                       reg |= 1 << 2;
+                       reg |= BIT(2);
                        sw_w32(reg, priv->r->mac_force_mode_ctrl(port));
                        return;
                }
@@ -378,7 +378,7 @@ static void rtl83xx_phylink_mac_config(struct dsa_switch *ds, int port,
 
        // Disable AN
        if (priv->family_id == RTL8380_FAMILY_ID)
-               reg &= ~(1 << 2);
+               reg &= ~BIT(2);
        sw_w32(reg, priv->r->mac_force_mode_ctrl(port));
 }
 
@@ -453,7 +453,7 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port,
                return 0;
 
        /* add port to switch mask of CPU_PORT */
-       priv->r->mask_port_reg_be(0ULL, 1ULL << port, priv->r->port_iso_ctrl(priv->cpu_port));
+       priv->r->mask_port_reg_be(0ULL, BIT_ULL(port), priv->r->port_iso_ctrl(priv->cpu_port));
 
        /* add all other ports in the same bridge to switch mask of port */
        priv->r->mask_port_reg_be(0ULL, priv->ports[port].pm, priv->r->port_iso_ctrl(port));
@@ -471,7 +471,7 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port)
                return;
 
        /* remove port from switch mask of CPU_PORT */
-       priv->r->mask_port_reg_be(1ULL << port, 0, priv->r->port_iso_ctrl(priv->cpu_port));
+       priv->r->mask_port_reg_be(BIT_ULL(port), 0, priv->r->port_iso_ctrl(priv->cpu_port));
 
        /* remove all other ports in the same bridge from switch mask of port */
        priv->r->mask_port_reg_be(priv->ports[port].pm, 0LL, priv->r->port_iso_ctrl(port));
@@ -486,16 +486,16 @@ static int rtl83xx_get_mac_eee(struct dsa_switch *ds, int port,
 
        pr_info("%s: port %d", __func__, port);
        e->supported = SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full;
-       if (sw_r32(priv->r->mac_force_mode_ctrl(port)) & (1 << 9))
+       if (sw_r32(priv->r->mac_force_mode_ctrl(port)) & BIT(9))
                e->advertised |= ADVERTISED_100baseT_Full;
 
-       if (sw_r32(priv->r->mac_force_mode_ctrl(port)) & (1 << 10))
+       if (sw_r32(priv->r->mac_force_mode_ctrl(port)) & BIT(10))
                e->advertised |= ADVERTISED_1000baseT_Full;
 
        e->eee_enabled = priv->ports[port].eee_enabled;
        pr_info("enabled: %d, active %x\n", e->eee_enabled, e->advertised);
 
-       if (sw_r32(RTL838X_MAC_EEE_ABLTY) & (1 << port)) {
+       if (sw_r32(RTL838X_MAC_EEE_ABLTY) & BIT(port)) {
                e->lp_advertised = ADVERTISED_100baseT_Full;
                e->lp_advertised |= ADVERTISED_1000baseT_Full;
        }
@@ -519,15 +519,15 @@ static int rtl83xx_set_mac_eee(struct dsa_switch *ds, int port,
        if (e->eee_enabled) {
                pr_info("Enabling EEE for MAC %d\n", port);
                sw_w32_mask(0, 3 << 9, priv->r->mac_force_mode_ctrl(port));
-               sw_w32_mask(0, 1 << port, RTL838X_EEE_PORT_TX_EN);
-               sw_w32_mask(0, 1 << port, RTL838X_EEE_PORT_RX_EN);
+               sw_w32_mask(0, BIT(port), RTL838X_EEE_PORT_TX_EN);
+               sw_w32_mask(0, BIT(port), RTL838X_EEE_PORT_RX_EN);
                priv->ports[port].eee_enabled = true;
                e->eee_enabled = true;
        } else {
                pr_info("Disabling EEE for MAC %d\n", port);
                sw_w32_mask(3 << 9, 0, priv->r->mac_force_mode_ctrl(port));
-               sw_w32_mask(1 << port, 0, RTL838X_EEE_PORT_TX_EN);
-               sw_w32_mask(1 << port, 0, RTL838X_EEE_PORT_RX_EN);
+               sw_w32_mask(BIT(port), 0, RTL838X_EEE_PORT_TX_EN);
+               sw_w32_mask(BIT(port), 0, RTL838X_EEE_PORT_RX_EN);
                priv->ports[port].eee_enabled = false;
                e->eee_enabled = false;
        }
@@ -560,7 +560,7 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port,
                                        struct net_device *bridge)
 {
        struct rtl838x_switch_priv *priv = ds->priv;
-       u64 port_bitmap = 1ULL << priv->cpu_port;
+       u64 port_bitmap = BIT_ULL(priv->cpu_port);
        int i;
 
        pr_info("%s %x: %d %llx", __func__, (u32)priv, port, port_bitmap);
@@ -574,17 +574,17 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port,
                        if (dsa_to_port(ds, i)->bridge_dev != bridge)
                                continue;
                        if (priv->ports[i].enable)
-                               priv->r->mask_port_reg_be(0, 1ULL << port,
+                               priv->r->mask_port_reg_be(0, BIT_ULL(port),
                                                       priv->r->port_iso_ctrl(i));
-                       priv->ports[i].pm |= 1ULL << port;
+                       priv->ports[i].pm |= BIT_ULL(port);
 
-                       port_bitmap |= 1ULL << i;
+                       port_bitmap |= BIT_ULL(i);
                }
        }
 
        /* Add all other ports to this port matrix. */
        if (priv->ports[port].enable) {
-               priv->r->mask_port_reg_be(0, 1ULL << port,
+               priv->r->mask_port_reg_be(0, BIT_ULL(port),
                                        priv->r->port_iso_ctrl(priv->cpu_port));
                priv->r->mask_port_reg_be(0, port_bitmap,
                                        priv->r->port_iso_ctrl(port));
@@ -599,7 +599,7 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port,
                                        struct net_device *bridge)
 {
        struct rtl838x_switch_priv *priv = ds->priv;
-       u64 port_bitmap = 1ULL << priv->cpu_port;
+       u64 port_bitmap = BIT_ULL(priv->cpu_port);
        int i;
 
        pr_info("%s %x: %d", __func__, (u32)priv, port);
@@ -615,11 +615,11 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port,
                        if (dsa_to_port(ds, i)->bridge_dev != bridge)
                                continue;
                        if (priv->ports[i].enable)
-                               priv->r->mask_port_reg_be(1ULL << port, 0,
+                               priv->r->mask_port_reg_be(BIT_ULL(port), 0,
                                                       priv->r->port_iso_ctrl(i));
-                       priv->ports[i].pm &= ~(1ULL << port);
+                       priv->ports[i].pm &= ~BIT_ULL(port);
 
-                       port_bitmap &= ~(1ULL << i);
+                       port_bitmap &= ~BIT_ULL(i);
                }
        }
 
@@ -657,12 +657,12 @@ static void rtl83xx_port_stp_state_set(struct dsa_switch *ds, int port,
        bit = (pos << 1) % 32;
 
        if (priv->family_id == RTL8380_FAMILY_ID) {
-               cmd = 1 << 15 /* Execute cmd */
-                       | 1 << 14 /* Read */
+               cmd = BIT(15) /* Execute cmd */
+                       | BIT(14) /* Read */
                        | 2 << 12 /* Table type 0b10 */
                        | (msti & 0xfff);
        } else {
-               cmd = 1 << 16 /* Execute cmd */
+               cmd = BIT(16) /* Execute cmd */
                        | 0 << 15 /* Read */
                        | 5 << 12 /* Table type 0b101 */
                        | (msti & 0xfff);
@@ -693,13 +693,13 @@ static void rtl83xx_port_stp_state_set(struct dsa_switch *ds, int port,
        }
 
        if (priv->family_id == RTL8380_FAMILY_ID) {
-               cmd = 1 << 15 /* Execute cmd */
+               cmd = BIT(15) /* Execute cmd */
                        | 0 << 14 /* Write */
                        | 2 << 12 /* Table type 0b10 */
                        | (msti & 0xfff);
        } else {
                cmd = 1 << 16 /* Execute cmd */
-                       | 1 << 15 /* Write */
+                       | BIT(15) /* Write */
                        | 5 << 12 /* Table type 0b101 */
                        | (msti & 0xfff);
        }
@@ -818,7 +818,7 @@ static void rtl83xx_vlan_add(struct dsa_switch *ds, int port,
                for (v = vlan->vid_begin; v <= vlan->vid_end; v++) {
                        /* Get untagged port memberships of this vlan */
                        priv->r->vlan_tables_read(v, &info);
-                       portmask = info.untagged_ports | (1 << port);
+                       portmask = info.untagged_ports | BIT(port);
                        pr_debug("Untagged ports, VLAN %d: %llx\n", v, portmask);
                        priv->r->vlan_set_untagged(v, portmask);
                }
@@ -826,7 +826,7 @@ static void rtl83xx_vlan_add(struct dsa_switch *ds, int port,
                for (v = vlan->vid_begin; v <= vlan->vid_end; v++) {
                        /* Get tagged port memberships of this vlan */
                        priv->r->vlan_tables_read(v, &info);
-                       info.tagged_ports |= (1 << port);
+                       info.tagged_ports |= BIT(port);
                        pr_debug("Tagged ports, VLAN %d: %llx\n", v, info.tagged_ports);
                        priv->r->vlan_set_tagged(v, &info);
                }
index 1f955ef3e5c8ac6a37e648412d3fe672fc289a98..85ab17626e2a7c626c822c6082d6409830c8da60 100644 (file)
@@ -70,9 +70,9 @@ static void int_phy_on_off(int mac, bool on)
 
        read_phy(mac, 0, 0, &val);
        if (on)
-               write_phy(mac, 0, 0, val & ~(1 << 11));
+               write_phy(mac, 0, 0, val & ~BIT(11));
        else
-               write_phy(mac, 0, 0, val | (1 << 11));
+               write_phy(mac, 0, 0, val | BIT(11));
 }
 
 static void rtl8214fc_on_off(int mac, bool on)
@@ -83,17 +83,17 @@ static void rtl8214fc_on_off(int mac, bool on)
        write_phy(mac, 4095, 30, 3);
        read_phy(mac, 0, 16, &val);
        if (on)
-               write_phy(mac, 0, 16, val & ~(1 << 11));
+               write_phy(mac, 0, 16, val & ~BIT(11));
        else
-               write_phy(mac, 0, 16, val | (1 << 11));
+               write_phy(mac, 0, 16, val | BIT(11));
 
        /* copper ports */
        write_phy(mac, 4095, 30, 1);
        read_phy(mac, 0, 16, &val);
        if (on)
-               write_phy(mac, 0xa40, 16, val & ~(1 << 11));
+               write_phy(mac, 0xa40, 16, val & ~BIT(11));
        else
-               write_phy(mac, 0xa40, 16, val | (1 << 11));
+               write_phy(mac, 0xa40, 16, val | BIT(11));
 }
 
 static void phy_reset(int mac)
@@ -101,7 +101,7 @@ static void phy_reset(int mac)
        u32 val;
 
        read_phy(mac, 0, 0, &val);
-       write_phy(mac, 0, 0, val | (0x1 << 15));
+       write_phy(mac, 0, 0, val | BIT(15));
 }
 
 /* Read the link and speed status of the 2 internal SGMII/1000Base-X
@@ -141,7 +141,7 @@ static int rtl8393_read_status(struct phy_device *phydev)
                 * PHY registers
                 */
                v = sw_r32(RTL839X_SDS12_13_XSG0 + offset + 0x80);
-               if (!(v & (1 << 13)) && (v & (1 << 6)))
+               if (!(v & (BIT(13)) && (v & BIT(6)))
                        phydev->speed = SPEED_1000;
                phydev->duplex = DUPLEX_FULL;
        }
@@ -258,7 +258,7 @@ static int rtl8380_configure_int_rtl8218b(struct phy_device *phydev)
                ipd_flag = 1;
 
        read_phy(mac, 0, 0, &val);
-       if (val & (1 << 11))
+       if (val & BIT(11))
                int_phy_on_off(mac, true);
        else
                phy_reset(mac);
@@ -350,7 +350,7 @@ static int rtl8380_configure_ext_rtl8218b(struct phy_device *phydev)
                        + h->parts[2].start;
 
        read_phy(mac, 0, 0, &val);
-       if (val & (1 << 11))
+       if (val & BIT(11))
                int_phy_on_off(mac, true);
        else
                phy_reset(mac);
@@ -460,7 +460,7 @@ static int rtl83xx_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val)
        if (rtl838x_smi_wait_op(10000))
                goto timeout;
 
-       sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
+       sw_w32(BIT(port), RTL838X_SMI_ACCESS_PHY_CTRL_0);
        mdelay(10);
 
        sw_w32_mask(0xffff0000, port << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
@@ -469,7 +469,7 @@ static int rtl83xx_read_mmd_phy(u32 port, u32 addr, u32 reg, u32 *val)
        sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_3);
 
        /* mmd-access | read | cmd-start */
-       v = 1 << 1 | 0 << 2 | 1;
+       v = BIT(1) | 0 << 2 | 1;
        sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1);
 
        if (rtl838x_smi_wait_op(10000))
@@ -499,7 +499,7 @@ static int rtl838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val)
        if (rtl838x_smi_wait_op(10000))
                goto timeout;
 
-       sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
+       sw_w32(BIT(port), RTL838X_SMI_ACCESS_PHY_CTRL_0);
        mdelay(10);
 
        sw_w32_mask(0xffff0000, val << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
@@ -507,7 +507,7 @@ static int rtl838x_write_mmd_phy(u32 port, u32 addr, u32 reg, u32 val)
        sw_w32_mask(0x1f << 16, addr << 16, RTL838X_SMI_ACCESS_PHY_CTRL_3);
        sw_w32_mask(0xffff, reg, RTL838X_SMI_ACCESS_PHY_CTRL_3);
        /* mmd-access | write | cmd-start */
-       v = 1 << 1 | 1 << 2 | 1;
+       v =  BIT(1) | BIT(2) | BIT(0);
        sw_w32(v, RTL838X_SMI_ACCESS_PHY_CTRL_1);
 
        if (rtl838x_smi_wait_op(10000))
@@ -559,23 +559,23 @@ static void rtl8380_rtl8214fc_media_set(int mac, bool set_fibre)
                write_phy(base, 0xfff, 29, 1);
                /* Ensure power is off */
                read_phy(base, 0xa40, 16, &power);
-               if (!(power & (1 << 11)))
-                       write_phy(base, 0xa40, 16, power | (1 << 11));
+               if (!(power & BIT(11)))
+                       write_phy(base, 0xa40, 16, power | BIT(11));
        } else {
                pr_info("Powering off FIBRE");
                write_phy(base, 0xfff, 29, 3);
                /* Ensure power is off */
                read_phy(base, 0xa40, 16, &power);
-               if (!(power & (1 << 11)))
-                       write_phy(base, 0xa40, 16, power | (1 << 11));
+               if (!(power & BIT(11)))
+                       write_phy(base, 0xa40, 16, power | BIT(11));
        }
 
        if (set_fibre) {
-               val |= 1 << 10;
-               val &= ~(1 << 11);
+               val |= BIT(10);
+               val &= ~BIT(11);
        } else {
-               val |= 1 << 10;
-               val |= 1 << 11;
+               val |= BIT(10);
+               val |= BIT(11);
        }
        write_phy(base, 0xfff, 29, 8);
        write_phy(base, 0x266, reg[mac % 4], val);
@@ -586,15 +586,15 @@ static void rtl8380_rtl8214fc_media_set(int mac, bool set_fibre)
                write_phy(base, 0xfff, 29, 3);
                /* Ensure power is off */
                read_phy(base, 0xa40, 16, &power);
-               if (power & (1 << 11))
-                       write_phy(base, 0xa40, 16, power & ~(1 << 11));
+               if (power & BIT(11))
+                       write_phy(base, 0xa40, 16, power & ~BIT(11));
        } else {
                pr_info("Powering on COPPER\n");
                write_phy(base, 0xfff, 29, 1);
                /* Ensure power is off */
                read_phy(base, 0xa40, 16, &power);
-               if (power & (1 << 11))
-                       write_phy(base, 0xa40, 16, power & ~(1 << 11));
+               if (power & BIT(11))
+                       write_phy(base, 0xa40, 16, power & ~BIT(11));
        }
 
        write_phy(base, 0xfff, 29, 0);
@@ -609,7 +609,7 @@ static bool rtl8380_rtl8214fc_media_is_fibre(int mac)
        write_phy(base, 0xfff, 29, 8);
        read_phy(base, 0x266, reg[mac % 4], &val);
        write_phy(base, 0xfff, 29, 0);
-       if (val & (1 << 11))
+       if (val & BIT(11))
                return false;
        return true;
 }
@@ -643,7 +643,7 @@ static void rtl8218b_eee_set_u_boot(int port, bool enable)
        /* Set GPHY page to copper */
        write_phy(port, 0, 30, 0x0001);
        read_phy(port, 0, 0, &val);
-       an_enabled = val & (1 << 12);
+       an_enabled = val & BIT(12);
 
        if (enable) {
                /* 100/1000M EEE Capability */
@@ -653,7 +653,7 @@ static void rtl8218b_eee_set_u_boot(int port, bool enable)
                write_phy(port, 0, 14, 0x0006);
 
                read_phy(port, 0x0A43, 25, &val);
-               val |= 1 << 4;
+               val |= BIT(4);
                write_phy(port, 0x0A43, 25, val);
        } else {
                /* 100/1000M EEE Capability */
@@ -663,14 +663,14 @@ static void rtl8218b_eee_set_u_boot(int port, bool enable)
                write_phy(port, 0, 14, 0x0000);
 
                read_phy(port, 0x0A43, 25, &val);
-               val &= ~(1 << 4);
+               val &= ~BIT(4);
                write_phy(port, 0x0A43, 25, val);
        }
 
        /* Restart AN if enabled */
        if (an_enabled) {
                read_phy(port, 0, 0, &val);
-               val |= (1 << 12) | (1 << 9);
+               val |= BIT(12) | BIT(9);
                write_phy(port, 0, 0, val);
        }
 
@@ -689,11 +689,11 @@ static void rtl8380_rtl8218b_eee_set(int port, bool enable)
        write_phy(port, 0xa42, 29, 0x0001);
 
        read_phy(port, 0, 0, &val);
-       an_enabled = val & (1 << 12);
+       an_enabled = val & BIT(12);
 
        /* MAC based EEE */
        read_phy(port, 0xa43, 25, &val);
-       val &= ~(1 << 5);
+       val &= ~BIT(5);
        write_phy(port, 0xa43, 25, val);
 
        /* 100M / 1000M EEE */
@@ -705,15 +705,15 @@ static void rtl8380_rtl8218b_eee_set(int port, bool enable)
        /* 500M EEE ability */
        read_phy(port, 0xa42, 20, &val);
        if (enable)
-               val |= 1 << 7;
+               val |= BIT(7);
        else
-               val &= ~(1 << 7);
+               val &= ~BIT(7);
        write_phy(port, 0xa42, 20, val);
 
        /* Restart AN if enabled */
        if (an_enabled) {
                read_phy(port, 0, 0, &val);
-               val |= (1 << 12) | (1 << 9);
+               val |= BIT(12) | BIT(9);
                write_phy(port, 0, 0, val);
        }
 
@@ -733,8 +733,8 @@ static int rtl8218b_get_eee(struct phy_device *phydev,
        write_phy(addr, 0xa42, 29, 0x0001);
 
        rtl83xx_read_mmd_phy(addr, 7, 60, &val);
-       if (e->eee_enabled && (!!(val & (1 << 7))))
-               e->eee_enabled = !!(val & (1 << 7));
+       if (e->eee_enabled && (!!(val & BIT(7))))
+               e->eee_enabled = !!(val & BIT(7));
        else
                e->eee_enabled = 0;
 
@@ -755,11 +755,11 @@ static void rtl8380_rtl8218b_green_set(int mac, bool enable)
        write_phy(mac, 0, 27, 0x8011);
        read_phy(mac, 0, 28, &val);
        if (enable) {
-               val |= 1 << 9;
+               val |= BIT(9);
                write_phy(mac, 0, 27, 0x8011);
                write_phy(mac, 0, 28, val);
        } else {
-               val &= ~(1 << 9);
+               val &= ~BIT(9);
                write_phy(mac, 0, 27, 0x8011);
                write_phy(mac, 0, 28, val);
        }
@@ -780,8 +780,8 @@ static int rtl8380_rtl8214fc_get_green(struct phy_device *phydev, struct ethtool
 
        write_phy(addr, 0, 27, 0x8011);
        read_phy(addr, 0, 28, &val);
-       if (e->eee_enabled && (!!(val & (1 << 9))))
-               e->eee_enabled = !!(val & (1 << 9));
+       if (e->eee_enabled && (!!(val & BIT(9))))
+               e->eee_enabled = !!(val & BIT(9));
        else
                e->eee_enabled = 0;
 
@@ -910,7 +910,7 @@ static int rtl8380_configure_rtl8214fc(struct phy_device *phydev)
        read_phy(mac, 0xfff, 28, &val);
 
        read_phy(mac, 0, 16, &val);
-       if (val & (1 << 11))
+       if (val & BIT(11))
                rtl8214fc_on_off(mac, true);
        else
                phy_reset(mac);
@@ -1098,7 +1098,7 @@ static int rtl8380_configure_serdes(struct phy_device *phydev)
        sw_w32(3, RTL838X_INT_RW_CTRL);
 
        /* SerDes ports 4 and 5 are FIBRE ports */
-       sw_w32_mask(0x7 | 0x38, 1 | (1 << 3), RTL838X_INT_MODE_CTRL);
+       sw_w32_mask(0x7 | 0x38, 1 | BIT(3), RTL838X_INT_MODE_CTRL);
 
        /* SerDes module settings, SerDes 0-3 are QSGMII */
        v = 0x6 << 25 | 0x6 << 20 | 0x6 << 15 | 0x6 << 10;
@@ -1157,7 +1157,7 @@ static int rtl8390_configure_serdes(struct phy_device *phydev)
        phydev_info(phydev, "Detected internal RTL8390 SERDES\n");
 
        /* In autoneg state, force link, set SR4_CFG_EN_LINK_FIB1G */
-       sw_w32_mask(0, 1 << 18, RTL839X_SDS12_13_XSG0 + 0x0a);
+       sw_w32_mask(0, BIT(18), RTL839X_SDS12_13_XSG0 + 0x0a);
 
        /* Disable EEE: Clear FRE16_EEE_RSG_FIB1G, FRE16_EEE_STD_FIB1G,
         * FRE16_C1_PWRSAV_EN_FIB1G, FRE16_C2_PWRSAV_EN_FIB1G
index 83fe22c2d91aa774f9a80512c793198b5a68f735..246d75bb2853dd96fa2985620041d6d702fc620a 100644 (file)
@@ -34,13 +34,13 @@ static inline int rtl838x_port_iso_ctrl(int p)
 static inline void rtl838x_exec_tbl0_cmd(u32 cmd)
 {
        sw_w32(cmd, RTL838X_TBL_ACCESS_CTRL_0);
-       do { } while (sw_r32(RTL838X_TBL_ACCESS_CTRL_0) & (1 << 15));
+       do { } while (sw_r32(RTL838X_TBL_ACCESS_CTRL_0) & BIT(15));
 }
 
 static inline void rtl838x_exec_tbl1_cmd(u32 cmd)
 {
        sw_w32(cmd, RTL838X_TBL_ACCESS_CTRL_1);
-       do { } while (sw_r32(RTL838X_TBL_ACCESS_CTRL_1) & (1 << 15));
+       do { } while (sw_r32(RTL838X_TBL_ACCESS_CTRL_1) & BIT(15));
 }
 
 static inline int rtl838x_tbl_access_data_0(int i)
@@ -52,8 +52,8 @@ static void rtl838x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info)
 {
        u32 cmd, v;
 
-       cmd = 1 << 15 /* Execute cmd */
-               | 1 << 14 /* Read */
+       cmd = BIT(15) /* Execute cmd */
+               | BIT(14) /* Read */
                | 0 << 12 /* Table type 0b00 */
                | (vlan & 0xfff);
        rtl838x_exec_tbl0_cmd(cmd);
@@ -65,8 +65,8 @@ static void rtl838x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info)
        info->fid = (v >> 5) & 0x3f;
 
 
-       cmd = 1 << 15 /* Execute cmd */
-               | 1 << 14 /* Read */
+       cmd = BIT(15) /* Execute cmd */
+               | BIT(14) /* Read */
                | 0 << 12 /* Table type 0b00 */
                | (vlan & 0xfff);
        rtl838x_exec_tbl1_cmd(cmd);
@@ -75,7 +75,7 @@ static void rtl838x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info)
 
 static void rtl838x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info)
 {
-       u32 cmd = 1 << 15 /* Execute cmd */
+       u32 cmd = BIT(15) /* Execute cmd */
                | 0 << 14 /* Write */
                | 0 << 12 /* Table type 0b00 */
                | (vlan & 0xfff);
@@ -94,7 +94,7 @@ static void rtl838x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info)
 
 static void rtl838x_vlan_set_untagged(u32 vlan, u64 portmask)
 {
-       u32 cmd = 1 << 15 /* Execute cmd */
+       u32 cmd = BIT(15) /* Execute cmd */
                | 0 << 14 /* Write */
                | 0 << 12 /* Table type 0b00 */
                | (vlan & 0xfff);
@@ -150,13 +150,13 @@ static u64 rtl838x_read_l2_entry_using_hash(u32 hash, u32 position, struct rtl83
        /* Search in SRAM, with hash and at position in hash bucket (0-3) */
        u32 idx = (0 << 14) | (hash << 2) | position;
 
-       u32 cmd = 1 << 16 /* Execute cmd */
-               | 1 << 15 /* Read */
+       u32 cmd = BIT(16) /* Execute cmd */
+               | BIT(15) /* Read */
                | 0 << 13 /* Table type 0b00 */
                | (idx & 0x1fff);
 
        sw_w32(cmd, RTL838X_TBL_ACCESS_L2_CTRL);
-       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & (1 << 16));
+       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & BIT(16));
        r[0] = sw_r32(RTL838X_TBL_ACCESS_L2_DATA(0));
        r[1] = sw_r32(RTL838X_TBL_ACCESS_L2_DATA(1));
        r[2] = sw_r32(RTL838X_TBL_ACCESS_L2_DATA(2));
@@ -188,12 +188,12 @@ static u64 rtl838x_read_cam(int idx, struct rtl838x_l2_entry *e)
        u64 entry;
        u32 r[3];
 
-       u32 cmd = 1 << 16 /* Execute cmd */
-               | 1 << 15 /* Read */
-               | 1 << 13 /* Table type 0b01 */
+       u32 cmd = BIT(16) /* Execute cmd */
+               | BIT(15) /* Read */
+               | BIT(13) /* Table type 0b01 */
                | (idx & 0x3f);
        sw_w32(cmd, RTL838X_TBL_ACCESS_L2_CTRL);
-       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & (1 << 16));
+       do { }  while (sw_r32(RTL838X_TBL_ACCESS_L2_CTRL) & BIT(16));
        r[0] = sw_r32(RTL838X_TBL_ACCESS_L2_DATA(0));
        r[1] = sw_r32(RTL838X_TBL_ACCESS_L2_DATA(1));
        r[2] = sw_r32(RTL838X_TBL_ACCESS_L2_DATA(2));
@@ -299,9 +299,9 @@ irqreturn_t rtl838x_switch_irq(int irq, void *dev_id)
        pr_info("RTL8380 Link change: status: %x, ports %x\n", status, ports);
 
        for (i = 0; i < 28; i++) {
-               if (ports & (1 << i)) {
+               if (ports & BIT(i)) {
                        link = sw_r32(RTL838X_MAC_LINK_STS);
-                       if (link & (1 << i))
+                       if (link & BIT(i))
                                dsa_port_phylink_mac_change(ds, i, true);
                        else
                                dsa_port_phylink_mac_change(ds, i, false);
@@ -378,7 +378,7 @@ int rtl838x_write_phy(u32 port, u32 page, u32 reg, u32 val)
        if (rtl838x_smi_wait_op(10000))
                goto timeout;
 
-       sw_w32(1 << port, RTL838X_SMI_ACCESS_PHY_CTRL_0);
+       sw_w32(BIT(port), RTL838X_SMI_ACCESS_PHY_CTRL_0);
        mdelay(10);
 
        sw_w32_mask(0xffff0000, val << 16, RTL838X_SMI_ACCESS_PHY_CTRL_2);
index 53bbee56922e3d632f36eec348ffbf74dd434d2a..38b942e42646396d6f0436d05fd5bd3c56b33fb8 100644 (file)
@@ -61,13 +61,13 @@ static inline int rtl839x_port_iso_ctrl(int p)
 static inline void rtl839x_exec_tbl0_cmd(u32 cmd)
 {
        sw_w32(cmd, RTL839X_TBL_ACCESS_CTRL_0);
-       do { } while (sw_r32(RTL839X_TBL_ACCESS_CTRL_0) & (1 << 16));
+       do { } while (sw_r32(RTL839X_TBL_ACCESS_CTRL_0) & BIT(16));
 }
 
 static inline void rtl839x_exec_tbl1_cmd(u32 cmd)
 {
        sw_w32(cmd, RTL839X_TBL_ACCESS_CTRL_1);
-       do { } while (sw_r32(RTL839X_TBL_ACCESS_CTRL_1) & (1 << 16));
+       do { } while (sw_r32(RTL839X_TBL_ACCESS_CTRL_1) & BIT(16));
 }
 
 static inline int rtl839x_tbl_access_data_0(int i)
@@ -81,7 +81,7 @@ static void rtl839x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info)
        u64 v;
        u32 u, w;
 
-       cmd = 1 << 16 /* Execute cmd */
+       cmd = BIT(16) /* Execute cmd */
                | 0 << 15 /* Read */
                | 0 << 12 /* Table type 0b000 */
                | (vlan & 0xfff);
@@ -100,7 +100,7 @@ static void rtl839x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info)
        info->hash_uc = !!(u & 4);
        info->fid = (u >> 3) & 0xff;
 
-       cmd = 1 << 16 /* Execute cmd */
+       cmd = BIT(16) /* Execute cmd */
                | 0 << 15 /* Read */
                | 0 << 12 /* Table type 0b000 */
                | (vlan & 0xfff);
@@ -113,8 +113,8 @@ static void rtl839x_vlan_tables_read(u32 vlan, struct rtl838x_vlan_info *info)
 
 static void rtl839x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info)
 {
-       u32 cmd = 1 << 16 /* Execute cmd */
-               | 1 << 15 /* Write */
+       u32 cmd = BIT(16) /* Execute cmd */
+               | BIT(15) /* Write */
                | 0 << 12 /* Table type 0b00 */
                | (vlan & 0xfff);
        u32 w;
@@ -133,8 +133,8 @@ static void rtl839x_vlan_set_tagged(u32 vlan, struct rtl838x_vlan_info *info)
 
 static void rtl839x_vlan_set_untagged(u32 vlan, u64 portmask)
 {
-       u32 cmd = 1 << 16 /* Execute cmd */
-               | 1 << 15 /* Write */
+       u32 cmd = BIT(16) /* Execute cmd */
+               | BIT(15) /* Write */
                | 0 << 12 /* Table type 0b00 */
                | (vlan & 0xfff);
        rtl839x_set_port_reg_be(portmask << 11, RTL838X_TBL_ACCESS_DATA_1(0));
@@ -189,13 +189,13 @@ static u64 rtl839x_read_l2_entry_using_hash(u32 hash, u32 position, struct rtl83
        /* Search in SRAM, with hash and at position in hash bucket (0-3) */
        u32 idx = (0 << 14) | (hash << 2) | position;
 
-       u32 cmd = 1 << 17 /* Execute cmd */
+       u32 cmd = BIT(17) /* Execute cmd */
                | 0 << 16 /* Read */
                | 0 << 14 /* Table type 0b00 */
                | (idx & 0x3fff);
 
        sw_w32(cmd, RTL839X_TBL_ACCESS_L2_CTRL);
-       do { }  while (sw_r32(RTL839X_TBL_ACCESS_L2_CTRL) & (1 << 17));
+       do { }  while (sw_r32(RTL839X_TBL_ACCESS_L2_CTRL) & BIT(17));
        r[0] = sw_r32(RTL839X_TBL_ACCESS_L2_DATA(0));
        r[1] = sw_r32(RTL839X_TBL_ACCESS_L2_DATA(1));
        r[2] = sw_r32(RTL839X_TBL_ACCESS_L2_DATA(2));
@@ -203,8 +203,8 @@ static u64 rtl839x_read_l2_entry_using_hash(u32 hash, u32 position, struct rtl83
        /* Table contains different entry types, we need to identify the right one:
         * Check for MC entries, first
         */
-       e->is_ip_mc = !!(r[2] & (1 << 31));
-       e->is_ipv6_mc = !!(r[2] & (1 << 30));
+       e->is_ip_mc = !!(r[2] & BIT(31));
+       e->is_ipv6_mc = !!(r[2] & BIT(30));
        e->type = L2_INVALID;
        if (!e->is_ip_mc) {
                e->mac[0] = (r[0] >> 12);
@@ -220,10 +220,10 @@ static u64 rtl839x_read_l2_entry_using_hash(u32 hash, u32 position, struct rtl83
                        e->vid = (r[2] >> 4) & 0xfff;
                        e->rvid = (r[0] >> 20) & 0xfff;
                        e->port = (r[2] >> 24) & 0x3f;
-                       e->block_da = !!(r[2] & (1 << 19));
-                       e->block_sa = !!(r[2] & (1 << 20));
-                       e->suspended = !!(r[2] & (1 << 17));
-                       e->next_hop = !!(r[2] & (1 << 16));
+                       e->block_da = !!(r[2] & BIT(19));
+                       e->block_sa = !!(r[2] & BIT(20));
+                       e->suspended = !!(r[2] & BIT(17));
+                       e->next_hop = !!(r[2] & BIT(16));
                        if (e->next_hop)
                                pr_info("Found next hop entry, need to read data\n");
                        e->age = (r[2] >> 21) & 3;
@@ -256,12 +256,12 @@ static u64 rtl839x_read_cam(int idx, struct rtl838x_l2_entry *e)
        u64 entry;
        u32 r[3];
 
-       u32 cmd = 1 << 17 /* Execute cmd */
+       u32 cmd = BIT(17) /* Execute cmd */
                | 0 << 16 /* Read */
-               | 1 << 14 /* Table type 0b01 */
+               | BIT(14) /* Table type 0b01 */
                | (idx & 0x3f);
        sw_w32(cmd, RTL839X_TBL_ACCESS_L2_CTRL);
-       do { }  while (sw_r32(RTL839X_TBL_ACCESS_L2_CTRL) & (1 << 17));
+       do { }  while (sw_r32(RTL839X_TBL_ACCESS_L2_CTRL) & BIT(17));
        r[0] = sw_r32(RTL839X_TBL_ACCESS_L2_DATA(0));
        r[1] = sw_r32(RTL839X_TBL_ACCESS_L2_DATA(1));
        r[2] = sw_r32(RTL839X_TBL_ACCESS_L2_DATA(2));
@@ -392,7 +392,7 @@ int rtl8390_sds_power(int mac, int val)
        }
 
        // Set bit 1003. 1000 starts at 7c
-       sw_w32_mask(1 << 11, mode << 11, RTL839X_SDS12_13_PWR0 + offset);
+       sw_w32_mask(BIT(11), mode << 11, RTL839X_SDS12_13_PWR0 + offset);
 
        return 0;
 }
@@ -437,7 +437,7 @@ int rtl839x_write_phy(u32 port, u32 page, u32 reg, u32 val)
        /* Clear both port registers */
        sw_w32(0, RTL839X_PHYREG_PORT_CTRL(0));
        sw_w32(0, RTL839X_PHYREG_PORT_CTRL(0) + 4);
-       sw_w32_mask(0, 1 << port, RTL839X_PHYREG_PORT_CTRL(port));
+       sw_w32_mask(0, BIT(port), RTL839X_PHYREG_PORT_CTRL(port));
 
        sw_w32_mask(0xffff0000, val << 16, RTL839X_PHYREG_DATA_CTRL);
 
@@ -446,7 +446,7 @@ int rtl839x_write_phy(u32 port, u32 page, u32 reg, u32 val)
 
        sw_w32(0x1ff, RTL839X_PHYREG_CTRL);
 
-       v |= 1 << 3 | 1; /* Write operation and execute */
+       v |= BIT(3) | 1; /* Write operation and execute */
        sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL);
 
        do {
index 3a28c45fc4f04a86db926c840a839889ee48d3af..9789459b1d4d1011b32cd79cc2d8e54fe3641e83 100644 (file)
@@ -31,9 +31,9 @@ void __init rtl83xx_storm_control_init(struct rtl838x_switch_priv *priv)
        sw_w32(0x00200020, RTL838X_STORM_CTRL_BURST_PPS_1); // MC and BC
 
        // Include IFG in storm control
-       sw_w32_mask(0, 1 << 6, RTL838X_STORM_CTRL);
+       sw_w32_mask(0, BIT(6), RTL838X_STORM_CTRL);
        // Rate control is based on bytes/s (0 = packets)
-       sw_w32_mask(0, 1 << 5, RTL838X_STORM_CTRL);
+       sw_w32_mask(0, BIT(5), RTL838X_STORM_CTRL);
        // Bandwidth control includes preamble and IFG (10 Bytes)
        sw_w32_mask(0, 1, RTL838X_SCHED_CTRL);
 
@@ -45,8 +45,8 @@ void __init rtl83xx_storm_control_init(struct rtl838x_switch_priv *priv)
         * for UC and MC for both known and unknown addresses */
        for (i = 0; i < priv->cpu_port; i++) {
                if (priv->ports[i].phy) {
-                       sw_w32((1 << 18) | 0x8000, RTL838X_STORM_CTRL_PORT_UC(i));
-                       sw_w32((1 << 18) | 0x8000, RTL838X_STORM_CTRL_PORT_MC(i));
+                       sw_w32(BIT(18) | 0x8000, RTL838X_STORM_CTRL_PORT_UC(i));
+                       sw_w32(BIT(18) | 0x8000, RTL838X_STORM_CTRL_PORT_MC(i));
                        sw_w32(0x000, RTL838X_STORM_CTRL_PORT_BC(i));
                        rtl83xx_storm_enable(priv, i, true);
                }