ar71xx: remove linux 3.18 support
[openwrt.git] / target / linux / ipq806x / patches-4.0 / 702-stmmac-move-error-path-at-the-end-of-stmmac_probe_co.patch
1 From 0149d275415cd1b2382ce94e5eb32641590097d0 Mon Sep 17 00:00:00 2001
2 From: Mathieu Olivari <mathieu@codeaurora.org>
3 Date: Fri, 8 May 2015 15:57:12 -0700
4 Subject: [PATCH 2/8] stmmac: move error path at the end of
5  stmmac_probe_config_dt()
6
7 We will want to do additional clean-up on certain errors. Therefore,
8 this change moves the error path at the end of the function for better
9 code readability.
10
11 This patch doesn't change anything functionally.
12
13 Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org>
14 ---
15  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 22 ++++++++++++++++------
16  1 file changed, 16 insertions(+), 6 deletions(-)
17
18 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
19 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
20 @@ -129,13 +129,18 @@ static int stmmac_probe_config_dt(struct
21         struct device_node *np = pdev->dev.of_node;
22         struct stmmac_dma_cfg *dma_cfg;
23         const struct of_device_id *device;
24 +       int ret;
25  
26 -       if (!np)
27 -               return -ENODEV;
28 +       if (!np) {
29 +               ret = -ENODEV;
30 +               goto err;
31 +       }
32  
33         device = of_match_device(stmmac_dt_ids, &pdev->dev);
34 -       if (!device)
35 -               return -ENODEV;
36 +       if (!device) {
37 +               ret = -ENODEV;
38 +               goto err;
39 +       }
40  
41         if (device->data) {
42                 const struct stmmac_of_data *data = device->data;
43 @@ -231,8 +236,10 @@ static int stmmac_probe_config_dt(struct
44         if (of_find_property(np, "snps,pbl", NULL)) {
45                 dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
46                                        GFP_KERNEL);
47 -               if (!dma_cfg)
48 -                       return -ENOMEM;
49 +               if (!dma_cfg) {
50 +                       ret = -ENOMEM;
51 +                       goto err;
52 +               }
53                 plat->dma_cfg = dma_cfg;
54                 of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
55                 dma_cfg->fixed_burst =
56 @@ -250,6 +257,9 @@ static int stmmac_probe_config_dt(struct
57         }
58  
59         return 0;
60 +
61 +err:
62 +       return ret;
63  }
64  #else
65  static int stmmac_probe_config_dt(struct platform_device *pdev,