From: Arnd Bergmann <arnd@arndb.de>
To: "Jörn Engel" <joern@logfs.org>
Cc: linux-mtd@lists.infradead.org, David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH Take 3] MTD driver for alauda chips
Date: Wed, 11 Jul 2007 20:05:43 +0200 [thread overview]
Message-ID: <200707112005.44089.arnd@arndb.de> (raw)
In-Reply-To: <20070711172617.GC27628@lazybastard.org>
On Wednesday 11 July 2007, Jörn Engel wrote:
> A driver for the Olympus MAUSB-10 and Fujifilm DPC-R1 card readers.
> Unlike most stuff on the market the chip inside these two allows raw
> flash access and doesn't implement and FTL, leaving that functionality
> to the device driver.
>
> Raw flash access in a cheap USB cardreader! An MTD test device one can
> attach to a PC! What a deal!
Cool stuff! just a few details I noticed:
> +/* Address shifting */
> +#define PBA_LO(pba) ((pba & 0xF) << 5)
> +#define PBA_HI(pba) (pba >> 3)
> +#define PBA_ZONE(pba) (pba >> 11)
What is PBA?
> +static struct usb_driver alauda_driver;
The forward declaration is use nowhere, you can kill it.
> + struct alauda *al = mtd->priv;
> + u32 pba = from >> al->card->blockshift;
> + u32 page = (from >> al->card->pageshift) & al->pagemask;
> + u8 command[] = {
> + ALAUDA_BULK_CMD, ALAUDA_BULK_READ_PAGE, PBA_HI(pba),
> + PBA_ZONE(pba), 0, PBA_LO(pba) + page, 1, 0,
> + ALAUDA_PORT_XD
> + };
It would be nice to have support for both ports, not hardcoding xD.
At least I only have SmartMedia cards, so I can't test the code
the way it is ;-)
> + err = usb_bulk_msg(al->dev, al->bulk_out, command, 9, NULL, HZ);
> + if (err < 0)
> + return -EIO;
> +
> + err = usb_bulk_msg(al->dev, al->bulk_in, buf, mtd->writesize, NULL, HZ);
> + if (err < 0)
> + return -EIO;
> +
> + err = usb_bulk_msg(al->dev, al->bulk_in, oob, 16, NULL, HZ);
> + if (err < 0)
> + return -EIO;
> + return 0;
> +}
Not sure how much difference it makes, but it should be more efficient
to queue all three commands first, and then wait for their completion
once, instead of doing them all synchronously.
> + err = usb_bulk_msg(al->dev, al->bulk_out, command, 9, NULL, HZ);
> + if (err < 0)
> + return -EIO;
> +
> + err = usb_bulk_msg(al->dev, al->write_out, buf, mtd->writesize, NULL,
> + HZ);
> + if (err < 0)
> + return -EIO;
> +
> + err = usb_bulk_msg(al->dev, al->write_out, oob, 16, NULL, HZ);
> + if (err < 0)
> + return -EIO;
> + return 0;
> +}
Same here, obviously.
> +static int alauda_read(struct mtd_info *mtd, loff_t from, size_t len,
> + size_t *retlen, u_char *buf)
> +{
> + struct alauda *al = mtd->priv;
> + int err, corrected=0, uncorrected=0;
> +
> + if ((from & al->bytemask) || (len & al->bytemask))
> + return -EINVAL;
> +
> + *retlen = len;
> + while (len) {
> + u8 oob[16];
> +
> + err = alauda_read_page(mtd, from, buf, oob);
> + if (err)
> + return err;
> +
and you could gain more if you have multiple pages outstanding I/O.
> + while (len) {
> + u32 page = (to >> al->card->pageshift) & al->pagemask;
> + u8 oob[16] = { 'h', 'e', 'l', 'l', 'o', 0xff, 0xff, 0xff,
> + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
Are you planning to keep this string?
Armd <><
next prev parent reply other threads:[~2007-07-11 18:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-09 22:37 [PATCH] MTD driver for alauda chips Jörn Engel
[not found] ` <20070711164628.GB27628@lazybastard.org>
[not found] ` <20070711172617.GC27628@lazybastard.org>
2007-07-11 18:05 ` Arnd Bergmann [this message]
2007-07-11 19:17 ` [PATCH Take 3] " Jörn Engel
2007-07-11 20:36 ` Arnd Bergmann
2007-07-11 21:01 ` Jörn Engel
2007-07-11 23:08 ` Jörn Engel
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=200707112005.44089.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=dwmw2@infradead.org \
--cc=joern@logfs.org \
--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