diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /drivers/video/xilinxfb.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'drivers/video/xilinxfb.c')
-rw-r--r-- | drivers/video/xilinxfb.c | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c index 6ff1a91..84c664e 100644 --- a/drivers/video/xilinxfb.c +++ b/drivers/video/xilinxfb.c @@ -260,9 +260,10 @@ static int xilinxfb_assign(struct platform_device *pdev, res = platform_get_resource(pdev, IORESOURCE_MEM, 0); drvdata->regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(drvdata->regs)) - return PTR_ERR(drvdata->regs); - + if (IS_ERR(drvdata->regs)) { + rc = PTR_ERR(drvdata->regs); + goto err_region; + } drvdata->regs_phys = res->start; } @@ -278,7 +279,11 @@ static int xilinxfb_assign(struct platform_device *pdev, if (!drvdata->fb_virt) { dev_err(dev, "Could not allocate frame buffer memory\n"); - return -ENOMEM; + rc = -ENOMEM; + if (drvdata->flags & BUS_ACCESS_FLAG) + goto err_fbmem; + else + goto err_region; } /* Clear (turn to black) the framebuffer */ @@ -358,6 +363,14 @@ err_cmap: /* Turn off the display */ xilinx_fb_out32(drvdata, REG_CTRL, 0); +err_fbmem: + if (drvdata->flags & BUS_ACCESS_FLAG) + devm_iounmap(dev, drvdata->regs); + +err_region: + kfree(drvdata); + dev_set_drvdata(dev, NULL); + return rc; } @@ -382,12 +395,17 @@ static int xilinxfb_release(struct device *dev) /* Turn off the display */ xilinx_fb_out32(drvdata, REG_CTRL, 0); -#ifdef CONFIG_PPC_DCR /* Release the resources, as allocated based on interface */ - if (!(drvdata->flags & BUS_ACCESS_FLAG)) + if (drvdata->flags & BUS_ACCESS_FLAG) + devm_iounmap(dev, drvdata->regs); +#ifdef CONFIG_PPC_DCR + else dcr_unmap(drvdata->dcr_host, drvdata->dcr_len); #endif + kfree(drvdata); + dev_set_drvdata(dev, NULL); + return 0; } @@ -395,7 +413,7 @@ static int xilinxfb_release(struct device *dev) * OF bus binding */ -static int xilinxfb_of_probe(struct platform_device *pdev) +static int xilinxfb_of_probe(struct platform_device *op) { const u32 *prop; u32 tft_access = 0; @@ -407,15 +425,17 @@ static int xilinxfb_of_probe(struct platform_device *pdev) pdata = xilinx_fb_default_pdata; /* Allocate the driver data region */ - drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); - if (!drvdata) + drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) { + dev_err(&op->dev, "Couldn't allocate device private record\n"); return -ENOMEM; + } /* * To check whether the core is connected directly to DCR or BUS * interface and initialize the tft_access accordingly. */ - of_property_read_u32(pdev->dev.of_node, "xlnx,dcr-splb-slave-if", + of_property_read_u32(op->dev.of_node, "xlnx,dcr-splb-slave-if", &tft_access); /* @@ -428,39 +448,40 @@ static int xilinxfb_of_probe(struct platform_device *pdev) #ifdef CONFIG_PPC_DCR else { int start; - start = dcr_resource_start(pdev->dev.of_node, 0); - drvdata->dcr_len = dcr_resource_len(pdev->dev.of_node, 0); - drvdata->dcr_host = dcr_map(pdev->dev.of_node, start, drvdata->dcr_len); + start = dcr_resource_start(op->dev.of_node, 0); + drvdata->dcr_len = dcr_resource_len(op->dev.of_node, 0); + drvdata->dcr_host = dcr_map(op->dev.of_node, start, drvdata->dcr_len); if (!DCR_MAP_OK(drvdata->dcr_host)) { - dev_err(&pdev->dev, "invalid DCR address\n"); + dev_err(&op->dev, "invalid DCR address\n"); + kfree(drvdata); return -ENODEV; } } #endif - prop = of_get_property(pdev->dev.of_node, "phys-size", &size); + prop = of_get_property(op->dev.of_node, "phys-size", &size); if ((prop) && (size >= sizeof(u32)*2)) { pdata.screen_width_mm = prop[0]; pdata.screen_height_mm = prop[1]; } - prop = of_get_property(pdev->dev.of_node, "resolution", &size); + prop = of_get_property(op->dev.of_node, "resolution", &size); if ((prop) && (size >= sizeof(u32)*2)) { pdata.xres = prop[0]; pdata.yres = prop[1]; } - prop = of_get_property(pdev->dev.of_node, "virtual-resolution", &size); + prop = of_get_property(op->dev.of_node, "virtual-resolution", &size); if ((prop) && (size >= sizeof(u32)*2)) { pdata.xvirt = prop[0]; pdata.yvirt = prop[1]; } - if (of_find_property(pdev->dev.of_node, "rotate-display", NULL)) + if (of_find_property(op->dev.of_node, "rotate-display", NULL)) pdata.rotate_screen = 1; - dev_set_drvdata(&pdev->dev, drvdata); - return xilinxfb_assign(pdev, drvdata, &pdata); + dev_set_drvdata(&op->dev, drvdata); + return xilinxfb_assign(op, drvdata, &pdata); } static int xilinxfb_of_remove(struct platform_device *op) |