]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: lan966x: cleanup error handling in lan966x_fdma_rx_alloc_page_pool()
authorDan Carpenter <error27@gmail.com>
Thu, 21 May 2026 12:49:36 +0000 (15:49 +0300)
committerJakub Kicinski <kuba@kernel.org>
Mon, 25 May 2026 19:54:37 +0000 (12:54 -0700)
This code works, but there are a few things to tidy up:
1. No need to an unlikely() because IS_ERR() already has an unlikely()
   built in.
2. No need to use PTR_ERR_OR_ZERO() because it's not an error pointer.
3. Use the returned error code directly instead of using groveling in
   rx->page_pool to find it.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Link: https://patch.msgid.link/ag7_YBWRpRmY9MGT@stanley.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

index f8ce735a7fc090f6c3e2527124cc9d8657a579dd..2d1c38289bb4918e461e6b369cb803111a07c5b8 100644 (file)
@@ -91,7 +91,7 @@ static int lan966x_fdma_rx_alloc_page_pool(struct lan966x_rx *rx)
                pp_params.dma_dir = DMA_BIDIRECTIONAL;
 
        rx->page_pool = page_pool_create(&pp_params);
-       if (unlikely(IS_ERR(rx->page_pool)))
+       if (IS_ERR(rx->page_pool))
                return PTR_ERR(rx->page_pool);
 
        for (int i = 0; i < lan966x->num_phys_ports; ++i) {
@@ -106,7 +106,7 @@ static int lan966x_fdma_rx_alloc_page_pool(struct lan966x_rx *rx)
                                           rx->page_pool);
        }
 
-       return PTR_ERR_OR_ZERO(rx->page_pool);
+       return 0;
 }
 
 static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx)
@@ -115,8 +115,9 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx)
        struct fdma *fdma = &rx->fdma;
        int err;
 
-       if (lan966x_fdma_rx_alloc_page_pool(rx))
-               return PTR_ERR(rx->page_pool);
+       err = lan966x_fdma_rx_alloc_page_pool(rx);
+       if (err)
+               return err;
 
        err = fdma_alloc_coherent(lan966x->dev, fdma);
        if (err) {