linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pxa168fb: Add .remove function
@ 2010-08-30  0:32 Haojian Zhuang
  2010-08-30  0:32 ` [PATCH] pxa168fb: fix clear operation Haojian Zhuang
  2010-08-30 17:43 ` [PATCH] pxa168fb: Add .remove function Marek Vasut
  0 siblings, 2 replies; 8+ messages in thread
From: Haojian Zhuang @ 2010-08-30  0:32 UTC (permalink / raw)
  To: linux-arm-kernel

The pxa168fb driver is missing .remove function so the framebuffer isn't
correctly shut down when the module is removed.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
 drivers/video/pxa168fb.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
index c91a7f7..ec2ddb2 100644
--- a/drivers/video/pxa168fb.c
+++ b/drivers/video/pxa168fb.c
@@ -784,12 +784,53 @@ failed:
 	return ret;
 }
 
+static int __devexit pxa168fb_remove(struct platform_device *pdev)
+{
+	struct pxa168fb_info *fbi = platform_get_drvdata(pdev);
+	struct fb_info *info;
+	int irq;
+	unsigned int data;
+
+	if (!fbi)
+		return 0;
+
+	/* disable DMA transfer */
+	data = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
+	data &= ~CFG_GRA_ENA_MASK;
+	writel(data, fbi->reg_base + LCD_SPU_DMA_CTRL0);
+
+	info = fbi->info;
+
+	unregister_framebuffer(info);
+
+	writel(GRA_FRAME_IRQ0_ENA(0x0), fbi->reg_base + SPU_IRQ_ENA);
+
+	if (info->cmap.len)
+		fb_dealloc_cmap(&info->cmap);
+
+	irq = platform_get_irq(pdev, 0);
+	free_irq(irq, fbi);
+
+	dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
+				info->screen_base, info->fix.smem_start);
+
+	iounmap(fbi->reg_base);
+
+	clk_disable(fbi->clk);
+	clk_put(fbi->clk);
+
+	framebuffer_release(info);
+
+	return 0;
+}
+
 static struct platform_driver pxa168fb_driver = {
 	.driver		= {
 		.name	= "pxa168-fb",
 		.owner	= THIS_MODULE,
 	},
 	.probe		= pxa168fb_probe,
+	.remove		= __devexit_p(pxa168fb_remove),
 };
 
 static int __devinit pxa168fb_init(void)
@@ -798,6 +839,12 @@ static int __devinit pxa168fb_init(void)
 }
 module_init(pxa168fb_init);
 
+static void __exit pxa168fb_exit(void)
+{
+	platform_driver_unregister(&pxa168fb_driver);
+}
+module_exit(pxa168fb_exit);
+
 MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com> "
 	      "Green Wan <gwan@marvell.com>");
 MODULE_DESCRIPTION("Framebuffer driver for PXA168/910");
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: fix clear operation
  2010-08-30  0:32 [PATCH] pxa168fb: Add .remove function Haojian Zhuang
@ 2010-08-30  0:32 ` Haojian Zhuang
  2010-08-30 17:44   ` Marek Vasut
  2010-09-05 11:56   ` Eric Miao
  2010-08-30 17:43 ` [PATCH] pxa168fb: Add .remove function Marek Vasut
  1 sibling, 2 replies; 8+ messages in thread
From: Haojian Zhuang @ 2010-08-30  0:32 UTC (permalink / raw)
  To: linux-arm-kernel

While fb isn't active, we should clear CFG_GRA_ENA bit. The existing code
can't clear this bit.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
---
 drivers/video/pxa168fb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
index ec2ddb2..3f112c9 100644
--- a/drivers/video/pxa168fb.c
+++ b/drivers/video/pxa168fb.c
@@ -298,8 +298,8 @@ static void set_dma_control0(struct pxa168fb_info *fbi)
 	 * Set bit to enable graphics DMA.
 	 */
 	x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
