From nobody Sun Feb 8 06:00:05 2026 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 B61D1C2EA for ; Sat, 10 Jan 2026 02:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768012131; cv=none; b=fSlzoDAptS/iGcdWTsyWiE6pIbpjVbLqde+i9A7b4fHN1l5bWYmfNq90C+fMcHgXu+cAfXJNLjH84Vq2fpmnQ/l48frqQOsXom7LKoAHqrnXEAhOcad4+6ucB50IsQ+u5IoQFkPI6RwLhlBqhk82DZ60cE5Y457F1eriK4jcCPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768012131; c=relaxed/simple; bh=Dnxh8sb29haGhCiOAryzaMc9erxkIKQTcrK4cP1kif0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=c1ubhf07fM+m3UfkkZ4S6uNfoD5Y79kZfCKvzg6dAk4oYTvmeJ/DbhVwSeX0zAPex/peBxcE3IUJ1fkLKHoSaMh9Qd32x33Y1Hh/SpP42vtgbt5V9TtSxafBUA9LGlTsW5i/7ShD7YwzH2kZ9w8vD2TCaFFptHjEC4su/4rBYUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp; spf=pass smtp.mailfrom=0x0f.com; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b=ah4Qwaf/; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=thingy.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0x0f.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=thingy.jp header.i=@thingy.jp header.b="ah4Qwaf/" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-34b75fba315so2960909a91.3 for ; Fri, 09 Jan 2026 18:28:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thingy.jp; s=google; t=1768012129; x=1768616929; 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=Mg1KQlHbkSdYgtTHkTb4TEaugE2VkLT6mkvL0fKcs9U=; b=ah4Qwaf/NPNgT+u65jSzLIP2XzHwRfKU3xnVyO3V6GKq3hutCN+WUqT7zZOaOcwz+7 NFs2TZZBGx0tvD6J4LT5xTZMmLjMTDJYUemtfmxyJAiD2y9ipNI/QguAVSZQ8nd3eVfF CT2Ta3s0RoRuJsRh2eU67hEL+ib3+WBswktTs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768012129; x=1768616929; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mg1KQlHbkSdYgtTHkTb4TEaugE2VkLT6mkvL0fKcs9U=; b=BREtC3bdm5SaOwBeMdCXNeZJ4UosNCaG2jDlDwMspH8Agy1TdxLbjzfZmRDysX0pYw 3Dlo67WwrYsNfC/uul5HrI1RyiKXqPF3MafelTlrAMpmBgy8MskJcxm9QSuu4zwtvVC6 Z6p9qF4DpiFASVWLt6wCudxX33WrTqHODVQmxfzfsc9BrLaLBCfXjYq3N/Fg1EPEPqP6 PclQ5PoaQg9XC4iUrFQu5OB4ldejRbPDwfdRyKBYN5gaWM4erRtgFTL//DCS9KsJGUPj ElzOZNa47EpVsAu0dR5Sk6KHS8BNVMsGGl00ITBiUkZ4UkPA5kvrGAI1kl//3rQ3miMZ ql5g== X-Gm-Message-State: AOJu0YyDKPI2erOkx1RKgQ4p4uTwCGWZOvrU3ja6Rv3r3R1uyQ04B9l8 4Ll1Z6R7k0hzibq/WFP5hwlkGIM9BO/4HowPLGF1YU0FEFMKMJM43dasYkMNeNPmoUSX307a+PM T13+z3PQ= X-Gm-Gg: AY/fxX66rJ7OaroQliFexFpNpmmAGrFTOQCRXXg7RUoLISFSOFED5JQVJT3aYpDagIG oDHfyYlBd7nFnZy+qQFJUN4AOgqzws2nVXZV9+aaV/FeFcWWB/71FzHVGBBolqC/YjI0LyKkUst 1NMmaC4SaUJlJljjqUwnub8Zp9CoTX84VwlvHc01SIRPI0otAFswaUSkRhqrCNgaJkQZmTPLTrt xMJcqgd/u+r22FiY4jD+GTGVA6gLXK4Qc509bEgZ8T1oSudITBp3GSNYYP96HCNiaoRlbQV45/W GY4zApUHNGO236Rb8WDbeD7+fPmCXfvF/eBLFbOzzLieppLT6Sy2uVO2GipBo5PUgjuHUW+aQoZ 26ZaVzOK+gEfYMbyKBWPm4jA9C/EVlBfbrLfNbVcbDeFFpnKG1JIp0HIclJHhdToOtl99dmlr+k ult5m3WUPggka1t7oT9BnNGHxtRDUT9ih6EckGf36OI5RTCEEk23Pg4eYobk7PRNq2gl4LpuTGU cI= X-Google-Smtp-Source: AGHT+IFlo/9lxdre3yXq1NOxIeo0BBIcQbZRTk47Fc9YsAHDGaTVCagUQaR7bHJjPqhAzjeRLQ5C0w== X-Received: by 2002:a17:90b:568d:b0:340:29a1:1b0c with SMTP id 98e67ed59e1d1-34f68bcf7damr12107186a91.7.1768012128887; Fri, 09 Jan 2026 18:28:48 -0800 (PST) Received: from kinako.work.home.arpa (p1536247-ipxg00c01sizuokaden.shizuoka.ocn.ne.jp. [122.26.212.247]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-34f6b7b3e7fsm4368666a91.2.2026.01.09.18.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 18:28:48 -0800 (PST) From: Daniel Palmer To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jacky_chou@aspeedtech.com, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Daniel Palmer Subject: [PATCH] net: ftgmac100: reduce calls to of_device_is_compatible() Date: Sat, 10 Jan 2026 11:28:27 +0900 Message-ID: <20260110022827.2067386-1-daniel@thingy.jp> X-Mailer: git-send-email 2.51.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" 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 --- 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 co= de 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/etherne= t/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 *p= dev) struct net_device *netdev; struct phy_device *phydev; struct ftgmac100 *priv; - struct device_node *np; + struct device_node *np =3D pdev->dev.of_node; + bool is_ast2400 =3D false; + bool is_ast2500 =3D false; + bool is_ast2600 =3D false; int err =3D 0; =20 res =3D 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; =20 - np =3D 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 =3D of_device_is_compatible(np, "aspeed,ast2400-mac"); + is_ast2500 =3D !is_ast2400 && of_device_is_compatible(np, "aspeed,ast250= 0-mac"); + is_ast2600 =3D !is_ast2500 && of_device_is_compatible(np, "aspeed,ast260= 0-mac"); + } + + if (is_ast2400 || is_ast2500 || is_ast2600) { priv->rxdes0_edorr_mask =3D BIT(30); priv->txdes0_edotr_mask =3D BIT(30); priv->is_aspeed =3D true; @@ -1948,8 +1954,7 @@ static int ftgmac100_probe(struct platform_device *pd= ev) * 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 =3D ftgmac100_setup_mdio(netdev); if (err) goto err_setup_mdio; @@ -2001,7 +2006,7 @@ static int ftgmac100_probe(struct platform_device *pd= ev) goto err_phy_connect; =20 /* 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 |=3D NETIF_F_HW_VLAN_CTAG_FILTER; =20 /* AST2400 doesn't have working HW checksum generation */ - if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac"))) + if (is_ast2400) netdev->hw_features &=3D ~NETIF_F_HW_CSUM; =20 /* 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 &=3D ~NETIF_F_HW_CSUM; =20 if (np && of_get_property(np, "no-hw-checksum", NULL)) --=20 2.51.0