linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Generic Platform NAND Driver
@ 2007-05-18 12:15 Semih Hazar
  2007-05-22  9:08 ` Semih Hazar
  0 siblings, 1 reply; 6+ messages in thread
From: Semih Hazar @ 2007-05-18 12:15 UTC (permalink / raw)
  To: linux-mtd

Hi,

In the new generic platforn NAND driver, line 54;

	data->chip.priv = &data;
	data->mtd.priv = &data->chip;

mtd->priv->priv points to struct plat_nand_data which is defined in the 
plat_nand.c and never used by it.
Can we change it so that this priv points to a host specific data, and 
the helper functions (board specific) can make use of it.
Below is a suggested patch:

diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index d2365c8..256957b 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -599,10 +599,12 @@ struct platform_nand_ctrl {
  * struct platform_nand_data - container structure for platform-specific data
  * @chip:		chip level chip structure
  * @ctrl:		controller level device structure
+ * @host:		pointer to host specific data structure
  */
 struct platform_nand_data {
 	struct platform_nand_chip	chip;
 	struct platform_nand_ctrl	ctrl;
+	void				*host;
 };
 
 /* Some helpers to access the data structures */
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index cd725fc..1e47ad3 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -51,7 +51,7 @@ static int __init plat_nand_probe(struct platform_device *pdev)
 		return -EIO;
 	}
 
-	data->chip.priv = &data;
+	data->chip.priv = pdata->host;
 	data->mtd.priv = &data->chip;

 	data->mtd.owner = THIS_MODULE;

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

* Re: Generic Platform NAND Driver
  2007-05-18 12:15 Generic Platform NAND Driver Semih Hazar
@ 2007-05-22  9:08 ` Semih Hazar
  2007-05-22  9:48   ` Vladimir A. Barinov
  0 siblings, 1 reply; 6+ messages in thread
From: Semih Hazar @ 2007-05-22  9:08 UTC (permalink / raw)
  To: vitalywool; +Cc: linux-mtd

Hi Vitaly,

I couldn't get any replies from the list and I wonder if I'm missing a 
point here.

struct plat_nand_data seems useless to users of this generic nand 
driver, and there is no way of passing user data in mtd structures.

Does that make sense, or am I missing something ?

Also the priv members in platform_nand_chip and platform_nand_ctrl are 
not used in any way. Maybe a better solution would be to utilize these ?

> Hi,
>
> In the new generic platforn NAND driver, line 54;
>
> 	data->chip.priv = &data;
> 	data->mtd.priv = &data->chip;
>
> mtd->priv->priv points to struct plat_nand_data which is defined in the 
> plat_nand.c and never used by it.
> Can we change it so that this priv points to a host specific data, and 
> the helper functions (board specific) can make use of it.
> Below is a suggested patch:
>
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index d2365c8..256957b 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -599,10 +599,12 @@ struct platform_nand_ctrl {
>   * struct platform_nand_data - container structure for platform-specific data
>   * @chip:		chip level chip structure
>   * @ctrl:		controller level device structure
> + * @host:		pointer to host specific data structure
>   */
>  struct platform_nand_data {
>  	struct platform_nand_chip	chip;
>  	struct platform_nand_ctrl	ctrl;
> +	void				*host;
>  };
>  
>  /* Some helpers to access the data structures */
> diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
> index cd725fc..1e47ad3 100644
> --- a/drivers/mtd/nand/plat_nand.c
> +++ b/drivers/mtd/nand/plat_nand.c
> @@ -51,7 +51,7 @@ static int __init plat_nand_probe(struct platform_device *pdev)
>  		return -EIO;
>  	}
>  
> -	data->chip.priv = &data;
> +	data->chip.priv = pdata->host;
>  	data->mtd.priv = &data->chip;
>
>  	data->mtd.owner = THIS_MODULE;
>   

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

* Re: Generic Platform NAND Driver
  2007-05-22  9:08 ` Semih Hazar
@ 2007-05-22  9:48   ` Vladimir A. Barinov
  2007-05-22 10:28     ` Semih Hazar
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir A. Barinov @ 2007-05-22  9:48 UTC (permalink / raw)
  To: Semih Hazar; +Cc: linux-mtd, vitalywool

Semih Hazar wrote:
> Hi Vitaly,
>
> I couldn't get any replies from the list and I wonder if I'm missing a 
> point here.
>
> struct plat_nand_data seems useless to users of this generic nand 
> driver, and there is no way of passing user data in mtd structures.
>
> Does that make sense, or am I missing something ?
>
> Also the priv members in platform_nand_chip and platform_nand_ctrl are 
> not used in any way. Maybe a better solution would be to utilize these ?
>   
That structures are for arch related code for NAND flashes that 
registers are memory mapped but
has special h/w control.

You can look at the first (I guess) usage example here:
http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=4385/2