-	x |= fbi->active ? 0x00000100 : 0;
-	fbi->active = 0;
+	x &= ~CFG_GRA_ENA_MASK;
+	x |= CFG_GRA_ENA(!!fbi->active);
 
 	/*
 	 * If we are in a pseudo-color mode, we need to enable
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: Add .remove function
  2010-08-30  0:32 [PATCH] pxa168fb: Add .remove function Haojian Zhuang
  2010-08-30  0:32 ` [PATCH] pxa168fb: fix clear operation Haojian Zhuang
@ 2010-08-30 17:43 ` Marek Vasut
  2010-09-05 11:08   ` Eric Miao
  1 sibling, 1 reply; 8+ messages in thread
From: Marek Vasut @ 2010-08-30 17:43 UTC (permalink / raw)
  To: linux-arm-kernel

Dne Po 30. srpna 2010 02:32:16 Haojian Zhuang napsal(a):
> The pxa168fb driver is missing .remove function so the framebuffer isn't
> correctly shut down when the module is removed.
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
> ---
>  drivers/video/pxa168fb.c |   47
> ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 47
> insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index c91a7f7..ec2ddb2 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -784,12 +784,53 @@ failed:
>  	return ret;
>  }
> 
> +static int __devexit pxa168fb_remove(struct platform_device *pdev)
> +{
> +	struct pxa168fb_info *fbi = platform_get_drvdata(pdev);
> +	struct fb_info *info;
> +	int irq;
> +	unsigned int data;
> +
> +	if (!fbi)
> +		return 0;
> +
> +	/* disable DMA transfer */
> +	data = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
> +	data &= ~CFG_GRA_ENA_MASK;
> +	writel(data, fbi->reg_base + LCD_SPU_DMA_CTRL0);
> +
> +	info = fbi->info;
> +
> +	unregister_framebuffer(info);
> +

Haojian, is this line below correct?

If so, for this modified version, find my:

Acked-by: Marek Vasut <marek.vasut@gmail.com>

> +	writel(GRA_FRAME_IRQ0_ENA(0x0), fbi->reg_base + SPU_IRQ_ENA);
> +
> +	if (info->cmap.len)
> +		fb_dealloc_cmap(&info->cmap);
> +
> +	irq = platform_get_irq(pdev, 0);
> +	free_irq(irq, fbi);
> +
> +	dma_free_writecombine(fbi->dev, PAGE_ALIGN(info->fix.smem_len),
> +				info->screen_base, info->fix.smem_start);
> +
> +	iounmap(fbi->reg_base);
> +
> +	clk_disable(fbi->clk);
> +	clk_put(fbi->clk);
> +
> +	framebuffer_release(info);
> +
> +	return 0;
> +}
> +
>  static struct platform_driver pxa168fb_driver = {
>  	.driver		= {
>  		.name	= "pxa168-fb",
>  		.owner	= THIS_MODULE,
>  	},
>  	.probe		= pxa168fb_probe,
> +	.remove		= __devexit_p(pxa168fb_remove),
>  };
> 
>  static int __devinit pxa168fb_init(void)
> @@ -798,6 +839,12 @@ static int __devinit pxa168fb_init(void)
>  }
>  module_init(pxa168fb_init);
> 
> +static void __exit pxa168fb_exit(void)
> +{
> +	platform_driver_unregister(&pxa168fb_driver);
> +}
> +module_exit(pxa168fb_exit);
> +
>  MODULE_AUTHOR("Lennert Buytenhek <buytenh@marvell.com> "
>  	      "Green Wan <gwan@marvell.com>");
>  MODULE_DESCRIPTION("Framebuffer driver for PXA168/910");

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: fix clear operation
  2010-08-30  0:32 ` [PATCH] pxa168fb: fix clear operation Haojian Zhuang
@ 2010-08-30 17:44   ` Marek Vasut
  2010-09-05 11:56   ` Eric Miao
  1 sibling, 0 replies; 8+ messages in thread
From: Marek Vasut @ 2010-08-30 17:44 UTC (permalink / raw)
  To: linux-arm-kernel

Dne Po 30. srpna 2010 02:32:17 Haojian Zhuang napsal(a):
> While fb isn't active, we should clear CFG_GRA_ENA bit. The existing code
> can't clear this bit.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
> ---
>  drivers/video/pxa168fb.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index ec2ddb2..3f112c9 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -298,8 +298,8 @@ static void set_dma_control0(struct pxa168fb_info *fbi)
>  	 * Set bit to enable graphics DMA.
>  	 */
>  	x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
> -	x |= fbi->active ? 0x00000100 : 0;
> -	fbi->active = 0;
> +	x &= ~CFG_GRA_ENA_MASK;
> +	x |= CFG_GRA_ENA(!!fbi->active);
> 
>  	/*
>  	 * If we are in a pseudo-color mode, we need to enable

Acked-by: Marek Vasut <marek.vasut@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: Add .remove function
  2010-08-30 17:43 ` [PATCH] pxa168fb: Add .remove function Marek Vasut
