public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Ken Gordon" <kengordon@magneticscrolls.com>
To: <linux-mtd@lists.infradead.org>
Subject: Getting a mtd_info with a valid map.
Date: Wed, 18 Jun 2003 11:45:54 +0100	[thread overview]
Message-ID: <004101c33586$cb802a90$1207a8c0@kenlap> (raw)

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;
}

             reply	other threads:[~2003-06-18 10:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-18 10:45 Ken Gordon [this message]
2003-06-18 10:54 ` Getting a mtd_info with a valid map 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='004101c33586$cb802a90$1207a8c0@kenlap' \
    --to=kengordon@magneticscrolls.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox