[U-Boot-Users] [PATCH] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST

Stefan Roese sr at denx.de
Sat Apr 19 14:02:23 CEST 2008


Hi Matthias,

On Saturday 19 April 2008, Matthias Fuchs wrote:
> is it possible to use weak structures? Or do you mean
> a weak function that initializes my autoprotect list?
>
> Please give me an idea and I will implement it.

I don't know if it's possible to implement a weak structure, but I
would prefer something like this instead of your original
implementation (no #ifdef's in the code):

struct apl_s {
	u32 start;
	u32 size;
};

#if !defined(CFG_FLASH_AUTOPROTECT_LIST)
struct apl_s apl[] = { };
#else
struct apl_s apl[] = CFG_FLASH_AUTOPROTECT_LIST;
#endif

And then later in the code:

+       for (i = 0; i < ARRAY_SIZE(apl); i++) {
+               debug("autoprotecting from %08x to %08x\n",
+                     apl[i].start, apl[i].start + apl[i].size - 1);
+               flash_protect (FLAG_PROTECT_SET,
+                              apl[i].start,
+                              apl[i].start + apl[i].size - 1,
+                              flash_get_info(apl[i].start));
+       }

What do you think? 
> Matthias
>
> On Friday 18 April 2008 18:01:57 Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> > > index e3cfb8a..68ab55f 100644
> > > --- a/drivers/mtd/cfi_flash.c
> > > +++ b/drivers/mtd/cfi_flash.c
> > > @@ -1873,6 +1873,12 @@ unsigned long flash_init (void)
> > >  {
> > >  	unsigned long size = 0;
> > >  	int i;
> > > +#if defined(CFG_FLASH_AUTOPROTECT_LIST)
> > > +	struct apl_s {
> > > +		ulong start;
> > > +		ulong size;
> > > +	} apl[] = CFG_FLASH_AUTOPROTECT_LIST;
> > > +#endif
> >
> > I think it will be better to create a weak structure.
> >
> > Best Regards,
> > J.
>
> !DSPAM:4809d80874783629025813!



-- 
Viele Grüße,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================




More information about the U-Boot mailing list