Simplify driver probe and release function.

Signed-off-by: Michal Simek <[email protected]>
---
 drivers/video/xilinxfb.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index 123cd70..fd9c430 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -368,7 +368,6 @@ err_fbmem:
                devm_iounmap(dev, drvdata->regs);

 err_region:
-       kfree(drvdata);
        dev_set_drvdata(dev, NULL);

        return rc;
@@ -403,7 +402,6 @@ static int xilinxfb_release(struct device *dev)
                dcr_unmap(drvdata->dcr_host, drvdata->dcr_len);
 #endif

-       kfree(drvdata);
        dev_set_drvdata(dev, NULL);

        return 0;
@@ -425,7 +423,7 @@ static int xilinxfb_of_probe(struct platform_device *pdev)
        pdata = xilinx_fb_default_pdata;

        /* Allocate the driver data region */
-       drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
+       drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
        if (!drvdata) {
                dev_err(&pdev->dev, "Couldn't allocate device private 
record\n");
                return -ENOMEM;
@@ -453,7 +451,6 @@ static int xilinxfb_of_probe(struct platform_device *pdev)
                drvdata->dcr_host = dcr_map(op->dev.of_node, start, 
drvdata->dcr_len);
                if (!DCR_MAP_OK(drvdata->dcr_host)) {
                        dev_err(&op->dev, "invalid DCR address\n");
-                       kfree(drvdata);
                        return -ENODEV;
                }
        }
--
1.8.2.3

Attachment: pgpyLuK7mC9GE.pgp
Description: PGP signature

Reply via email to