>   
>> Hi,
>>
>> In the new generic platforn NAND driver, line 54;
>>
>> 	data->chip.priv = &data;
>> 	data->mtd.priv = &data->chip;
>>
>> mtd->priv->priv points to struct plat_nand_data which is defined in the 
>> plat_nand.c and never used by it.
>> Can we change it so that this priv points to a host specific data, and 
>> the helper functions (board specific) can make use of it.
>> Below is a suggested patch:
>>
>> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
>> index d2365c8..256957b 100644
>> --- a/include/linux/mtd/nand.h
>> +++ b/include/linux/mtd/nand.h
>> @@ -599,10 +599,12 @@ struct platform_nand_ctrl {
>>   * struct platform_nand_data - container structure for platform-specific data
>>   * @chip:		chip level chip structure
>>   * @ctrl:		controller level device structure
>> + * @host:		pointer to host specific data structure
>>   */
>>  struct platform_nand_data {
>>  	struct platform_nand_chip	chip;
>>  	struct platform_nand_ctrl	ctrl;
>> +	void				*host;
>>  };
>>  
>>  /* Some helpers to access the data structures */
>> diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
>> index cd725fc..1e47ad3 100644
>> --- a/drivers/mtd/nand/plat_nand.c
>> +++ b/drivers/mtd/nand/plat_nand.c
>> @@ -51,7 +51,7 @@ static int __init plat_nand_probe(struct platform_device *pdev)
>>  		return -EIO;
>>  	}
>>  
>> -	data->chip.priv = &data;
>> +	data->chip.priv = pdata->host;
>>  	data->mtd.priv = &data->chip;
>>
>>  	data->mtd.owner = THIS_MODULE;
>>   
>>     
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>   

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

* Re: Generic Platform NAND Driver
  2007-05-22  9:48   ` Vladimir A. Barinov
@ 2007-05-22 10:28     ` Semih Hazar
  2007-05-22 11:19       ` Vladimir A. Barinov
  0 siblings, 1 reply; 6+ messages in thread
From: Semih Hazar @ 2007-05-22 10:28 UTC (permalink / raw)
  To: Vladimir A. Barinov; +Cc: linux-mtd, vitalywool

Vladimir A. Barinov wrote:
> You can look at the first (I guess) usage example here:
> http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=4385/2
>
>   

+ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+{
+	struct nand_chip *this = mtd->priv;
+	int offset = (int)this->priv;

Here offset is read from nand_chip->priv, which actually points to struct plat_nand_data of plat_nand.c

Am I wrong ?

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

* Re: Generic Platform NAND Driver
  2007-05-22 10:28     ` Semih Hazar
@ 2007-05-22 11:19       ` Vladimir A. Barinov
  2007-05-22 11:53         ` Semih Hazar
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir A. Barinov @ 2007-05-22 11:19 UTC (permalink / raw)
  To: Semih Hazar; +Cc: linux-mtd, vitalywool

Hi Semih,

Semih Hazar wrote:
> Vladimir A. Barinov wrote:
>> You can look at the first (I guess) usage example here:
>> http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=4385/2
>>
>>   
>
> +ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned 
> int ctrl)
> +{
> +    struct nand_chip *this = mtd->priv;
> +    int offset = (int)this->priv;
>
> Here offset is read from nand_chip->priv, which actually points to 
> struct plat_nand_data of plat_nand.c
>
> Am I wrong ? 
I agree with you.
And you are right that all things work fine because the 
mtd_info->priv->priv that points to plat_nand_data is not used.

I agree that the line 54 in plat_nand.c should be removed:

-	data->chip.priv = &data;


But does it really usefull to create void * host pointer if it could be 
done in arch code like the above patch does?

Vladimir

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

* Re: Generic Platform NAND Driver
  2007-05-22 11:19       ` Vladimir A. Barinov
@ 2007-05-22 11:53         ` Semih Hazar
  0 siblings, 0 replies; 6+ messages in thread
From: Semih Hazar @ 2007-05-22 11:53 UTC (permalink / raw)
  To: Vladimir A. Barinov; +Cc: linux-mtd, vitalywool

Vladimir A. Barinov wrote:
>>
>> +ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned 
>> int ctrl)
>> +{
>> +    struct nand_chip *this = mtd->priv;
>> +    int offset = (int)this->priv;
>>
>> Here offset is read from nand_chip->priv, which actually points to 
>> struct plat_nand_data of plat_nand.c
>>
>> Am I wrong ? 
> I agree with you.
> And you are right that all things work fine because the 
> mtd_info->priv->priv that points to plat_nand_data is not used.
>
> I agree that the line 54 in plat_nand.c should be removed:
>
> -    data->chip.priv = &data;
>
>
> But does it really usefull to create void * host pointer if it could 
> be done in arch code like the above patch does?
I thought board-specific code can make use of this area (just as in your 
patch) so it's good to be able pass some _known_ data there.

My code which uses generic nand and is very much like the patch you've 
sent. But we may have board specific CLE, ACE, CE pins so they're not 
#define'd in the machine code, rather they're passed in a struct from 
the board code. And I thought the right thing to so that would be to 
pass that data to the priv member rather than accessing it in a static way.

If it's better to access have these board-specific in a static manner, 
then I'll just go ahead and change my code that way.

Thanks for your feedback.

Regards,
-- 
Semih Hazar

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

end of thread, other threads:[~2007-05-22 11:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-18 12:15 Generic Platform NAND Driver Semih Hazar
2007-05-22  9:08 ` Semih Hazar
2007-05-22  9:48   ` Vladimir A. Barinov
2007-05-22 10:28     ` Semih Hazar
2007-05-22 11:19       ` Vladimir A. Barinov
2007-05-22 11:53         ` Semih Hazar

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).