@ 2010-09-05 11:08   ` Eric Miao
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Miao @ 2010-09-05 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Aug 31, 2010 at 1:43 AM, Marek Vasut <marek.vasut@gmail.com> wrote:
> Dne Po 30. srpna 2010 02:32:16 Haojian Zhuang napsal(a):
>> The pxa168fb driver is missing .remove function so the framebuffer isn't
>> correctly shut down when the module is removed.
>>
>> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
>> ---
>> ?drivers/video/pxa168fb.c | ? 47
>> ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 47
>> insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
>> index c91a7f7..ec2ddb2 100644
>> --- a/drivers/video/pxa168fb.c
>> +++ b/drivers/video/pxa168fb.c
>> @@ -784,12 +784,53 @@ failed:
>> ? ? ? return ret;
>> ?}
>>
>> +static int __devexit pxa168fb_remove(struct platform_device *pdev)
>> +{
>> + ? ? struct pxa168fb_info *fbi = platform_get_drvdata(pdev);
>> + ? ? struct fb_info *info;
>> + ? ? int irq;
>> + ? ? unsigned int data;
>> +
>> + ? ? if (!fbi)
>> + ? ? ? ? ? ? return 0;
>> +
>> + ? ? /* disable DMA transfer */
>> + ? ? data = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
>> + ? ? data &= ~CFG_GRA_ENA_MASK;
>> + ? ? writel(data, fbi->reg_base + LCD_SPU_DMA_CTRL0);
>> +
>> + ? ? info = fbi->info;
>> +
>> + ? ? unregister_framebuffer(info);
>> +
>
> Haojian, is this line below correct?
>
> If so, for this modified version, find my:
>
> Acked-by: Marek Vasut <marek.vasut@gmail.com>
>

Applied to 'devel'.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: fix clear operation
  2010-08-30  0:32 ` [PATCH] pxa168fb: fix clear operation Haojian Zhuang
  2010-08-30 17:44   ` Marek Vasut
@ 2010-09-05 11:56   ` Eric Miao
  2010-09-06 11:26     ` Haojian Zhuang
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Miao @ 2010-09-05 11:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Aug 30, 2010 at 8:32 AM, Haojian Zhuang
<haojian.zhuang@gmail.com> wrote:
> While fb isn't active, we should clear CFG_GRA_ENA bit. The existing code
> can't clear this bit.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
> ---
> ?drivers/video/pxa168fb.c | ? ?4 ++--
> ?1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index ec2ddb2..3f112c9 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -298,8 +298,8 @@ static void set_dma_control0(struct pxa168fb_info *fbi)
> ? ? ? ? * Set bit to enable graphics DMA.
> ? ? ? ? */
> ? ? ? ?x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
> - ? ? ? x |= fbi->active ? 0x00000100 : 0;
> - ? ? ? fbi->active = 0;
> + ? ? ? x &= ~CFG_GRA_ENA_MASK;
> + ? ? ? x |= CFG_GRA_ENA(!!fbi->active);

This isn't very readable. And since CFG_GRA_ENA is actually a 1-bit
field, I'd recommend to change it to something like below:

diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
index 5d786bd..59fa751 100644
--- a/drivers/video/pxa168fb.c
+++ b/drivers/video/pxa168fb.c
@@ -298,8 +298,11 @@ static void set_dma_control0(struct pxa168fb_info *fbi)
 	 * Set bit to enable graphics DMA.
 	 */
 	x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
-	x |= fbi->active ? 0x00000100 : 0;
-	fbi->active = 0;
+
+	if (fbi->active)
+		x &= ~CFG_GRA_ENA;
+	else
+		x |= CFG_GRA_ENA;

 	/*
 	 * If we are in a pseudo-color mode, we need to enable
diff --git a/drivers/video/pxa168fb.h b/drivers/video/pxa168fb.h
index eee0927..e5c34a5 100644
--- a/drivers/video/pxa168fb.h
+++ b/drivers/video/pxa168fb.h
@@ -240,8 +240,7 @@
 #define     CFG_GRA_SWAPYU_MASK			0x00000400
 #define     CFG_YUV2RGB_GRA(cvrt)		((cvrt) << 9)
 #define     CFG_YUV2RGB_GRA_MASK		0x00000200
-#define     CFG_GRA_ENA(gra)			((gra) << 8)
-#define     CFG_GRA_ENA_MASK			0x00000100
+#define     CFG_GRA_ENA				0x10000100
 /* for video part */
 #define     CFG_DMA_FTOGGLE(toggle)		((toggle) << 7)
 #define     CFG_DMA_FTOGGLE_MASK		0x00000080
>
> ? ? ? ?/*
> ? ? ? ? * If we are in a pseudo-color mode, we need to enable
> --
> 1.5.6.5
>
>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: fix clear operation
  2010-09-05 11:56   ` Eric Miao
@ 2010-09-06 11:26     ` Haojian Zhuang
  2010-09-07  2:23       ` Eric Miao
  0 siblings, 1 reply; 8+ messages in thread
