blob: 8c69abc349b87e36110c9233339c3b018fd7e765 [file] [log] [blame]
Joel Stanleyd537df82019-07-31 18:56:43 +09301From aa808480fb9fa62c96bd38a83328a87971a95ed4 Mon Sep 17 00:00:00 2001
2From: Joel Stanley <joel@jms.id.au>
3Date: Wed, 31 Jul 2019 18:10:37 +0930
4Subject: [PATCH] aspeed: espi: Clean up error handling
5
6I was seeing a crash shortly after the ESPI driver failed to probe:
7
8 AST ESPI Unable to get GPIO IRQ -22
9 Trying to free nonexistent resource <000000001e6ee000-000000001e6ee1ff>
10 aspeed_espi: probe of 1e6ee000.espi failed with error -22
11
12The error handling was freeing the unallocated resource.
13
14The driver correctly makes allocations using the devm APIs. This means
15the kernel will handle cleaning up of resources on failure. This patch
16removes the unnecessary error handling.
17
18Signed-off-by: Joel Stanley <joel@jms.id.au>
19---
20 drivers/soc/aspeed/aspeed-espi.c | 30 ++++++------------------------
21 1 file changed, 6 insertions(+), 24 deletions(-)
22
23diff --git a/drivers/soc/aspeed/aspeed-espi.c b/drivers/soc/aspeed/aspeed-espi.c
24index 342d45bdbad3..2b72f05dd24f 100644
25--- a/drivers/soc/aspeed/aspeed-espi.c
26+++ b/drivers/soc/aspeed/aspeed-espi.c
27@@ -1284,17 +1284,10 @@ static int aspeed_espi_probe(struct platform_device *pdev)
28 aspeed_espi->dma_mode = 0;
29
30 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
31- if (res == NULL) {
32- dev_err(&pdev->dev, "no memory resource defined\n");
33- ret = -ENODEV;
34- goto err_free;
35- }
36-
37 aspeed_espi->reg_base = devm_ioremap_resource(&pdev->dev, res);
38- if (aspeed_espi->reg_base == NULL) {
39+ if (IS_ERR(aspeed_espi->reg_base)) {
40 dev_err(&pdev->dev, "failed to ioremap() registers\n");
41- ret = -ENODEV;
42- goto err_free_mem;
43+ return ERR_PTR(aspeed_espi->reg_base);
44 }
45
46 sysfs_bin_attr_init(&aspeed_espi->oob_channel);
47@@ -1398,15 +1391,14 @@ static int aspeed_espi_probe(struct platform_device *pdev)
48 aspeed_espi->irq = platform_get_irq(pdev, 0);
49 if (aspeed_espi->irq < 0) {
50 dev_err(&pdev->dev, "no irq specified\n");
51- ret = -ENOENT;
52- goto err_free_mem;
53+ return aspeed_espi->irq;
54 }
55
56 ret = devm_request_irq(&pdev->dev, aspeed_espi->irq, aspeed_espi_isr,
57 0, dev_name(&pdev->dev), aspeed_espi);
58 if (ret) {
59 printk("AST ESPI Unable to get IRQ");
60- goto err_free_mem;
61+ return ret;
62 }
63
64 aspeed_espi->reset = devm_reset_control_get(&pdev->dev, NULL);
65@@ -1421,7 +1413,7 @@ static int aspeed_espi_probe(struct platform_device *pdev)
66 0, dev_name(&pdev->dev), aspeed_espi);
67 if (ret) {
68 printk("AST ESPI Unable to get GPIO IRQ %d\n", ret);
69- goto err_free_mem;
70+ return ret;
71 }
72
73 aspeed_espi_ctrl_init(aspeed_espi);
74@@ -1429,7 +1421,7 @@ static int aspeed_espi_probe(struct platform_device *pdev)
75 ret = misc_register(&aspeed_espi_misc);
76 if (ret) {
77 printk(KERN_ERR "ESPI : failed misc_register\n");
78- goto err_free_irq;
79+ return ret;
80 }
81
82 platform_set_drvdata(pdev, aspeed_espi);
83@@ -1444,16 +1436,6 @@ static int aspeed_espi_probe(struct platform_device *pdev)
84 printk(KERN_INFO "aspeed_espi: driver successfully loaded.\n");
85
86 return 0;
87-
88-err_free_irq:
89- free_irq(aspeed_espi->irq, pdev);
90-
91-err_free_mem:
92- release_mem_region(res->start, resource_size(res));
93-err_free:
94- kfree(aspeed_espi);
95-
96- return ret;
97 }
98
99 static int aspeed_espi_remove(struct platform_device *pdev)
100--
1012.20.1
102