summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2016-04-30 12:13:20 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-04-30 17:04:45 -0400
commitbd83a4ab569ddfc71a82fb0dd002f353b67df7df (patch)
treec812c9d780a1a8d17199c421170ad21b1a93f7de /drivers/char
parentea37a6b8a0b9fbe3f85b4b9da3206c28f1de6f8e (diff)
char: xillybus: use devm_add_action_or_reset
If devm_add_action() fails we are explicitly calling dma_unmap_single(), pci_unmap_single() and kfree(). Lets use the helper devm_add_action_or_reset() and return directly in case of error, as we know that the cleanup function has been already called by the helper if there was any error. At that same time remove the variable rc which becomes unused now. Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/xillybus/xillybus_of.c11
-rw-r--r--drivers/char/xillybus/xillybus_pcie.c10
2 files changed, 2 insertions, 19 deletions
diff --git a/drivers/char/xillybus/xillybus_of.c b/drivers/char/xillybus/xillybus_of.c
index 781865084dc1..78a492f5acfb 100644
--- a/drivers/char/xillybus/xillybus_of.c
+++ b/drivers/char/xillybus/xillybus_of.c
@@ -81,7 +81,6 @@ static int xilly_map_single_of(struct xilly_endpoint *ep,
81{ 81{
82 dma_addr_t addr; 82 dma_addr_t addr;
83 struct xilly_mapping *this; 83 struct xilly_mapping *this;
84 int rc;
85 84
86 this = kzalloc(sizeof(*this), GFP_KERNEL); 85 this = kzalloc(sizeof(*this), GFP_KERNEL);
87 if (!this) 86 if (!this)
@@ -101,15 +100,7 @@ static int xilly_map_single_of(struct xilly_endpoint *ep,
101 100
102 *ret_dma_handle = addr; 101 *ret_dma_handle = addr;
103 102
104 rc = devm_add_action(ep->dev, xilly_of_unmap, this); 103 return devm_add_action_or_reset(ep->dev, xilly_of_unmap, this);
105
106 if (rc) {
107 dma_unmap_single(ep->dev, addr, size, direction);
108 kfree(this);
109 return rc;
110 }
111
112 return 0;
113} 104}
114 105
115static struct xilly_endpoint_hardware of_hw = { 106static struct xilly_endpoint_hardware of_hw = {
diff --git a/drivers/char/xillybus/xillybus_pcie.c b/drivers/char/xillybus/xillybus_pcie.c
index 9418300214e9..dff2d1538164 100644
--- a/drivers/char/xillybus/xillybus_pcie.c
+++ b/drivers/char/xillybus/xillybus_pcie.c
@@ -98,7 +98,6 @@ static int xilly_map_single_pci(struct xilly_endpoint *ep,
98 int pci_direction; 98 int pci_direction;
99 dma_addr_t addr; 99 dma_addr_t addr;
100 struct xilly_mapping *this; 100 struct xilly_mapping *this;
101 int rc;
102 101
103 this = kzalloc(sizeof(*this), GFP_KERNEL); 102 this = kzalloc(sizeof(*this), GFP_KERNEL);
104 if (!this) 103 if (!this)
@@ -120,14 +119,7 @@ static int xilly_map_single_pci(struct xilly_endpoint *ep,
120 119
121 *ret_dma_handle = addr; 120 *ret_dma_handle = addr;
122 121
123 rc = devm_add_action(ep->dev, xilly_pci_unmap, this); 122 return devm_add_action_or_reset(ep->dev, xilly_pci_unmap, this);
124 if (rc) {
125 pci_unmap_single(ep->pdev, addr, size, pci_direction);
126 kfree(this);
127 return rc;
128 }
129
130 return 0;
131} 123}
132 124
133static struct xilly_endpoint_hardware pci_hw = { 125static struct xilly_endpoint_hardware pci_hw = {