From: Haojian Zhuang @ 2010-09-06 11:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Sep 5, 2010 at 7:56 PM, Eric Miao <eric.y.miao@gmail.com> wrote:
> On Mon, Aug 30, 2010 at 8:32 AM, Haojian Zhuang
> <haojian.zhuang@gmail.com> wrote:
>> While fb isn't active, we should clear CFG_GRA_ENA bit. The existing code
>> can't clear this bit.
>>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
>> ---
>> ?drivers/video/pxa168fb.c | ? ?4 ++--
>> ?1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
>> index ec2ddb2..3f112c9 100644
>> --- a/drivers/video/pxa168fb.c
>> +++ b/drivers/video/pxa168fb.c
>> @@ -298,8 +298,8 @@ static void set_dma_control0(struct pxa168fb_info *fbi)
>> ? ? ? ? * Set bit to enable graphics DMA.
>> ? ? ? ? */
>> ? ? ? ?x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
>> - ? ? ? x |= fbi->active ? 0x00000100 : 0;
>> - ? ? ? fbi->active = 0;
>> + ? ? ? x &= ~CFG_GRA_ENA_MASK;
>> + ? ? ? x |= CFG_GRA_ENA(!!fbi->active);
>
> This isn't very readable. And since CFG_GRA_ENA is actually a 1-bit
> field, I'd recommend to change it to something like below:
>
> diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
> index 5d786bd..59fa751 100644
> --- a/drivers/video/pxa168fb.c
> +++ b/drivers/video/pxa168fb.c
> @@ -298,8 +298,11 @@ static void set_dma_control0(struct pxa168fb_info *fbi)
> ? ? ? ? * Set bit to enable graphics DMA.
> ? ? ? ? */
> ? ? ? ?x = readl(fbi->reg_base + LCD_SPU_DMA_CTRL0);
> - ? ? ? x |= fbi->active ? 0x00000100 : 0;
> - ? ? ? fbi->active = 0;
> +
> + ? ? ? if (fbi->active)
> + ? ? ? ? ? ? ? x &= ~CFG_GRA_ENA;
> + ? ? ? else
> + ? ? ? ? ? ? ? x |= CFG_GRA_ENA;
>
> ? ? ? ?/*
> ? ? ? ? * If we are in a pseudo-color mode, we need to enable
> diff --git a/drivers/video/pxa168fb.h b/drivers/video/pxa168fb.h
> index eee0927..e5c34a5 100644
> --- a/drivers/video/pxa168fb.h
> +++ b/drivers/video/pxa168fb.h
> @@ -240,8 +240,7 @@
> ?#define ? ? CFG_GRA_SWAPYU_MASK ? ? ? ? ? ? ? ? ? ? ? ?0x00000400
> ?#define ? ? CFG_YUV2RGB_GRA(cvrt) ? ? ? ? ? ? ?((cvrt) << 9)
> ?#define ? ? CFG_YUV2RGB_GRA_MASK ? ? ? ? ? ? ? 0x00000200
> -#define ? ? CFG_GRA_ENA(gra) ? ? ? ? ? ? ? ? ? ((gra) << 8)
> -#define ? ? CFG_GRA_ENA_MASK ? ? ? ? ? ? ? ? ? 0x00000100
> +#define ? ? CFG_GRA_ENA ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0x10000100
> ?/* for video part */
> ?#define ? ? CFG_DMA_FTOGGLE(toggle) ? ? ? ? ? ?((toggle) << 7)
> ?#define ? ? CFG_DMA_FTOGGLE_MASK ? ? ? ? ? ? ? 0x00000080
>>
>> ? ? ? ?/*
>> ? ? ? ? * If we are in a pseudo-color mode, we need to enable
>> --
>> 1.5.6.5
>>
>>
>

I'm OK. Should I submit this patch again?

Thanks
Haojian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] pxa168fb: fix clear operation
  2010-09-06 11:26     ` Haojian Zhuang
@ 2010-09-07  2:23       ` Eric Miao
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Miao @ 2010-09-07  2:23 UTC (permalink / raw)
  To: linux-arm-kernel

> I'm OK. Should I submit this patch again?
>

Yes please and with Marek's Ack.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-09-07  2:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-30  0:32 [PATCH] pxa168fb: Add .remove function Haojian Zhuang
2010-08-30  0:32 ` [PATCH] pxa168fb: fix clear operation Haojian Zhuang
2010-08-30 17:44   ` Marek Vasut
2010-09-05 11:56   ` Eric Miao
2010-09-06 11:26     ` Haojian Zhuang
2010-09-07  2:23       ` Eric Miao
2010-08-30 17:43 ` [PATCH] pxa168fb: Add .remove function Marek Vasut
2010-09-05 11:08   ` Eric Miao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).