diff mbox

MTD: NAND: pxa3xx_nand: allow building as module

Message ID 1232364431-7941-1-git-send-email-mike@compulab.co.il
State New, archived
Headers show

Commit Message

Mike Rapoport Jan. 19, 2009, 11:27 a.m. UTC
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 drivers/mtd/nand/Kconfig       |    2 +-
 drivers/mtd/nand/pxa3xx_nand.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

Comments

Ben Dooks Jan. 19, 2009, 11:40 a.m. UTC | #1
On Mon, Jan 19, 2009 at 01:27:11PM +0200, Mike Rapoport wrote:
> 
> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
> ---
>  drivers/mtd/nand/Kconfig       |    2 +-
>  drivers/mtd/nand/pxa3xx_nand.c |   10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
> index 8b12e6e..d3966d0 100644
> --- a/drivers/mtd/nand/Kconfig
> +++ b/drivers/mtd/nand/Kconfig
> @@ -334,7 +334,7 @@ config MTD_NAND_ATMEL_ECC_NONE
>  endchoice
>  
>  config MTD_NAND_PXA3xx
> -	bool "Support for NAND flash devices on PXA3xx"
> +	tristate "Support for NAND flash devices on PXA3xx"
>  	depends on MTD_NAND && PXA3xx
>  	help
>  	  This enables the driver for the NAND flash device found on
> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> index cc55cbc..628ba08 100644
> --- a/drivers/mtd/nand/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/pxa3xx_nand.c
> @@ -123,6 +123,7 @@ struct pxa3xx_nand_info {
>  
>  	struct clk		*clk;
>  	void __iomem		*mmio_base;
> +	struct resource		*res;
>  
>  	unsigned int 		buf_start;
>  	unsigned int		buf_count;
> @@ -1079,6 +1080,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
>  
>  	this = &info->nand_chip;
>  	mtd->priv = info;
> +	mtd->owner = THIS_MODULE;
>  
>  	info->clk = clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(info->clk)) {
> @@ -1125,6 +1127,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
>  		goto fail_put_clk;
>  	}
>  
> +	info->res = r;
>  	info->mmio_base = ioremap(r->start, r->end - r->start + 1);
>  	if (info->mmio_base == NULL) {
>  		dev_err(&pdev->dev, "ioremap() failed\n");
> @@ -1199,6 +1202,13 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
>  				info->data_buff, info->data_buff_phys);
>  	} else
>  		kfree(info->data_buff);
> +
> +	iounmap(info->mmio_base);
> +	release_mem_region(info->res->start, info->res->end - info->res->start + 1);

resource_size() is probably better for the second argument.
Eric Miao Jan. 20, 2009, 3:16 a.m. UTC | #2
On Mon, Jan 19, 2009 at 7:40 PM, Ben Dooks <ben-linux@fluff.org> wrote:
> On Mon, Jan 19, 2009 at 01:27:11PM +0200, Mike Rapoport wrote:
>>
>> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
>> ---
>>  drivers/mtd/nand/Kconfig       |    2 +-
>>  drivers/mtd/nand/pxa3xx_nand.c |   10 ++++++++++
>>  2 files changed, 11 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
>> index 8b12e6e..d3966d0 100644
>> --- a/drivers/mtd/nand/Kconfig
>> +++ b/drivers/mtd/nand/Kconfig
>> @@ -334,7 +334,7 @@ config MTD_NAND_ATMEL_ECC_NONE
>>  endchoice
>>
>>  config MTD_NAND_PXA3xx
>> -     bool "Support for NAND flash devices on PXA3xx"
>> +     tristate "Support for NAND flash devices on PXA3xx"
>>       depends on MTD_NAND && PXA3xx
>>       help
>>         This enables the driver for the NAND flash device found on
>> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
>> index cc55cbc..628ba08 100644
>> --- a/drivers/mtd/nand/pxa3xx_nand.c
>> +++ b/drivers/mtd/nand/pxa3xx_nand.c
>> @@ -123,6 +123,7 @@ struct pxa3xx_nand_info {
>>
>>       struct clk              *clk;
>>       void __iomem            *mmio_base;
>> +     struct resource         *res;
>>
>>       unsigned int            buf_start;
>>       unsigned int            buf_count;
>> @@ -1079,6 +1080,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
>>
>>       this = &info->nand_chip;
>>       mtd->priv = info;
>> +     mtd->owner = THIS_MODULE;
>>
>>       info->clk = clk_get(&pdev->dev, NULL);
>>       if (IS_ERR(info->clk)) {
>> @@ -1125,6 +1127,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
>>               goto fail_put_clk;
>>       }
>>
>> +     info->res = r;
>>       info->mmio_base = ioremap(r->start, r->end - r->start + 1);
>>       if (info->mmio_base == NULL) {
>>               dev_err(&pdev->dev, "ioremap() failed\n");
>> @@ -1199,6 +1202,13 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
>>                               info->data_buff, info->data_buff_phys);
>>       } else
>>               kfree(info->data_buff);
>> +
>> +     iounmap(info->mmio_base);
>> +     release_mem_region(info->res->start, info->res->end - info->res->start + 1);
>
> resource_size() is probably better for the second argument.
>

