* Getting a mtd_info with a valid map.
@ 2003-06-18 10:45 Ken Gordon
2003-06-18 10:54 ` David Woodhouse
0 siblings, 1 reply; 7+ messages in thread
From: Ken Gordon @ 2003-06-18 10:45 UTC (permalink / raw)
To: linux-mtd
I'm trying to read the serial number from my Intel Strataflash (J3) suing
mtd->read_user_prot_reg and mtd->read_fact_prot_reg. This code below looks
to me like it should do the job but explodes because the mtd_info returned
by get_mtd_device has a NULL priv field.
Adding printk's into drivers/mtd/chips/cfi_probe.c I see an mtd_info being
created (not the one I get) and filled in with a valid priv pointing at a
map.
I'm a bit confused since mtd_info seem to refer to named partitions but I'm
after a per set of flash chips physical sort of thing. Am I am on the wrong
planet?
It looks like I could keep hold of the mtd_info that is returned to the
original probe in my file in drivers/mtd/maps but SURELY that isn't the way.
Ken
PS This is using linux 2.4.19-rmk6-pxa1
static int handle_proc_flashid(char *page,
char **start, off_t requested_offset,
int requested_len, int *eof, void *data)
{
int len = 0; /* which means that the bottom 4 bits are inverted */
char buf[1024]; /* wrt what is written on the bits !!*/
char *p = buf;
int f[4], s[4];
struct mtd_info *mtd = get_mtd_device(NULL, 0);
if (!mtd) {
sprintf(buf, "unable to get mtd device!\n");
} else {
// int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char
*buf);
size_t slen=0, flen=0;
int sret = -1, fret = -1;
struct map_info *map;
struct cfi_private *cfi;
struct cfi_pri_intelext *extp;
printk("about to get mtd->priv & is %x mtd is %x\n", &mtd->priv,
mtd);
map = mtd->priv;
printk("map %x\n", map); // map is ALWAYS 0 here - boo
hoo!
if (map) {
cfi = map->fldrv_priv;
printk("cfi %x\n", cfi);
if (cfi) {
extp=cfi->cmdset_priv;
printk("extp %x\n", extp);
}
}
printk("fn ptrs %x %x\n", mtd->read_user_prot_reg,
mtd->read_fact_prot_reg);
printk("name: %s\n", mtd->name);
if (mtd->read_user_prot_reg)
sret = mtd->read_user_prot_reg(mtd, 0, sizeof(s), &slen,
(unsigned char *)s);
printk("done user\n");
if (mtd->read_user_prot_reg)
fret = mtd->read_fact_prot_reg(mtd, 0, sizeof(f), &flen,
(unsigned char *)f);
printk("done fact\n");
sprintf(buf, "flen %d slen %d factory id =
%08x:%08x:%08x:%08x\nsystem id = %08x:%08x:%08x:%
08x\n",
flen, slen, f[0], f[1], f[2], f[3], s[0], s[1], s[2],
s[3]);
}
if (strlen(buf) < requested_len) {
strcpy(page, buf);
*start = page + requested_offset;
len = strlen(*start);
} else
*page = 0;
if (mtd)
put_mtd_device(mtd);
return len;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Getting a mtd_info with a valid map.
2003-06-18 10:45 Getting a mtd_info with a valid map Ken Gordon
@ 2003-06-18 10:54 ` David Woodhouse
2003-06-18 11:27 ` Ken Gordon
0 siblings, 1 reply; 7+ messages in thread
From: David Woodhouse @ 2003-06-18 10:54 UTC (permalink / raw)
To: Ken Gordon; +Cc: linux-mtd
On Wed, 2003-06-18 at 11:45, Ken Gordon wrote:
> I'm trying to read the serial number from my Intel Strataflash (J3) suing
> mtd->read_user_prot_reg and mtd->read_fact_prot_reg. This code below looks
> to me like it should do the job but explodes because the mtd_info returned
> by get_mtd_device has a NULL priv field.
I don't understand. When the 'map' is NULL you still call
mtd->read_user_prot_reg() anyway... doesn't it work?
What do you think that 'priv' is an abbreviation for, by the way? Under
what circumstances do you think a programmer would name a variable like
that? :)
--
dwmw2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Getting a mtd_info with a valid map.
2003-06-18 10:54 ` David Woodhouse
@ 2003-06-18 11:27 ` Ken Gordon
2003-06-18 11:32 ` Jörn Engel
2003-06-18 11:33 ` David Woodhouse
0 siblings, 2 replies; 7+ messages in thread
From: Ken Gordon @ 2003-06-18 11:27 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-mtd
>From cfi_cmdset_0001.c
static int cfi_intelext_read_user_prot_reg (struct mtd_info *mtd, loff_t
from, size_t len, size_t *r
etlen, u_char *buf)
{
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv; EXPODE HERE is map ==
NULL
struct cfi_pri_intelext *extp=cfi->cmdset_priv;
int base_offst,reg_sz;
/* Check that we actually have some protection registers */
if(!(extp->FeatureSupport&64)){
printk(KERN_WARNING "%s: This flash device has no protection data to
read!\n",map->name);
return 0;
}
base_offst=(1<<extp->FactProtRegSize);
reg_sz=(1<<extp->UserProtRegSize);
return cfi_intelext_read_prot_reg(mtd, from, len, retlen, buf,
base_offst, reg_sz);
}
----- Original Message -----
From: "David Woodhouse" <dwmw2@infradead.org>
To: "Ken Gordon" <kengordon@magneticscrolls.com>
Cc: <linux-mtd@lists.infradead.org>
Sent: Wednesday, June 18, 2003 11:54 AM
Subject: Re: Getting a mtd_info with a valid map.
> On Wed, 2003-06-18 at 11:45, Ken Gordon wrote:
> > I'm trying to read the serial number from my Intel Strataflash (J3)
suing
> > mtd->read_user_prot_reg and mtd->read_fact_prot_reg. This code below
looks
> > to me like it should do the job but explodes because the mtd_info
returned
> > by get_mtd_device has a NULL priv field.
>
> I don't understand. When the 'map' is NULL you still call
> mtd->read_user_prot_reg() anyway... doesn't it work?
>
> What do you think that 'priv' is an abbreviation for, by the way? Under
> what circumstances do you think a programmer would name a variable like
> that? :)
>
> --
> dwmw2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Getting a mtd_info with a valid map.
2003-06-18 11:27 ` Ken Gordon
@ 2003-06-18 11:32 ` Jörn Engel
2003-06-18 11:33 ` David Woodhouse
1 sibling, 0 replies; 7+ messages in thread
From: Jörn Engel @ 2003-06-18 11:32 UTC (permalink / raw)
To: Ken Gordon; +Cc: linux-mtd, David Woodhouse
On Wed, 18 June 2003 12:27:08 +0100, Ken Gordon wrote:
>
> >From cfi_cmdset_0001.c
Good. And now look into devices/*.c and figure out, what mtd->priv
means for those. Why again do you think, it was called priv and not
map?
Jörn
--
To announce that there must be no criticism of the President, or that we
are to stand by the President, right or wrong, is not only unpatriotic
and servile, but is morally treasonable to the American public.
-- Theodore Roosevelt, Kansas City Star, 1918
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Getting a mtd_info with a valid map.
2003-06-18 11:27 ` Ken Gordon
2003-06-18 11:32 ` Jörn Engel
@ 2003-06-18 11:33 ` David Woodhouse
2003-06-18 12:37 ` Ken Gordon
1 sibling, 1 reply; 7+ messages in thread
From: David Woodhouse @ 2003-06-18 11:33 UTC (permalink / raw)
To: Ken Gordon; +Cc: linux-mtd
On Wed, 2003-06-18 at 12:27, Ken Gordon wrote:
> >From cfi_cmdset_0001.c
Oh, I see. Do you have a version of mtdpart.c older than v1.28 then?
--
dwmw2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Getting a mtd_info with a valid map.
2003-06-18 11:33 ` David Woodhouse
@ 2003-06-18 12:37 ` Ken Gordon
2003-06-18 12:42 ` David Woodhouse
0 siblings, 1 reply; 7+ messages in thread
From: Ken Gordon @ 2003-06-18 12:37 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-mtd
I do. It is 1.27. So I should be getting newer sources then?
Ken
----- Original Message -----
From: "David Woodhouse" <dwmw2@infradead.org>
To: "Ken Gordon" <kengordon@magneticscrolls.com>
Cc: <linux-mtd@lists.infradead.org>
Sent: Wednesday, June 18, 2003 12:33 PM
Subject: Re: Getting a mtd_info with a valid map.
> On Wed, 2003-06-18 at 12:27, Ken Gordon wrote:
> > >From cfi_cmdset_0001.c
>
> Oh, I see. Do you have a version of mtdpart.c older than v1.28 then?
>
> --
> dwmw2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Getting a mtd_info with a valid map.
2003-06-18 12:37 ` Ken Gordon
@ 2003-06-18 12:42 ` David Woodhouse
0 siblings, 0 replies; 7+ messages in thread
From: David Woodhouse @ 2003-06-18 12:42 UTC (permalink / raw)
To: Ken Gordon; +Cc: linux-mtd
On Wed, 2003-06-18 at 13:37, Ken Gordon wrote:
> I do. It is 1.27. So I should be getting newer sources then?
Please don't top-post. Yes, you should be getting newer sources. v1.28
fixed this bug.
--
dwmw2
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-06-18 12:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-18 10:45 Getting a mtd_info with a valid map Ken Gordon
2003-06-18 10:54 ` David Woodhouse
2003-06-18 11:27 ` Ken Gordon
2003-06-18 11:32 ` Jörn Engel
2003-06-18 11:33 ` David Woodhouse
2003-06-18 12:37 ` Ken Gordon
2003-06-18 12:42 ` David Woodhouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox