aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uio/uio_pdrv_genirq.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-09-12 01:39:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 11:46:45 -0400
commite6789cd3dfb553077606ccafeb05e0043f072481 (patch)
treecb589b8f1a73343a8a67153a75ed9384a9cd0621 /drivers/uio/uio_pdrv_genirq.c
parent497b46dbc660d53e94abf8a46cda9747023802ba (diff)
uio: Simplify uio error path by using devres functions
Using devres functions simplify driver error path. - Use devm_kzalloc - Use devm_request_irq Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/uio/uio_pdrv_genirq.c')
-rw-r--r--drivers/uio/uio_pdrv_genirq.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 90ff17a0202f..76669313e9a7 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -112,11 +112,11 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
112 112
113 if (pdev->dev.of_node) { 113 if (pdev->dev.of_node) {
114 /* alloc uioinfo for one device */ 114 /* alloc uioinfo for one device */
115 uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL); 115 uioinfo = devm_kzalloc(&pdev->dev, sizeof(*uioinfo),
116 GFP_KERNEL);
116 if (!uioinfo) { 117 if (!uioinfo) {
117 ret = -ENOMEM;
118 dev_err(&pdev->dev, "unable to kmalloc\n"); 118 dev_err(&pdev->dev, "unable to kmalloc\n");
119 return ret; 119 return -ENOMEM;
120 } 120 }
121 uioinfo->name = pdev->dev.of_node->name; 121 uioinfo->name = pdev->dev.of_node->name;
122 uioinfo->version = "devicetree"; 122 uioinfo->version = "devicetree";
@@ -125,20 +125,19 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
125 125
126 if (!uioinfo || !uioinfo->name || !uioinfo->version) { 126 if (!uioinfo || !uioinfo->name || !uioinfo->version) {
127 dev_err(&pdev->dev, "missing platform_data\n"); 127 dev_err(&pdev->dev, "missing platform_data\n");
128 goto bad0; 128 return ret;
129 } 129 }
130 130
131 if (uioinfo->handler || uioinfo->irqcontrol || 131 if (uioinfo->handler || uioinfo->irqcontrol ||
132 uioinfo->irq_flags & IRQF_SHARED) { 132 uioinfo->irq_flags & IRQF_SHARED) {
133 dev_err(&pdev->dev, "interrupt configuration error\n"); 133 dev_err(&pdev->dev, "interrupt configuration error\n");
134 goto bad0; 134 return ret;
135 } 135 }
136 136
137 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 137 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
138 if (!priv) { 138 if (!priv) {
139 ret = -ENOMEM;
140 dev_err(&pdev->dev, "unable to kmalloc\n"); 139 dev_err(&pdev->dev, "unable to kmalloc\n");
141 goto bad0; 140 return -ENOMEM;
142 } 141 }
143 142
144 priv->uioinfo = uioinfo; 143 priv->uioinfo = uioinfo;
@@ -153,7 +152,7 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
153 uioinfo->irq = UIO_IRQ_NONE; 152 uioinfo->irq = UIO_IRQ_NONE;
154 else if (ret < 0) { 153 else if (ret < 0) {
155 dev_err(&pdev->dev, "failed to get IRQ\n"); 154 dev_err(&pdev->dev, "failed to get IRQ\n");
156 goto bad1; 155 return ret;
157 } 156 }
158 } 157 }
159 158
@@ -209,20 +208,12 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
209 ret = uio_register_device(&pdev->dev, priv->uioinfo); 208 ret = uio_register_device(&pdev->dev, priv->uioinfo);
210 if (ret) { 209 if (ret) {
211 dev_err(&pdev->dev, "unable to register uio device\n"); 210 dev_err(&pdev->dev, "unable to register uio device\n");
212 goto bad2; 211 pm_runtime_disable(&pdev->dev);
212 return ret;
213 } 213 }
214 214
215 platform_set_drvdata(pdev, priv); 215 platform_set_drvdata(pdev, priv);
216 return 0; 216 return 0;
217 bad2:
218 pm_runtime_disable(&pdev->dev);
219 bad1:
220 kfree(priv);
221 bad0:
222 /* kfree uioinfo for OF */
223 if (pdev->dev.of_node)
224 kfree(uioinfo);
225 return ret;
226} 217}
227 218
228static int uio_pdrv_genirq_remove(struct platform_device *pdev) 219static int uio_pdrv_genirq_remove(struct platform_device *pdev)
@@ -235,11 +226,6 @@ static int uio_pdrv_genirq_remove(struct platform_device *pdev)
235 priv->uioinfo->handler = NULL; 226 priv->uioinfo->handler = NULL;
236 priv->uioinfo->irqcontrol = NULL; 227 priv->uioinfo->irqcontrol = NULL;
237 228
238 /* kfree uioinfo for OF */
239 if (pdev->dev.of_node)
240 kfree(priv->uioinfo);
241
242 kfree(priv);
243 return 0; 229 return 0;
244} 230}
245 231