From: Michal Simek <hidden> Date: 2013-10-09 10:52:31
devm_iounmap is called automatically that's why remove it from the code
dev_set_drvdata(dev, NULL) is called by generic code
after device_release or on probe failure.
Signed-off-by: Michal Simek <redacted>
Reviewed-by: Jingoo Han <redacted>
---
Changes in v2:
Rebased on git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git for-next
drivers/video/xilinxfb.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
@@ -260,10 +260,9 @@ 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)){-rc=PTR_ERR(drvdata->regs);-gotoerr_region;-}+if(IS_ERR(drvdata->regs))+returnPTR_ERR(drvdata->regs);+drvdata->regs_phys=res->start;}
@@ -279,11 +278,7 @@ static int xilinxfb_assign(struct platform_device *pdev,if(!drvdata->fb_virt){dev_err(dev,"Could not allocate frame buffer memory\n");-rc=-ENOMEM;-if(drvdata->flags&BUS_ACCESS_FLAG)-gotoerr_fbmem;-else-gotoerr_region;+return-ENOMEM;}/* Clear (turn to black) the framebuffer */
@@ -363,11 +358,6 @@ 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:returnrc;}
@@ -392,11 +382,9 @@ static int xilinxfb_release(struct device *dev)/* Turn off the display */xilinx_fb_out32(drvdata,REG_CTRL,0);-/* Release the resources, as allocated based on interface */-if(drvdata->flags&BUS_ACCESS_FLAG)-devm_iounmap(dev,drvdata->regs);#ifdef CONFIG_PPC_DCR-else+/* Release the resources, as allocated based on interface */+if(!(drvdata->flags&BUS_ACCESS_FLAG))dcr_unmap(drvdata->dcr_host,drvdata->dcr_len);#endif--
@@ -402,8 +400,6 @@ static int xilinxfb_release(struct device *dev)dcr_unmap(drvdata->dcr_host,drvdata->dcr_len);#endif-kfree(drvdata);-return0;}
@@ -423,7 +419,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;
@@ -411,7 +411,7 @@ static int xilinxfb_release(struct device *dev)*OFbusbinding*/-staticintxilinxfb_of_probe(structplatform_device*op)+staticintxilinxfb_of_probe(structplatform_device*pdev){constu32*prop;u32tft_access=0;
@@ -425,7 +425,7 @@ static int xilinxfb_of_probe(struct platform_device *op)/* Allocate the driver data region */drvdata=kzalloc(sizeof(*drvdata),GFP_KERNEL);if(!drvdata){-dev_err(&op->dev,"Couldn't allocate device private record\n");+dev_err(&pdev->dev,"Couldn't allocate device private record\n");return-ENOMEM;}
@@ -433,7 +433,7 @@ static int xilinxfb_of_probe(struct platform_device *op)*TocheckwhetherthecoreisconnecteddirectlytoDCRorBUS*interfaceandinitializethetft_accessaccordingly.*/-of_property_read_u32(op->dev.of_node,"xlnx,dcr-splb-slave-if",+of_property_read_u32(pdev->dev.of_node,"xlnx,dcr-splb-slave-if",&tft_access);/*
@@ -457,29 +457,29 @@ static int xilinxfb_of_probe(struct platform_device *op)}#endif-prop=of_get_property(op->dev.of_node,"phys-size",&size);+prop=of_get_property(pdev->dev.of_node,"phys-size",&size);if((prop)&&(size>=sizeof(u32)*2)){pdata.screen_width_mm=prop[0];pdata.screen_height_mm=prop[1];}
While you're changing these lines, it would be nice to change this
pattern (here and elsewhere) to use of_property_read_u32_array, so that
it's endian-safe and consistent with other devicetree parsing code:
of_property_read_u32_array(pdev->dev.of_node, "phys-size", prop, 2);
It won't read the values if the property data's too short, so that
should be consistent with the existing code.
It would also make the diffstat negative :)
Similarly, this could use of_property_read_bool:
pdata.rotate_screen = of_property_read_bool(pdev->dev.of_node,
"rotate-display");
It won't help the diffstat, but it makes the intent clearer.
Cheers,
Mark.
@@ -411,7 +411,7 @@ static int xilinxfb_release(struct device *dev)*OFbusbinding*/-staticintxilinxfb_of_probe(structplatform_device*op)+staticintxilinxfb_of_probe(structplatform_device*pdev){constu32*prop;u32tft_access=0;
@@ -425,7 +425,7 @@ static int xilinxfb_of_probe(struct platform_device *op)/* Allocate the driver data region */drvdata=kzalloc(sizeof(*drvdata),GFP_KERNEL);if(!drvdata){-dev_err(&op->dev,"Couldn't allocate device private record\n");+dev_err(&pdev->dev,"Couldn't allocate device private record\n");return-ENOMEM;}
@@ -433,7 +433,7 @@ static int xilinxfb_of_probe(struct platform_device *op)*TocheckwhetherthecoreisconnecteddirectlytoDCRorBUS*interfaceandinitializethetft_accessaccordingly.*/-of_property_read_u32(op->dev.of_node,"xlnx,dcr-splb-slave-if",+of_property_read_u32(pdev->dev.of_node,"xlnx,dcr-splb-slave-if",&tft_access);/*
@@ -457,29 +457,29 @@ static int xilinxfb_of_probe(struct platform_device *op)}#endif-prop=of_get_property(op->dev.of_node,"phys-size",&size);+prop=of_get_property(pdev->dev.of_node,"phys-size",&size);if((prop)&&(size>=sizeof(u32)*2)){pdata.screen_width_mm=prop[0];pdata.screen_height_mm=prop[1];}
While you're changing these lines, it would be nice to change this
pattern (here and elsewhere) to use of_property_read_u32_array, so that
it's endian-safe and consistent with other devicetree parsing code:
of_property_read_u32_array(pdev->dev.of_node, "phys-size", prop, 2);
It won't read the values if the property data's too short, so that
should be consistent with the existing code.
It would also make the diffstat negative :)
The intention of this patch is simple rename which is exactly how
patch should look like. It means one change per patch.
It means these changes you have describe should be in separate patch
and I definitely agree with them.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
@@ -423,7 +419,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");
Be nice to remove the unnecessary OOM message.
There's already a generic dump_stack on OOM.
Ah yeah - this series was made before I knew this.
Will send v3.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform