Message ID | 1344008414-2894-3-git-send-email-damien.cassou@lifl.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 08/03/2012 03:40 PM, Damien Cassou wrote: > From: Damien Cassou <damien.cassou@lifl.fr> > > The various devm_ functions allocate memory that is released when a driver > detaches. This patch uses these functions for data that is allocated in the > probe function of a platform device and is only freed in the remove function. > > Signed-off-by: Damien Cassou <damien.cassou@lifl.fr> Applied. Thanks, Florian Tobias Schandinat > > --- > drivers/video/jz4740_fb.c | 22 ++++++---------------- > 1 file changed, 6 insertions(+), 16 deletions(-) > > diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c > index de36693..7669770 100644 > --- a/drivers/video/jz4740_fb.c > +++ b/drivers/video/jz4740_fb.c > @@ -659,25 +659,25 @@ static int __devinit jzfb_probe(struct platform_device *pdev) > jzfb->pdata = pdata; > jzfb->mem = mem; > > - jzfb->ldclk = clk_get(&pdev->dev, "lcd"); > + jzfb->ldclk = devm_clk_get(&pdev->dev, "lcd"); > if (IS_ERR(jzfb->ldclk)) { > ret = PTR_ERR(jzfb->ldclk); > dev_err(&pdev->dev, "Failed to get lcd clock: %d\n", ret); > goto err_framebuffer_release; > } > > - jzfb->lpclk = clk_get(&pdev->dev, "lcd_pclk"); > + jzfb->lpclk = devm_clk_get(&pdev->dev, "lcd_pclk"); > if (IS_ERR(jzfb->lpclk)) { > ret = PTR_ERR(jzfb->lpclk); > dev_err(&pdev->dev, "Failed to get lcd pixel clock: %d\n", ret); > - goto err_put_ldclk; > + goto err_framebuffer_release; > } > > - jzfb->base = ioremap(mem->start, resource_size(mem)); > + jzfb->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); > if (!jzfb->base) { > dev_err(&pdev->dev, "Failed to ioremap register memory region\n"); > ret = -EBUSY; > - goto err_put_lpclk; > + goto err_framebuffer_release; > } > > platform_set_drvdata(pdev, jzfb); > @@ -693,7 +693,7 @@ static int __devinit jzfb_probe(struct platform_device *pdev) > ret = jzfb_alloc_devmem(jzfb); > if (ret) { > dev_err(&pdev->dev, "Failed to allocate video memory\n"); > - goto err_iounmap; > + goto err_framebuffer_release; > } > > fb->fix = jzfb_fix; > @@ -734,12 +734,6 @@ err_free_devmem: > > fb_dealloc_cmap(&fb->cmap); > jzfb_free_devmem(jzfb); > -err_iounmap: > - iounmap(jzfb->base); > -err_put_lpclk: > - clk_put(jzfb->lpclk); > -err_put_ldclk: > - clk_put(jzfb->ldclk); > err_framebuffer_release: > framebuffer_release(fb); > err_release_mem_region: > @@ -756,7 +750,6 @@ static int __devexit jzfb_remove(struct platform_device *pdev) > jz_gpio_bulk_free(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); > jz_gpio_bulk_free(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); > > - iounmap(jzfb->base); > release_mem_region(jzfb->mem->start, resource_size(jzfb->mem)); > > fb_dealloc_cmap(&jzfb->fb->cmap); > @@ -764,9 +757,6 @@ static int __devexit jzfb_remove(struct platform_device *pdev) > > platform_set_drvdata(pdev, NULL); > > - clk_put(jzfb->lpclk); > - clk_put(jzfb->ldclk); > - > framebuffer_release(jzfb->fb); > > return 0; > -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/23/2012 10:41 PM, Florian Tobias Schandinat wrote: > On 08/03/2012 03:40 PM, Damien Cassou wrote: >> From: Damien Cassou <damien.cassou@lifl.fr> >> >> The various devm_ functions allocate memory that is released when a driver >> detaches. This patch uses these functions for data that is allocated in the >> probe function of a platform device and is only freed in the remove function. >> >> Signed-off-by: Damien Cassou <damien.cassou@lifl.fr> > > Applied. > > > Thanks, > > Florian Tobias Schandinat > >> >> --- >> drivers/video/jz4740_fb.c | 22 ++++++---------------- >> 1 file changed, 6 insertions(+), 16 deletions(-) >> >> diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c >> index de36693..7669770 100644 >> --- a/drivers/video/jz4740_fb.c >> +++ b/drivers/video/jz4740_fb.c >> @@ -659,25 +659,25 @@ static int __devinit jzfb_probe(struct platform_device *pdev) >> jzfb->pdata = pdata; >> jzfb->mem = mem; >> >> - jzfb->ldclk = clk_get(&pdev->dev, "lcd"); >> + jzfb->ldclk = devm_clk_get(&pdev->dev, "lcd"); I guess I'm a bit late, but we do not have devm_clk_get on jz4740 (yet), so this patch breaks linking for this driver in next. I'll to to have this added for the next release, but if I do not succeed we'll have to revert part of this patch. Also the driver does not include #include <linux/io.h>, since it is required for devm_ioremap compilation is also broken. This one is easy to fix though, will send a follow-up patch. - Lars -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c index de36693..7669770 100644 --- a/drivers/video/jz4740_fb.c +++ b/drivers/video/jz4740_fb.c @@ -659,25 +659,25 @@ static int __devinit jzfb_probe(struct platform_device *pdev) jzfb->pdata = pdata; jzfb->mem = mem; - jzfb->ldclk = clk_get(&pdev->dev, "lcd"); + jzfb->ldclk = devm_clk_get(&pdev->dev, "lcd"); if (IS_ERR(jzfb->ldclk)) { ret = PTR_ERR(jzfb->ldclk); dev_err(&pdev->dev, "Failed to get lcd clock: %d\n", ret); goto err_framebuffer_release; } - jzfb->lpclk = clk_get(&pdev->dev, "lcd_pclk"); + jzfb->lpclk = devm_clk_get(&pdev->dev, "lcd_pclk"); if (IS_ERR(jzfb->lpclk)) { ret = PTR_ERR(jzfb->lpclk); dev_err(&pdev->dev, "Failed to get lcd pixel clock: %d\n", ret); - goto err_put_ldclk; + goto err_framebuffer_release; } - jzfb->base = ioremap(mem->start, resource_size(mem)); + jzfb->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem)); if (!jzfb->base) { dev_err(&pdev->dev, "Failed to ioremap register memory region\n"); ret = -EBUSY; - goto err_put_lpclk; + goto err_framebuffer_release; } platform_set_drvdata(pdev, jzfb); @@ -693,7 +693,7 @@ static int __devinit jzfb_probe(struct platform_device *pdev) ret = jzfb_alloc_devmem(jzfb); if (ret) { dev_err(&pdev->dev, "Failed to allocate video memory\n"); - goto err_iounmap; + goto err_framebuffer_release; } fb->fix = jzfb_fix; @@ -734,12 +734,6 @@ err_free_devmem: fb_dealloc_cmap(&fb->cmap); jzfb_free_devmem(jzfb); -err_iounmap: - iounmap(jzfb->base); -err_put_lpclk: - clk_put(jzfb->lpclk); -err_put_ldclk: - clk_put(jzfb->ldclk); err_framebuffer_release: framebuffer_release(fb); err_release_mem_region: @@ -756,7 +750,6 @@ static int __devexit jzfb_remove(struct platform_device *pdev) jz_gpio_bulk_free(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); jz_gpio_bulk_free(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); - iounmap(jzfb->base); release_mem_region(jzfb->mem->start, resource_size(jzfb->mem)); fb_dealloc_cmap(&jzfb->fb->cmap); @@ -764,9 +757,6 @@ static int __devexit jzfb_remove(struct platform_device *pdev) platform_set_drvdata(pdev, NULL); - clk_put(jzfb->lpclk); - clk_put(jzfb->ldclk); - framebuffer_release(jzfb->fb); return 0;