]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: macb: Replace open-coded device config retrieval with of_device_get_match_data()
authorKevin Hao <haokexin@gmail.com>
Sat, 17 Jan 2026 01:46:18 +0000 (09:46 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 21 Jan 2026 02:42:37 +0000 (18:42 -0800)
Use of_device_get_match_data() to replace the open-coded method for
obtaining the device config.

Additionally, adjust the ordering of local variables to ensure
compatibility with RCS.

Signed-off-by: Kevin Hao <haokexin@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20260117-macb-v1-1-f092092d8c91@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cadence/macb_main.c

index 8135c5c2a51acf8ae6fff49159e7c4739a7c844d..effef67d80731e5cc795fcef5adc280ad931eda9 100644 (file)
@@ -5438,9 +5438,9 @@ static const struct macb_config default_gem_config = {
 
 static int macb_probe(struct platform_device *pdev)
 {
-       const struct macb_config *macb_config = &default_gem_config;
-       struct device_node *np = pdev->dev.of_node;
        struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
+       struct device_node *np = pdev->dev.of_node;
+       const struct macb_config *macb_config;
        struct clk *tsu_clk = NULL;
        phy_interface_t interface;
        struct net_device *dev;
@@ -5456,13 +5456,9 @@ static int macb_probe(struct platform_device *pdev)
        if (IS_ERR(mem))
                return PTR_ERR(mem);
 
-       if (np) {
-               const struct of_device_id *match;
-
-               match = of_match_node(macb_dt_ids, np);
-               if (match && match->data)
-                       macb_config = match->data;
-       }
+       macb_config = of_device_get_match_data(&pdev->dev);
+       if (!macb_config)
+               macb_config = &default_gem_config;
 
        err = macb_config->clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk, &tsu_clk);
        if (err)