And maybe we don't even need to introduce the 'info->res', which is
always valid by platform_get_resource() again in _remove().
Mike Rapoport Jan. 20, 2009, 7:21 a.m. UTC | #3
Eric Miao wrote:
> On Mon, Jan 19, 2009 at 7:40 PM, Ben Dooks <ben-linux@fluff.org> wrote:
>> On Mon, Jan 19, 2009 at 01:27:11PM +0200, Mike Rapoport wrote:
>>> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
>>> ---
>>>  drivers/mtd/nand/Kconfig       |    2 +-
>>>  drivers/mtd/nand/pxa3xx_nand.c |   10 ++++++++++
>>>  2 files changed, 11 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
>>> index 8b12e6e..d3966d0 100644
>>> --- a/drivers/mtd/nand/Kconfig
>>> +++ b/drivers/mtd/nand/Kconfig
>>> @@ -334,7 +334,7 @@ config MTD_NAND_ATMEL_ECC_NONE
>>>  endchoice
>>>
>>>  config MTD_NAND_PXA3xx
>>> -     bool "Support for NAND flash devices on PXA3xx"
>>> +     tristate "Support for NAND flash devices on PXA3xx"
>>>       depends on MTD_NAND && PXA3xx
>>>       help
>>>         This enables the driver for the NAND flash device found on
>>> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
>>> index cc55cbc..628ba08 100644
>>> --- a/drivers/mtd/nand/pxa3xx_nand.c
>>> +++ b/drivers/mtd/nand/pxa3xx_nand.c
>>> @@ -123,6 +123,7 @@ struct pxa3xx_nand_info {
>>>
>>>       struct clk              *clk;
>>>       void __iomem            *mmio_base;
>>> +     struct resource         *res;
>>>
>>>       unsigned int            buf_start;
>>>       unsigned int            buf_count;
>>> @@ -1079,6 +1080,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
>>>
>>>       this = &info->nand_chip;
>>>       mtd->priv = info;
>>> +     mtd->owner = THIS_MODULE;
>>>
>>>       info->clk = clk_get(&pdev->dev, NULL);
>>>       if (IS_ERR(info->clk)) {
>>> @@ -1125,6 +1127,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
>>>               goto fail_put_clk;
>>>       }
>>>
>>> +     info->res = r;
>>>       info->mmio_base = ioremap(r->start, r->end - r->start + 1);
>>>       if (info->mmio_base == NULL) {
>>>               dev_err(&pdev->dev, "ioremap() failed\n");
>>> @@ -1199,6 +1202,13 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
>>>                               info->data_buff, info->data_buff_phys);
>>>       } else
>>>               kfree(info->data_buff);
>>> +
>>> +     iounmap(info->mmio_base);
>>> +     release_mem_region(info->res->start, info->res->end - info->res->start + 1);
>> resource_size() is probably better for the second argument.
>>
> 
> And maybe we don't even need to introduce the 'info->res', which is
> always valid by platform_get_resource() again in _remove().

Ok.

> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
Mike Rapoport Jan. 20, 2009, 7:33 a.m. UTC | #4
This is updated version together with a patch that allows platform to
keep NAND flash controller settings defined by the bootloader.


--
Sincerely yours,
	Mike.
diff mbox

Patch

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8b12e6e..d3966d0 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -334,7 +334,7 @@  config MTD_NAND_ATMEL_ECC_NONE
 endchoice
 
 config MTD_NAND_PXA3xx
-	bool "Support for NAND flash devices on PXA3xx"
+	tristate "Support for NAND flash devices on PXA3xx"
 	depends on MTD_NAND && PXA3xx
 	help
 	  This enables the driver for the NAND flash device found on
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index cc55cbc..628ba08 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -123,6 +123,7 @@  struct pxa3xx_nand_info {
 
 	struct clk		*clk;
 	void __iomem		*mmio_base;
+	struct resource		*res;
 
 	unsigned int 		buf_start;
 	unsigned int		buf_count;
@@ -1079,6 +1080,7 @@  static int pxa3xx_nand_probe(struct platform_device *pdev)
 
 	this = &info->nand_chip;
 	mtd->priv = info;
+	mtd->owner = THIS_MODULE;
 
 	info->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(info->clk)) {
@@ -1125,6 +1127,7 @@  static int pxa3xx_nand_probe(struct platform_device *pdev)
 		goto fail_put_clk;
 	}
 
+	info->res = r;
 	info->mmio_base = ioremap(r->start, r->end - r->start + 1);
 	if (info->mmio_base == NULL) {
 		dev_err(&pdev->dev, "ioremap() failed\n");
@@ -1199,6 +1202,13 @@  static int pxa3xx_nand_remove(struct platform_device *pdev)
 				info->data_buff, info->data_buff_phys);
 	} else
 		kfree(info->data_buff);
+
+	iounmap(info->mmio_base);
+	release_mem_region(info->res->start, info->res->end - info->res->start + 1);
+
+	clk_disable(info->clk);
+	clk_put(info->clk);
+
 	kfree(mtd);
 	return 0;
 }