* [U-Boot] [PATCH] NAND: Allow nand_scan to be replaced by user
@ 2011-12-05 23:16 Marek Vasut
2011-12-05 23:21 ` Scott Wood
0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2011-12-05 23:16 UTC (permalink / raw)
To: u-boot
This patch allows user to supply nand_scan() call replacement via the usual
method. This will be beneficial for PXA3XX NAND driver, which does further init
of the chip at this stage.
Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Scott Wood <scottwood@freescale.com>
---
drivers/mtd/nand/nand_base.c | 12 +++++++++---
include/linux/mtd/nand.h | 2 ++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 27f6c77..baf7622 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2974,10 +2974,16 @@ int nand_scan_tail(struct mtd_info *mtd)
int nand_scan(struct mtd_info *mtd, int maxchips)
{
int ret;
+ struct nand_chip *nand = mtd->priv;
+
+ if (nand->scan) {
+ ret = nand->scan(mtd);
+ } else {
+ ret = nand_scan_ident(mtd, maxchips, NULL);
+ if (!ret)
+ ret = nand_scan_tail(mtd);
+ }
- ret = nand_scan_ident(mtd, maxchips, NULL);
- if (!ret)
- ret = nand_scan_tail(mtd);
return ret;
}
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 1cdc7ae..698208c 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -432,6 +432,7 @@ struct nand_buffers {
* @errstat: [OPTIONAL] hardware specific function to perform additional error status checks
* (determine if errors are correctable)
* @write_page: [REPLACEABLE] High-level page write function
+ * @scan: [REPLACEABLE] Fill in the chip size and other parameters
*/
struct nand_chip {
@@ -456,6 +457,7 @@ struct nand_chip {
int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page);
int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *buf, int page, int cached, int raw);
+ int (*scan)(struct mtd_info *mtd);
int chip_delay;
unsigned int options;
--
1.7.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] NAND: Allow nand_scan to be replaced by user
2011-12-05 23:16 [U-Boot] [PATCH] NAND: Allow nand_scan to be replaced by user Marek Vasut
@ 2011-12-05 23:21 ` Scott Wood
2011-12-05 23:24 ` Marek Vasut
0 siblings, 1 reply; 3+ messages in thread
From: Scott Wood @ 2011-12-05 23:21 UTC (permalink / raw)
To: u-boot
On 12/05/2011 05:16 PM, Marek Vasut wrote:
> This patch allows user to supply nand_scan() call replacement via the usual
> method. This will be beneficial for PXA3XX NAND driver, which does further init
> of the chip at this stage.
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Scott Wood <scottwood@freescale.com>
> ---
> drivers/mtd/nand/nand_base.c | 12 +++++++++---
> include/linux/mtd/nand.h | 2 ++
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 27f6c77..baf7622 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2974,10 +2974,16 @@ int nand_scan_tail(struct mtd_info *mtd)
> int nand_scan(struct mtd_info *mtd, int maxchips)
> {
> int ret;
> + struct nand_chip *nand = mtd->priv;
> +
> + if (nand->scan) {
> + ret = nand->scan(mtd);
> + } else {
> + ret = nand_scan_ident(mtd, maxchips, NULL);
> + if (!ret)
> + ret = nand_scan_tail(mtd);
> + }
>
> - ret = nand_scan_ident(mtd, maxchips, NULL);
> - if (!ret)
> - ret = nand_scan_tail(mtd);
> return ret;
> }
There is no need to change this code. Instead, we should stop calling
nand_scan in the first place if we want to insert code between ident and
tail.
Does the approach in the following patch work for you?
http://patchwork.ozlabs.org/patch/128816/
-Scott
^ permalink raw reply [flat|nested] 3+ messages in thread* [U-Boot] [PATCH] NAND: Allow nand_scan to be replaced by user
2011-12-05 23:21 ` Scott Wood
@ 2011-12-05 23:24 ` Marek Vasut
0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2011-12-05 23:24 UTC (permalink / raw)
To: u-boot
> On 12/05/2011 05:16 PM, Marek Vasut wrote:
> > This patch allows user to supply nand_scan() call replacement via the
> > usual method. This will be beneficial for PXA3XX NAND driver, which does
> > further init of the chip at this stage.
> >
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> > Cc: Scott Wood <scottwood@freescale.com>
> > ---
> >
> > drivers/mtd/nand/nand_base.c | 12 +++++++++---
> > include/linux/mtd/nand.h | 2 ++
> > 2 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > index 27f6c77..baf7622 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -2974,10 +2974,16 @@ int nand_scan_tail(struct mtd_info *mtd)
> >
> > int nand_scan(struct mtd_info *mtd, int maxchips)
> > {
> >
> > int ret;
> >
> > + struct nand_chip *nand = mtd->priv;
> > +
> > + if (nand->scan) {
> > + ret = nand->scan(mtd);
> > + } else {
> > + ret = nand_scan_ident(mtd, maxchips, NULL);
> > + if (!ret)
> > + ret = nand_scan_tail(mtd);
> > + }
> >
> > - ret = nand_scan_ident(mtd, maxchips, NULL);
> > - if (!ret)
> > - ret = nand_scan_tail(mtd);
> >
> > return ret;
> >
> > }
>
> There is no need to change this code. Instead, we should stop calling
> nand_scan in the first place if we want to insert code between ident and
> tail.
>
> Does the approach in the following patch work for you?
> http://patchwork.ozlabs.org/patch/128816/
No, why use weak-aliased function if you can pass it like I do? If V2 passed the
function pointer like I do, I'll be OK with it. Though I tried very hard to keep
the pxa3xx driver as much unchanged as possible and this slightly breaks my
effort. Anyway, when do you expect to see this (in some modified version,
without the weak-aliased fn) mainline?
>
> -Scott
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-05 23:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-05 23:16 [U-Boot] [PATCH] NAND: Allow nand_scan to be replaced by user Marek Vasut
2011-12-05 23:21 ` Scott Wood
2011-12-05 23:24 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox