Messages in this thread | | | Date | Tue, 3 Jan 2006 17:26:35 -0800 | From | Andrew Morton <> | Subject | Re: [patch 2.6.15-rc5-mm3] M25 series SPI flash |
| |
David Brownell <david-b@pacbell.net> wrote: > > Here's a driver for more traditional types of SPI flash, as found > in the ST M25 series. Contributed by Mike Lavender (thanks Mike!) > and tested on some ColdFire boards. >
bah, attachments..
> This was originally a driver for the ST M25P80 SPI flash. It's been > updated slightly to handle other M25P series chips. > > For many of these chips, the specific type could be probed, but for now > this just requires static setup with flash_platform_data that lists the > chip type (size, format) and any default partitioning to use. > > From: Mike Lavender <mike@steroidmicros.com> > Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> >
Please put the From: at the very first line of the changelog.
Mike, please review section 11 of Documentation/SubmittingPatches and send a Signed-off-by: for this work, thanks.
> +static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, > + size_t *retlen, const u_char *buf) > +{ > + struct m25p *flash = mtd_to_m25p(mtd); > + u32 page_offset, page_size; > + struct spi_transfer t[2]; > + struct spi_message m; > + > + DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %z\n", spi->dev.bus_id, > + __FUNCTION__, "to", (u32) to, len); > + > + if (retlen) > + *retlen = 0;
If retlen can be NULL
> + /* sanity checks */ > + if (!len) > + return(0); > + > + if (to + len > flash->mtd.size) > + return -EINVAL; > + > + down(&flash->lock); > + > + /* Wait until finished previous write command. */ > + if (wait_till_ready(flash)) > + return 1; > + > + write_enable(flash); > + > + memset(t, 0, (sizeof t)); > + > + /* Set up the opcode in the write buffer. */ > + flash->command[0] = OPCODE_PP; > + flash->command[1] = to >> 16; > + flash->command[2] = to >> 8; > + flash->command[3] = to; > + > + t[0].tx_buf = flash->command; > + t[0].len = sizeof(flash->command); > + > + m.transfers = t; > + m.n_transfer = 2; > + > + /* what page do we start with? */ > + page_offset = to % FLASH_PAGESIZE; > + > + /* do all the bytes fit onto one page? */ > + if (page_offset + len <= FLASH_PAGESIZE) { > + t[1].tx_buf = buf; > + t[1].len = len; > + > + spi_sync(flash->spi, &m); > + > + *retlen = m.actual_length - sizeof(flash->command);
this will oops.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |