From nobody Wed Feb 5 14:15:36 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4E111D6199 for ; Wed, 15 Jan 2025 19:47:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736970435; cv=none; b=rwHcLBdj+qJmMqdjD321fvRB014F3v9iQOxxxK3ps7IPKHyslvUfUtemYacv439nZaPZ2qqKURvQhltUjZhCVNQme5p3G07B5zrjilih1wCwARSon4tSmYmX6SCJ2tSsCu2jfUio+uGg+FP9I8Cn9Pth6/bCdlnnvbpvp2RGK8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736970435; c=relaxed/simple; bh=JcoBOLlZDFxc6w3ZGGX5fV9BvtX38EbLZkkoUF0zD+0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DvEARXFhXeVGetMwBBt/5ifLXQtHWiFx6+bUUVs4ew0m8XiGbb8KoJYuflRz1c8+4gk44aEdgZ9Yfz2DbYiYOMgg7Z8lZzurtfS7gyf5WyE12sa2Hw8zCzlZ961wdx8/G0T/XfPKlYIyAJXlwvxo/YNRXuunDlCcsFmYu/GT4Ik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AQR1ihUE; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AQR1ihUE" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-43637977fa4so69855e9.3 for ; Wed, 15 Jan 2025 11:47:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736970431; x=1737575231; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+HwjLRPW3qYzmyzCBBtyVwl3HhaHmrEDtXBLyx7UHGQ=; b=AQR1ihUE504XpdQqMYZGBgU2H7V7nBkUPh4IWwVVqBGZXY4lkWk2rMprqGaiD+L7m4 KS7qI3jLRhaEGvnoMgYxnYBlRsTXpK7lhboqhN/H2d6Ka3EXp53XQotCzKkuPBPQIEUw MHFRqfi9imTX4zJ5rzGpUp23HJnNReudiwjeSYNaJRUgq6djQZZhKyq51g8ErFHBpeFs C2Ni6XWh04BN2hhtdVs3nroByFj5l7Qo6IKWbLA4RwTO0b+AdaaG5N79A1D5vwxrvZFd 16Uv2/cFtyTITA4+HBpzw8N+y6kf4IGbxYOdYO4hejbwRwQuCd8YQlOfnNe5qZOGGtzJ NDDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736970431; x=1737575231; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+HwjLRPW3qYzmyzCBBtyVwl3HhaHmrEDtXBLyx7UHGQ=; b=Q1swtRJtBvR+vK/m4yzuXqOi0yG33x8B7ZnH7GzO2HcCwTaIp++BpzFNUgtK88CFFl +u8GZxKa003xuVkmvdCfTF8QsXSEVs5NtSTTEOdn/RJAxDIDUxf+NGH+PmNqiwtUjwW0 iZSD06brzDAgy97E9unlUXHOzi9E0mzGECmMcVEXk++H6TFs52BPRH+i9ZD0hQQNYnwe cz2zgkcFb1bjZKh1FWp46ompM7KfuF7YyOYByfPeKk12SJYb7OJOpvstXcksFNJdCMsX +uZIIG6BxbPvmPR7VfuFJLRyVJhMv4COwVbctLKymNUsFppE21Bv8I+jqPOSyiyVkuKM RxgA== X-Forwarded-Encrypted: i=1; AJvYcCUFMotNbp9SgQbX8cjJxOWpdolIZmtjTv7TYOhxuByiOyggVgIKmo3j/J6IEBefMoguCdizm0rhCvsU9T0=@vger.kernel.org X-Gm-Message-State: AOJu0YzYqfjZTRZgGeDU1EmxTDbKeCHK4CkFI15sR3G3twMKQw8oEnSK cIm4KBkXuR4uEDlOED3+JSOi7SNsYwI6MVEMAmmbU4wGGtnJo0Uj2f0A8yCvGKQ= X-Gm-Gg: ASbGncsk8qLHd3m72bPJlKRUOb5BFzjyt73VHLAYxMyO/fYfO7kLCZInpWXWggqQhXA v4FyaX+E8v8d579drmFPY8M9qIWvOuQsnt7bcdCiqPHVYyQW96UCW6lTBSZb2zpEei1qQWxCfdr WuEjxy9ECwVULe8xd/d2cGq2t0iWQXNAXnPw5S2YpjETK/VjhcMT1NpThSjOZeTJU18wVrfz073 uK+feqRSNf+v/EFa75d5NgnA2VLY7NJVHBRp6bcM/ig8DlWKWuu/AmVNXciX1oHnuJcECU= X-Google-Smtp-Source: AGHT+IEwtfl9NZmzY+E0t5e6s2+QtV/BALzaojDV7VZf39tnjLx60qhVEo0NKESZxMiWM0MB4U1PZw== X-Received: by 2002:a05:600c:4e52:b0:434:a339:ec67 with SMTP id 5b1f17b1804b1-436eba35780mr99818725e9.3.1736970431127; Wed, 15 Jan 2025 11:47:11 -0800 (PST) Received: from krzk-bin.. ([178.197.223.165]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e38bd0dsm18327001f8f.45.2025.01.15.11.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 11:47:10 -0800 (PST) From: Krzysztof Kozlowski To: Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH net-next] dsa: Use str_enable_disable-like helpers Date: Wed, 15 Jan 2025 20:47:03 +0100 Message-ID: <20250115194703.117074-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Linus Walleij Reviewed-by: Vladimir Oltean --- I have more of similar patches in progress, but before I start spamming you with this let me know if you find such code more readable, specially for more complex conditions in ternary operators. drivers/net/dsa/mv88e6xxx/pcs-639x.c | 3 ++- drivers/net/dsa/mv88e6xxx/port.c | 3 ++- drivers/net/dsa/realtek/rtl8366rb.c | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/pcs-639x.c b/drivers/net/dsa/mv88e6x= xx/pcs-639x.c index d758a6c1b226..dcec8ec16394 100644 --- a/drivers/net/dsa/mv88e6xxx/pcs-639x.c +++ b/drivers/net/dsa/mv88e6xxx/pcs-639x.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 #include "chip.h" #include "global2.h" @@ -748,7 +749,7 @@ static int mv88e6393x_sgmii_apply_2500basex_an(struct m= v88e639x_pcs *mpcs, if (err) dev_err(mpcs->mdio.dev.parent, "failed to %s 2500basex fix: %pe\n", - enable ? "enable" : "disable", ERR_PTR(err)); + str_enable_disable(enable), ERR_PTR(err)); =20 return err; } diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/p= ort.c index dc777ddce1f3..66b1b7277281 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -13,6 +13,7 @@ #include #include #include +#include =20 #include "chip.h" #include "global2.h" @@ -176,7 +177,7 @@ int mv88e6xxx_port_set_link(struct mv88e6xxx_chip *chip= , int port, int link) =20 dev_dbg(chip->dev, "p%d: %s link %s\n", port, reg & MV88E6XXX_PORT_MAC_CTL_FORCE_LINK ? "Force" : "Unforce", - reg & MV88E6XXX_PORT_MAC_CTL_LINK_UP ? "up" : "down"); + str_up_down(reg & MV88E6XXX_PORT_MAC_CTL_LINK_UP)); =20 return 0; } diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/= rtl8366rb.c index 23374178a176..4c4a95d4380c 100644 --- a/drivers/net/dsa/realtek/rtl8366rb.c +++ b/drivers/net/dsa/realtek/rtl8366rb.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include "realtek.h" #include "realtek-smi.h" @@ -1522,7 +1523,7 @@ static int rtl8366rb_vlan_filtering(struct dsa_switch= *ds, int port, rb =3D priv->chip_data; =20 dev_dbg(priv->dev, "port %d: %s VLAN filtering\n", port, - vlan_filtering ? "enable" : "disable"); + str_enable_disable(vlan_filtering)); =20 /* If the port is not in the member set, the frame will be dropped */ ret =3D regmap_update_bits(priv->map, RTL8366RB_VLAN_INGRESS_CTRL2_REG, @@ -1884,7 +1885,7 @@ static bool rtl8366rb_is_vlan_valid(struct realtek_pr= iv *priv, unsigned int vlan =20 static int rtl8366rb_enable_vlan(struct realtek_priv *priv, bool enable) { - dev_dbg(priv->dev, "%s VLAN\n", enable ? "enable" : "disable"); + dev_dbg(priv->dev, "%s VLAN\n", str_enable_disable(enable)); return regmap_update_bits(priv->map, RTL8366RB_SGCR, RTL8366RB_SGCR_EN_VLAN, enable ? RTL8366RB_SGCR_EN_VLAN : 0); @@ -1892,7 +1893,7 @@ static int rtl8366rb_enable_vlan(struct realtek_priv = *priv, bool enable) =20 static int rtl8366rb_enable_vlan4k(struct realtek_priv *priv, bool enable) { - dev_dbg(priv->dev, "%s VLAN 4k\n", enable ? "enable" : "disable"); + dev_dbg(priv->dev, "%s VLAN 4k\n", str_enable_disable(enable)); return regmap_update_bits(priv->map, RTL8366RB_SGCR, RTL8366RB_SGCR_EN_VLAN_4KTB, enable ? RTL8366RB_SGCR_EN_VLAN_4KTB : 0); --=20 2.43.0