]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/xillybus/xillybus_of.c
Merge tag 'microblaze-3.16-rc1' of git://git.monstr.eu/linux-2.6-microblaze into...
[karo-tx-linux.git] / drivers / staging / xillybus / xillybus_of.c
index 23a609b0ab1d5201d7ef837e8f26377da1cef6bf..46ea010b4ac65afc7eadc1d016bb062ddd01dce9 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+#include <linux/err.h>
 #include "xillybus.h"
 
 MODULE_DESCRIPTION("Xillybus driver for Open Firmware");
@@ -123,6 +124,7 @@ static int xilly_drv_probe(struct platform_device *op)
        struct xilly_endpoint *endpoint;
        int rc = 0;
        int irq;
+       struct resource res;
        struct xilly_endpoint_hardware *ephw = &of_hw;
 
        if (of_property_read_bool(dev->of_node, "dma-coherent"))
@@ -135,38 +137,26 @@ static int xilly_drv_probe(struct platform_device *op)
 
        dev_set_drvdata(dev, endpoint);
 
-       rc = of_address_to_resource(dev->of_node, 0, &endpoint->res);
+       rc = of_address_to_resource(dev->of_node, 0, &res);
        if (rc) {
                dev_warn(endpoint->dev,
                         "Failed to obtain device tree resource\n");
-               goto failed_request_regions;
+               return rc;
        }
 
-       if  (!request_mem_region(endpoint->res.start,
-                                resource_size(&endpoint->res), xillyname)) {
-               dev_err(endpoint->dev,
-                       "request_mem_region failed. Aborting.\n");
-               rc = -EBUSY;
-               goto failed_request_regions;
-       }
+       endpoint->registers = devm_ioremap_resource(dev, &res);
 
-       endpoint->registers = of_iomap(dev->of_node, 0);
-       if (!endpoint->registers) {
-               dev_err(endpoint->dev,
-                       "Failed to map I/O memory. Aborting.\n");
-               rc = -EIO;
-               goto failed_iomap0;
-       }
+       if (IS_ERR(endpoint->registers))
+               return PTR_ERR(endpoint->registers);
 
        irq = irq_of_parse_and_map(dev->of_node, 0);
 
-       rc = request_irq(irq, xillybus_isr, 0, xillyname, endpoint);
+       rc = devm_request_irq(dev, irq, xillybus_isr, 0, xillyname, endpoint);
 
        if (rc) {
                dev_err(endpoint->dev,
                        "Failed to register IRQ handler. Aborting.\n");
-               rc = -ENODEV;
-               goto failed_register_irq;
+               return -ENODEV;
        }
 
        rc = xillybus_endpoint_discovery(endpoint);
@@ -174,18 +164,8 @@ static int xilly_drv_probe(struct platform_device *op)
        if (!rc)
                return 0;
 
-       free_irq(irq, endpoint);
-
-failed_register_irq:
-       iounmap(endpoint->registers);
-failed_iomap0:
-       release_mem_region(endpoint->res.start,
-                          resource_size(&endpoint->res));
-
-failed_request_regions:
        xillybus_do_cleanup(&endpoint->cleanup, endpoint);
 
-       kfree(endpoint);
        return rc;
 }
 
@@ -193,20 +173,11 @@ static int xilly_drv_remove(struct platform_device *op)
 {
        struct device *dev = &op->dev;
        struct xilly_endpoint *endpoint = dev_get_drvdata(dev);
-       int irq = irq_of_parse_and_map(dev->of_node, 0);
 
        xillybus_endpoint_remove(endpoint);
 
-       free_irq(irq, endpoint);
-
-       iounmap(endpoint->registers);
-       release_mem_region(endpoint->res.start,
-                          resource_size(&endpoint->res));
-
        xillybus_do_cleanup(&endpoint->cleanup, endpoint);
 
-       kfree(endpoint);
-
        return 0;
 }