[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260110022827.2067386-1-daniel@thingy.jp>
Date: Sat, 10 Jan 2026 11:28:27 +0900
From: Daniel Palmer <daniel@...ngy.jp>
To: andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
jacky_chou@...eedtech.com,
netdev@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Daniel Palmer <daniel@...ngy.jp>
Subject: [PATCH] net: ftgmac100: reduce calls to of_device_is_compatible()
ftgmac100_probe() calls of_device_is_compatible() with the same arguments
multiple times.
Just call of_device_is_compatible() once for each variant, save the result
into a local variable and use the variable instead.
Signed-off-by: Daniel Palmer <daniel@...ngy.jp>
---
I am looking through callers to of_device_is_compatible() and noticed this.
I have build tested but I don't have this hardware so I haven't tested if
it works or not. I don't see why it wouldn't. This only saves 8 bytes of code
in my build so its not massive but I think the code makes more sense after
this.
drivers/net/ethernet/faraday/ftgmac100.c | 25 ++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index a863f7841210..1588d3c79ddf 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1840,7 +1840,10 @@ static int ftgmac100_probe(struct platform_device *pdev)
struct net_device *netdev;
struct phy_device *phydev;
struct ftgmac100 *priv;
- struct device_node *np;
+ struct device_node *np = pdev->dev.of_node;
+ bool is_ast2400 = false;
+ bool is_ast2500 = false;
+ bool is_ast2600 = false;
int err = 0;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1900,10 +1903,13 @@ static int ftgmac100_probe(struct platform_device *pdev)
if (err)
goto err_phy_connect;
- np = pdev->dev.of_node;
- if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
- of_device_is_compatible(np, "aspeed,ast2500-mac") ||
- of_device_is_compatible(np, "aspeed,ast2600-mac"))) {
+ if (np) {
+ is_ast2400 = of_device_is_compatible(np, "aspeed,ast2400-mac");
+ is_ast2500 = !is_ast2400 && of_device_is_compatible(np, "aspeed,ast2500-mac");
+ is_ast2600 = !is_ast2500 && of_device_is_compatible(np, "aspeed,ast2600-mac");
+ }
+
+ if (is_ast2400 || is_ast2500 || is_ast2600) {
priv->rxdes0_edorr_mask = BIT(30);
priv->txdes0_edotr_mask = BIT(30);
priv->is_aspeed = true;
@@ -1948,8 +1954,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
* available PHYs and register them.
*/
if (of_get_property(np, "phy-handle", NULL) &&
- (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
- of_device_is_compatible(np, "aspeed,ast2500-mac"))) {
+ (is_ast2400 || is_ast2500)) {
err = ftgmac100_setup_mdio(netdev);
if (err)
goto err_setup_mdio;
@@ -2001,7 +2006,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
goto err_phy_connect;
/* Disable ast2600 problematic HW arbitration */
- if (of_device_is_compatible(np, "aspeed,ast2600-mac"))
+ if (is_ast2600)
iowrite32(FTGMAC100_TM_DEFAULT,
priv->base + FTGMAC100_OFFSET_TM);
}
@@ -2019,11 +2024,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
/* AST2400 doesn't have working HW checksum generation */
- if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac")))
+ if (is_ast2400)
netdev->hw_features &= ~NETIF_F_HW_CSUM;
/* AST2600 tx checksum with NCSI is broken */
- if (priv->use_ncsi && of_device_is_compatible(np, "aspeed,ast2600-mac"))
+ if (priv->use_ncsi && is_ast2600)
netdev->hw_features &= ~NETIF_F_HW_CSUM;
if (np && of_get_property(np, "no-hw-checksum", NULL))
--
2.51.0
Powered by blists - more mailing lists