Skip to content

Commit 544c939

Browse files
krzkdavem330
authored andcommitted
dsa: Use str_enable_disable-like helpers
Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a12c76a commit 544c939

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

drivers/net/dsa/mv88e6xxx/pcs-639x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/interrupt.h>
1010
#include <linux/irqdomain.h>
1111
#include <linux/mii.h>
12+
#include <linux/string_choices.h>
1213

1314
#include "chip.h"
1415
#include "global2.h"
@@ -750,7 +751,7 @@ static int mv88e6393x_sgmii_apply_2500basex_an(struct mv88e639x_pcs *mpcs,
750751
if (err)
751752
dev_err(mpcs->mdio.dev.parent,
752753
"failed to %s 2500basex fix: %pe\n",
753-
enable ? "enable" : "disable", ERR_PTR(err));
754+
str_enable_disable(enable), ERR_PTR(err));
754755

755756
return err;
756757
}

drivers/net/dsa/mv88e6xxx/port.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/phy.h>
1414
#include <linux/phylink.h>
1515
#include <linux/property.h>
16+
#include <linux/string_choices.h>
1617

1718
#include "chip.h"
1819
#include "global2.h"
@@ -176,7 +177,7 @@ int mv88e6xxx_port_set_link(struct mv88e6xxx_chip *chip, int port, int link)
176177

177178
dev_dbg(chip->dev, "p%d: %s link %s\n", port,
178179
reg & MV88E6XXX_PORT_MAC_CTL_FORCE_LINK ? "Force" : "Unforce",
179-
reg & MV88E6XXX_PORT_MAC_CTL_LINK_UP ? "up" : "down");
180+
str_up_down(reg & MV88E6XXX_PORT_MAC_CTL_LINK_UP));
180181

181182
return 0;
182183
}

drivers/net/dsa/realtek/rtl8366rb.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/irqchip/chained_irq.h>
2222
#include <linux/of_irq.h>
2323
#include <linux/regmap.h>
24+
#include <linux/string_choices.h>
2425

2526
#include "realtek.h"
2627
#include "realtek-smi.h"
@@ -1522,7 +1523,7 @@ static int rtl8366rb_vlan_filtering(struct dsa_switch *ds, int port,
15221523
rb = priv->chip_data;
15231524

15241525
dev_dbg(priv->dev, "port %d: %s VLAN filtering\n", port,
1525-
vlan_filtering ? "enable" : "disable");
1526+
str_enable_disable(vlan_filtering));
15261527

15271528
/* If the port is not in the member set, the frame will be dropped */
15281529
ret = regmap_update_bits(priv->map, RTL8366RB_VLAN_INGRESS_CTRL2_REG,
@@ -1884,15 +1885,15 @@ static bool rtl8366rb_is_vlan_valid(struct realtek_priv *priv, unsigned int vlan
18841885

18851886
static int rtl8366rb_enable_vlan(struct realtek_priv *priv, bool enable)
18861887
{
1887-
dev_dbg(priv->dev, "%s VLAN\n", enable ? "enable" : "disable");
1888+
dev_dbg(priv->dev, "%s VLAN\n", str_enable_disable(enable));
18881889
return regmap_update_bits(priv->map,
18891890
RTL8366RB_SGCR, RTL8366RB_SGCR_EN_VLAN,
18901891
enable ? RTL8366RB_SGCR_EN_VLAN : 0);
18911892
}
18921893

18931894
static int rtl8366rb_enable_vlan4k(struct realtek_priv *priv, bool enable)
18941895
{
1895-
dev_dbg(priv->dev, "%s VLAN 4k\n", enable ? "enable" : "disable");
1896+
dev_dbg(priv->dev, "%s VLAN 4k\n", str_enable_disable(enable));
18961897
return regmap_update_bits(priv->map, RTL8366RB_SGCR,
18971898
RTL8366RB_SGCR_EN_VLAN_4KTB,
18981899
enable ? RTL8366RB_SGCR_EN_VLAN_4KTB : 0);

0 commit comments

Comments
 (0)