From 4ebb5ab622c69dea8f482aa156070925d29bd09f Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Sat, 2 Oct 2004 19:17:59 -0700 Subject: [PATCH] [PATCH] Updated IXP4xx MTD driver from CVS (v1.6) Following patch updates the IXP4xx MTD driver with the latest version from MTD CVS. Signed-Off-By: David Woodhouse Signed-off-by: Deepak Saxena Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/mtd/maps/ixp4xx.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index ddd067262ffca..1770b1acc2b9e 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c @@ -1,5 +1,5 @@ /* - * $Id: ixp4xx.c,v 1.4 2004/08/31 22:55:51 dsaxena Exp $ + * $Id: ixp4xx.c,v 1.6 2004/09/17 00:25:06 gleixner Exp $ * * drivers/mtd/maps/ixp4xx.c * @@ -69,9 +69,22 @@ static void ixp4xx_copy_from(struct map_info *map, void *to, dest[len - 1] = BYTE0(src[i]); } +/* + * Unaligned writes are ignored, causing the 8-bit + * probe to fail and proceed to the 16-bit probe (which succeeds). + */ +static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr) +{ + if (!(adr & 1)) + *(__u16 *) (map->map_priv_1 + adr) = d.x[0]; +} + +/* + * Fast write16 function without the probing check above + */ static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr) { - *(__u16 *) (map->map_priv_1 + adr) = d.x[0]; + *(__u16 *) (map->map_priv_1 + adr) = d.x[0]; } struct ixp4xx_flash_info { @@ -171,7 +184,7 @@ static int ixp4xx_flash_probe(struct device *_dev) info->map.bankwidth = 2; info->map.name = dev->dev.bus_id; info->map.read = ixp4xx_read16, - info->map.write = ixp4xx_write16, + info->map.write = ixp4xx_probe_write16, info->map.copy_from = ixp4xx_copy_from, info->res = request_mem_region(dev->resource->start, @@ -184,7 +197,7 @@ static int ixp4xx_flash_probe(struct device *_dev) } info->map.map_priv_1 = - (unsigned long) ioremap(dev->resource->start, + (void __iomem *) ioremap(dev->resource->start, dev->resource->end - dev->resource->start + 1); if (!info->map.map_priv_1) { printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n"); @@ -200,6 +213,9 @@ static int ixp4xx_flash_probe(struct device *_dev) } info->mtd->owner = THIS_MODULE; + /* Use the fast version */ + info->map.write = ixp4xx_write16, + err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0); if (err > 0) { err = add_mtd_partitions(info->mtd, info->partitions, err); -- 2.53.0