Skip to contentSkip to conversation

Work to enable SmartMedia/xD support in mtd

PATCH In review Maxim Levitsky 2 participants 26 messages Feb 22, 2010 – Feb 23, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v10 cover Work to enable SmartMedia/xD support in mtd

Changes:

* Rebased the series against patches from Ben Hutchings. Now it applies cleanly on top of
git://git.infradead.org/users/dedekind/l2-mtd-2.6.git

* Fixed another blktrans hotplug problem.
If you remove that card while it is used, then add it while, the user still holds the block device open, block device wasn't accesable

* Fixed minor memory leak in mtdblock (unrelated to the patchset)

Best regards,
Maxim Levitsky

#1 lore raw

PATCH v10 1/15 MTD: create unlocked versions of {get,put}_mtd_device

Use these only if you know that you already hold mtd_table_mutex

---
 drivers/mtd/mtdcore.c   |   60 ++++++++++++++++++++++++++++++----------------
 include/linux/mtd/mtd.h |    3 +-
 2 files changed, 41 insertions(+), 22 deletions(-)
drivers/mtd/mtdcore.c +39 -21
index b3b98d1..67669a7 100644
@@ -463,27 +463,38 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
 			ret = NULL;
 	}
 
-	if (!ret)
-		goto out_unlock;
-
-	if (!try_module_get(ret->owner))
-		goto out_unlock;
-
-	if (ret->get_device) {
-		err = ret->get_device(ret);
-		if (err)
-			goto out_put;
+	if (!ret) {
+		ret = ERR_PTR(err);
+		goto out;
 	}
 
-	ret->usecount++;
+	err = __get_mtd_device(ret);
+	if (err)
+		ret = ERR_PTR(err);
+out:
 	mutex_unlock(&mtd_table_mutex);
 	return ret;
+}
 
-out_put:
-	module_put(ret->owner);
-out_unlock:
-	mutex_unlock(&mtd_table_mutex);
-	return ERR_PTR(err);
+
+int __get_mtd_device(struct mtd_info *mtd)
+{
+	int err;
+
+	if (!try_module_get(mtd->owner))
+		return -ENODEV;
+
+	if (mtd->get_device) {
+
+		err = mtd->get_device(mtd);
+
+		if (err) {
+			module_put(mtd->owner);
+			return err;
+		}
+	}
+	mtd->usecount++;
+	return 0;
 }
 
 /**
@@ -534,14 +545,19 @@ out_unlock:
 
 void put_mtd_device(struct mtd_info *mtd)
 {
-	int c;
-
 	mutex_lock(&mtd_table_mutex);
-	c = --mtd->usecount;
+	__put_mtd_device(mtd);
+	mutex_unlock(&mtd_table_mutex);
+
+}
+
+void __put_mtd_device(struct mtd_info *mtd)
+{
+	--mtd->usecount;
+	BUG_ON(mtd->usecount < 0);
+
 	if (mtd->put_device)
 		mtd->put_device(mtd);
-	mutex_unlock(&mtd_table_mutex);
-	BUG_ON(c < 0);
 
 	module_put(mtd->owner);
 }
@@ -579,7 +595,9 @@ EXPORT_SYMBOL_GPL(add_mtd_device);
 EXPORT_SYMBOL_GPL(del_mtd_device);
 EXPORT_SYMBOL_GPL(get_mtd_device);
 EXPORT_SYMBOL_GPL(get_mtd_device_nm);
+EXPORT_SYMBOL_GPL(__get_mtd_device);
 EXPORT_SYMBOL_GPL(put_mtd_device);
+EXPORT_SYMBOL_GPL(__put_mtd_device);
 EXPORT_SYMBOL_GPL(register_mtd_user);
 EXPORT_SYMBOL_GPL(unregister_mtd_user);
 EXPORT_SYMBOL_GPL(default_mtd_writev);
include/linux/mtd/mtd.h +2 -1
index ba53ecc..11d8e68 100644
@@ -289,8 +289,9 @@ extern int add_mtd_device(struct mtd_info *mtd);
 extern int del_mtd_device (struct mtd_info *mtd);
 
 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
+extern int __get_mtd_device(struct mtd_info *mtd);
+extern void __put_mtd_device(struct mtd_info *mtd);
 extern struct mtd_info *get_mtd_device_nm(const char *name);
-
 extern void put_mtd_device(struct mtd_info *mtd);
 
 
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH v10 2/15 blktrans: remove mtd_blkcore_priv and switch to per device queue and thread

In reply to Maxim Levitsky

This is the biggest change. To make hotplug possible, and this layer clean, the mtd_blktrans_dev now contains everything for a single mtd block translation device. Also removed some very old leftovers

---
 drivers/mtd/mtd_blkdevs.c    |  124 ++++++++++++++++++++----------------------
 include/linux/mtd/blktrans.h |   10 ++--
 2 files changed, 63 insertions(+), 71 deletions(-)
drivers/mtd/mtd_blkdevs.c +58 -66
index 2f8c202..6a57262 100644
@@ -14,7 +14,6 @@
 #include <linux/mtd/mtd.h>
 #include <linux/blkdev.h>
 #include <linux/blkpg.h>
-#include <linux/freezer.h>
 #include <linux/spinlock.h>
 #include <linux/hdreg.h>
 #include <linux/init.h>
@@ -26,11 +25,6 @@
 
 static LIST_HEAD(blktrans_majors);
 
-struct mtd_blkcore_priv {
-	struct task_struct *thread;
-	struct request_queue *rq;
-	spinlock_t queue_lock;
-};
 
 static int do_blktrans_request(struct mtd_blktrans_ops *tr,
 			       struct mtd_blktrans_dev *dev,
@@ -61,7 +55,6 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
 				return -EIO;
 		rq_flush_dcache_pages(req);
 		return 0;
-
 	case WRITE:
 		if (!tr->writesect)
 			return -EIO;
@@ -71,7 +64,6 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
 			if (tr->writesect(dev, block, buf))
 				return -EIO;
 		return 0;
-
 	default:
 		printk(KERN_NOTICE "Unknown request %u\n", rq_data_dir(req));
 		return -EIO;
@@ -80,14 +72,13 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
 
 static int mtd_blktrans_thread(void *arg)
 {
-	struct mtd_blktrans_ops *tr = arg;
-	struct request_queue *rq = tr->blkcore_priv->rq;
+	struct mtd_blktrans_dev *dev = arg;
+	struct request_queue *rq = dev->rq;
 	struct request *req = NULL;
 
 	spin_lock_irq(rq->queue_lock);
 
 	while (!kthread_should_stop()) {
-		struct mtd_blktrans_dev *dev;
 		int res;
 
 		if (!req && !(req = blk_fetch_request(rq))) {
@@ -98,13 +89,10 @@ static int mtd_blktrans_thread(void *arg)
 			continue;
 		}
 
-		dev = req->rq_disk->private_data;
-		tr = dev->tr;
-
 		spin_unlock_irq(rq->queue_lock);
 
 		mutex_lock(&dev->lock);
-		res = do_blktrans_request(tr, dev, req);
+		res = do_blktrans_request(dev->tr, dev, req);
 		mutex_unlock(&dev->lock);
 
 		spin_lock_irq(rq->queue_lock);
@@ -123,8 +111,8 @@ static int mtd_blktrans_thread(void *arg)
 
 static void mtd_blktrans_request(struct request_queue *rq)
 {
-	struct mtd_blktrans_ops *tr = rq->queuedata;
-	wake_up_process(tr->blkcore_priv->thread);
+	struct mtd_blktrans_dev *dev = rq->queuedata;
+	wake_up_process(dev->thread);
 }
 
 
@@ -214,6 +202,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	struct mtd_blktrans_dev *d;
 	int last_devnum = -1;
 	struct gendisk *gd;
+	int ret;
 
 	if (mutex_trylock(&mtd_table_mutex)) {
 		mutex_unlock(&mtd_table_mutex);
@@ -239,6 +228,8 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 		}
 		last_devnum = d->devnum;
 	}
+
+	ret = -EBUSY;
 	if (new->devnum == -1)
 		new->devnum = last_devnum+1;
 
@@ -247,7 +238,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	 * with this number. */
 	if (new->devnum > (MINORMASK >> tr->part_bits) ||
 	    (tr->part_bits && new->devnum >= 27 * 26))
-		return -EBUSY;
+		goto error1;
 
 	list_add_tail(&new->list, &tr->devs);
  added:
@@ -255,11 +246,16 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	if (!tr->writesect)
 		new->readonly = 1;
 
+
+	/* Create gendisk */
+	ret = -ENOMEM;
 	gd = alloc_disk(1 << tr->part_bits);
-	if (!gd) {
-		list_del(&new->list);
-		return -ENOMEM;
-	}
+
+	if (!gd)
+		goto error2;
+
+	new->disk = gd;
+	gd->private_data = new;
 	gd->major = tr->major;
 	gd->first_minor = (new->devnum) << tr->part_bits;
 	gd->fops = &mtd_blktrans_ops;
@@ -277,21 +273,49 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 		snprintf(gd->disk_name, sizeof(gd->disk_name),
 			 "%s%d", tr->name, new->devnum);
 
-	/* 2.5 has capacity in units of 512 bytes while still
-	   having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */
 	set_capacity(gd, (new->size * tr->blksize) >> 9);
 
-	gd->private_data = new;
-	new->blkcore_priv = gd;
-	gd->queue = tr->blkcore_priv->rq;
+
+	/* Create the request queue */
+	spin_lock_init(&new->queue_lock);
+	new->rq = blk_init_queue(mtd_blktrans_request, &new->queue_lock);
+
+	if (!new->rq)
+		goto error3;
+
+	new->rq->queuedata = new;
+	blk_queue_logical_block_size(new->rq, tr->blksize);
+
+	if (tr->discard)
+		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD,
+					new->rq);
+
+	gd->queue = new->rq;
+
+	/* Create processing thread */
+	/* TODO: workqueue ? */
+	new->thread = kthread_run(mtd_blktrans_thread, new,
+			"%s%d", tr->name, new->mtd->index);
+	if (IS_ERR(new->thread)) {
+		ret = PTR_ERR(new->thread);
+		goto error4;
+	}
 	gd->driverfs_dev = &new->mtd->dev;
 
 	if (new->readonly)
 		set_disk_ro(gd, 1);
 
 	add_disk(gd);
-
 	return 0;
+error4:
+	blk_cleanup_queue(new->rq);
+error3:
+	put_disk(new->disk);
+error2:
+	list_del(&new->list);
+error1:
+	kfree(new);
+	return ret;
 }
 
 int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
@@ -303,9 +327,13 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
 
 	list_del(&old->list);
 
-	del_gendisk(old->blkcore_priv);
-	put_disk(old->blkcore_priv);
+	/* stop new requests to arrive */
+	del_gendisk(old->disk);
 
+	/* Stop the thread */
+	kthread_stop(old->thread);
+
+	blk_cleanup_queue(old->rq);
 	return 0;
 }
 
@@ -347,9 +375,6 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
 	if (!blktrans_notifier.list.next)
 		register_mtd_user(&blktrans_notifier);
 
-	tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
-	if (!tr->blkcore_priv)
-		return -ENOMEM;
 
 	mutex_lock(&mtd_table_mutex);
 
@@ -357,39 +382,12 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
 	if (ret) {
 		printk(KERN_WARNING "Unable to register %s block device on major %d: %d\n",
 		       tr->name, tr->major, ret);
-		kfree(tr->blkcore_priv);
 		mutex_unlock(&mtd_table_mutex);
 		return ret;
 	}
-	spin_lock_init(&tr->blkcore_priv->queue_lock);
-
-	tr->blkcore_priv->rq = blk_init_queue(mtd_blktrans_request, &tr->blkcore_priv->queue_lock);
-	if (!tr->blkcore_priv->rq) {
-		unregister_blkdev(tr->major, tr->name);
-		kfree(tr->blkcore_priv);
-		mutex_unlock(&mtd_table_mutex);
-		return -ENOMEM;
-	}
-
-	tr->blkcore_priv->rq->queuedata = tr;
-	blk_queue_logical_block_size(tr->blkcore_priv->rq, tr->blksize);
-	if (tr->discard)
-		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD,
-					tr->blkcore_priv->rq);
 
 	tr->blkshift = ffs(tr->blksize) - 1;
 
-	tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr,
-			"%sd", tr->name);
-	if (IS_ERR(tr->blkcore_priv->thread)) {
-		ret = PTR_ERR(tr->blkcore_priv->thread);
-		blk_cleanup_queue(tr->blkcore_priv->rq);
-		unregister_blkdev(tr->major, tr->name);
-		kfree(tr->blkcore_priv);
-		mutex_unlock(&mtd_table_mutex);
-		return ret;
-	}
-
 	INIT_LIST_HEAD(&tr->devs);
 	list_add(&tr->list, &blktrans_majors);
 
@@ -408,8 +406,6 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
 
 	mutex_lock(&mtd_table_mutex);
 
-	/* Clean up the kernel thread */
-	kthread_stop(tr->blkcore_priv->thread);
 
 	/* Remove it from the list of active majors */
 	list_del(&tr->list);
@@ -417,13 +413,9 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
 	list_for_each_entry_safe(dev, next, &tr->devs, list)
 		tr->remove_dev(dev);
 
-	blk_cleanup_queue(tr->blkcore_priv->rq);
 	unregister_blkdev(tr->major, tr->name);
-
 	mutex_unlock(&mtd_table_mutex);
 
-	kfree(tr->blkcore_priv);
-
 	BUG_ON(!list_empty(&tr->devs));
 	return 0;
 }
include/linux/mtd/blktrans.h +5 -5
index 8b4aa05..a4b3928 100644
@@ -24,11 +24,13 @@ struct mtd_blktrans_dev {
 	int devnum;
 	unsigned long size;
 	int readonly;
-	void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */
+	struct gendisk *disk;
+	struct task_struct *thread;
+	struct request_queue *rq;
+	spinlock_t queue_lock;
+	void *priv;
 };
 
-struct blkcore_priv; /* Differs for 2.4 and 2.5 kernels; private */
-
 struct mtd_blktrans_ops {
 	char *name;
 	int major;
@@ -60,8 +62,6 @@ struct mtd_blktrans_ops {
 	struct list_head devs;
 	struct list_head list;
 	struct module *owner;
-
-	struct mtd_blkcore_priv *blkcore_priv;
 };
 
 extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr);
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH v10 3/15 blktrans: Hotplug fixes

In reply to Maxim Levitsky

* Add locking where it was missing.
* Don't do a get_mtd_device in blktrans_open because it would lead to a deadlock instead do that in add_mtd_blktrans_dev.

* Only free the mtd_blktrans_dev structure when the last user exits.

* Flush request queue on device removal.

* Track users, and call tr->release in del_mtd_blktrans_dev Due to that ->open and release aren't called more that once.

Now it is safe to call del_mtd_blktrans_dev while the device is still in use.

---
 drivers/mtd/ftl.c            |    1 -
 drivers/mtd/inftlcore.c      |    1 -
 drivers/mtd/mtd_blkdevs.c    |  202 ++++++++++++++++++++++++++++++-----------
 drivers/mtd/mtdblock.c       |    2 -
 drivers/mtd/mtdblock_ro.c    |    1 -
 drivers/mtd/nftlcore.c       |    1 -
 drivers/mtd/rfd_ftl.c        |    1 -
 drivers/mtd/ssfdc.c          |    1 -
 include/linux/mtd/blktrans.h |    3 +
 9 files changed, 151 insertions(+), 62 deletions(-)
drivers/mtd/ftl.c +0 -1
index e56d6b4..62da9eb 100644
@@ -1082,7 +1082,6 @@ static void ftl_remove_dev(struct mtd_blktrans_dev *dev)
 {
 	del_mtd_blktrans_dev(dev);
 	ftl_freepart((partition_t *)dev);
-	kfree(dev);
 }
 
 static struct mtd_blktrans_ops ftl_tr = {
drivers/mtd/inftlcore.c +0 -1
index 8aca552..015a7fe 100755
@@ -139,7 +139,6 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev)
 
 	kfree(inftl->PUtable);
 	kfree(inftl->VUtable);
-	kfree(inftl);
 }
 
 /*
drivers/mtd/mtd_blkdevs.c +148 -54

316 lines not on this page · raw message

drivers/mtd/mtdblock.c +0 -2
index 69f6bf2..8e5da1e 100644
@@ -354,9 +354,7 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
 {
 	struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
-
 	del_mtd_blktrans_dev(dev);
-	kfree(mtdblk);
 }
 
 static struct mtd_blktrans_ops mtdblock_tr = {
drivers/mtd/mtdblock_ro.c +0 -1
index 852165f..54ff288 100644
@@ -49,7 +49,6 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
 {
 	del_mtd_blktrans_dev(dev);
-	kfree(dev);
 }
 
 static struct mtd_blktrans_ops mtdblock_tr = {
drivers/mtd/nftlcore.c +0 -1
index 1002e18..a4578bf 100644
@@ -126,7 +126,6 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
 	del_mtd_blktrans_dev(dev);
 	kfree(nftl->ReplUnitTable);
 	kfree(nftl->EUNtable);
-	kfree(nftl);
 }
 
 /*
drivers/mtd/rfd_ftl.c +0 -1
index d2aa9c4..63b83c0 100644
@@ -817,7 +817,6 @@ static void rfd_ftl_remove_dev(struct mtd_blktrans_dev *dev)
 	vfree(part->sector_map);
 	kfree(part->header_cache);
 	kfree(part->blocks);
-	kfree(part);
 }
 
 static struct mtd_blktrans_ops rfd_ftl_tr = {
drivers/mtd/ssfdc.c +0 -1
index 3f67e00..81c4ecd 100644
@@ -375,7 +375,6 @@ static void ssfdcr_remove_dev(struct mtd_blktrans_dev *dev)
 
 	del_mtd_blktrans_dev(dev);
 	kfree(ssfdc->logic_block_map);
-	kfree(ssfdc);
 }
 
 static int ssfdcr_readsect(struct mtd_blktrans_dev *dev,
include/linux/mtd/blktrans.h +3 -0
index a4b3928..d89b8fb 100644
@@ -9,6 +9,7 @@
 #define __MTD_TRANS_H__
 
 #include <linux/mutex.h>
+#include <linux/kref.h>
 
 struct hd_geometry;
 struct mtd_info;
@@ -24,6 +25,8 @@ struct mtd_blktrans_dev {
 	int devnum;
 	unsigned long size;
 	int readonly;
+	int open;
+	struct kref ref;
 	struct gendisk *disk;
 	struct task_struct *thread;
 	struct request_queue *rq;
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH v10 4/15 MTD: mtdblock: test return value of add_mtd_blktrans_dev, because if can fail

In reply to Maxim Levitsky

This prevents a memory leak

---
 drivers/mtd/mtdblock.c    |    3 ++-
 drivers/mtd/mtdblock_ro.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/mtdblock.c +2 -1
index 8e5da1e..7ce30a2 100644
@@ -348,7 +348,8 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 	if (!(mtd->flags & MTD_WRITEABLE))
 		dev->mbd.readonly = 1;
 
-	add_mtd_blktrans_dev(&dev->mbd);
+	if (add_mtd_blktrans_dev(&dev->mbd))
+		kfree(dev);
 }
 
 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
drivers/mtd/mtdblock_ro.c +2 -1
index 54ff288..d0d3f79 100644
@@ -43,7 +43,8 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 	dev->tr = tr;
 	dev->readonly = 1;
 
-	add_mtd_blktrans_dev(dev);
+	if (add_mtd_blktrans_dev(dev))
+		kfree(dev);
 }
 
 static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
Signature · 1 line
1.6.3.3
#5 lore raw

PATCH v10 5/15 MTD: call the remove notifiers before assuming it is in use

In reply to Maxim Levitsky

Now that mtd block common layer is prepared for proper hotplug support, enable it here

Now all users of the mtd device have a chance to put the mtd device when they are notified to do so, and they have to do so to make hotplug work.

---
 drivers/mtd/mtdcore.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
drivers/mtd/mtdcore.c +11 -8
index 67669a7..70a7858 100644
@@ -350,31 +350,34 @@ fail_locked:
 int del_mtd_device (struct mtd_info *mtd)
 {
 	int ret;
+	struct mtd_notifier *not;
 
 	mutex_lock(&mtd_table_mutex);
 
 	if (idr_find(&mtd_idr, mtd->index) != mtd) {
 		ret = -ENODEV;
-	} else if (mtd->usecount) {
+		goto out_error;
+	}
+
+	/* No need to get a refcount on the module containing
+		the notifier, since we hold the mtd_table_mutex */
+	list_for_each_entry(not, &mtd_notifiers, list)
+		not->remove(mtd);
+
+	if (mtd->usecount) {
 		printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
 		       mtd->index, mtd->name, mtd->usecount);
 		ret = -EBUSY;
 	} else {
-		struct mtd_notifier *not;
-
 		device_unregister(&mtd->dev);
 
-		/* No need to get a refcount on the module containing
-		   the notifier, since we hold the mtd_table_mutex */
-		list_for_each_entry(not, &mtd_notifiers, list)
-			not->remove(mtd);
-
 		idr_remove(&mtd_idr, mtd->index);
 
 		module_put(THIS_MODULE);
 		ret = 0;
 	}
 
+out_error:
 	mutex_unlock(&mtd_table_mutex);
 	return ret;
 }
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH v10 6/15 blktrans: allow FTL drivers to export sysfs attributes

In reply to Maxim Levitsky

This patch adds an ability to export sysfs attributes below the block disk device.

This can be used to pass the udev an information about the FTL and could include the vendor, serial, version, etc...

---
 drivers/mtd/mtd_blkdevs.c    |    8 ++++++++
 include/linux/mtd/blktrans.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
drivers/mtd/mtd_blkdevs.c +8 -0
index 646cc84..9dd23d6 100644
@@ -379,6 +379,10 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 		set_disk_ro(gd, 1);
 
 	add_disk(gd);
+
+	if (new->disk_attributes)
+		sysfs_create_group(&disk_to_dev(gd)->kobj,
+					new->disk_attributes);
 	return 0;
 error4:
 	module_put(tr->owner);
@@ -405,6 +409,10 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
 	/* Stop new requests to arrive */
 	del_gendisk(old->disk);
 
+	if (old->disk_attributes)
+		sysfs_remove_group(&disk_to_dev(old->disk)->kobj,
+						old->disk_attributes);
+
 	/* Stop the thread */
 	kthread_stop(old->thread);
 
include/linux/mtd/blktrans.h +2 -0
index d89b8fb..b481ccd 100644
@@ -10,6 +10,7 @@
 
 #include <linux/mutex.h>
 #include <linux/kref.h>
+#include <linux/sysfs.h>
 
 struct hd_geometry;
 struct mtd_info;
@@ -28,6 +29,7 @@ struct mtd_blktrans_dev {
 	int open;
 	struct kref ref;
 	struct gendisk *disk;
+	struct attribute_group *disk_attributes;
 	struct task_struct *thread;
 	struct request_queue *rq;
 	spinlock_t queue_lock;
Signature · 1 line
1.6.3.3
#7 lore raw

PATCH v10 7/15 MTD: nand: make suspend work if device is accessed by kernel threads.

In reply to Maxim Levitsky

Since all userspace threads are frozen at the time the nand_suspend is called, they aren't inside any nand function.

We don't call try_to_freeze in nand ether. Thus the only user that can be inside the nand functions is an non freezeable kernel thread.
Thus we can safely wait for it to finish.

---
 drivers/mtd/nand/nand_base.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mtd/nand/nand_base.c +0 -3
index ed62e1e..7442b3a 100644
@@ -773,9 +773,6 @@ nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)
 			chip->state = FL_PM_SUSPENDED;
 			spin_unlock(lock);
 			return 0;
-		} else {
-			spin_unlock(lock);
-			return -EAGAIN;
 		}
 	}
 	set_current_state(TASK_UNINTERRUPTIBLE);
Signature · 1 line
1.6.3.3
#8 lore raw

PATCH v10 8/15 MTD: nand: make MTD_OOB_PLACE work correctly.

In reply to Maxim Levitsky

MTD_OOB_PLACE is supposed to read/write the raw oob data similiar to the MTD_OOB_RAW however due to a bug, currently it is not possible to read more data that is specified by the oob 'free' regions.

---
 drivers/mtd/nand/nand_base.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/mtd/nand/nand_base.c +5 -1
index 7442b3a..cada4cf 100644
@@ -1420,6 +1420,9 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 	int ret = 0;
 	uint32_t readlen = ops->len;
 	uint32_t oobreadlen = ops->ooblen;
+	uint32_t max_oobsize = ops->mode == MTD_OOB_AUTO ?
+		mtd->oobavail : mtd->oobsize;
+
 	uint8_t *bufpoi, *oob, *buf;
 
 	stats = mtd->ecc_stats;
@@ -1470,10 +1473,11 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 			buf += bytes;
 
 			if (unlikely(oob)) {
+
 				/* Raw mode does data:oob:data:oob */
 				if (ops->mode != MTD_OOB_RAW) {
 					int toread = min(oobreadlen,
-						chip->ecc.layout->oobavail);
+								max_oobsize);
 					if (toread) {
 						oob = nand_transfer_oob(chip,
 							oob, ops, toread);
Signature · 1 line
1.6.3.3
#9 lore raw

PATCH v10 9/15 MTD: nand: cleanup the nand_do_write_ops

In reply to Maxim Levitsky

nand_do_write_ops have broken in regard to writing several pages,
each with its own oob.

Although nand_do_write_ops intends to allow such mode, it fails do do so Probably this was never tested.

Also add missing checks for attemts to write at illegal offsets.

---
 drivers/mtd/nand/nand_base.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
drivers/mtd/nand/nand_base.c +17 -7
index cada4cf..1386741 100644
@@ -2072,11 +2072,9 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
  * @oob:	oob data buffer
  * @ops:	oob ops structure
  */
-static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob,
-				  struct mtd_oob_ops *ops)
+static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, size_t len,
+						struct mtd_oob_ops *ops)
 {
-	size_t len = ops->ooblen;
-
 	switch(ops->mode) {
 
 	case MTD_OOB_PLACE:
@@ -2131,6 +2129,11 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 	int chipnr, realpage, page, blockmask, column;
 	struct nand_chip *chip = mtd->priv;
 	uint32_t writelen = ops->len;
+
+	uint32_t oobwritelen = ops->ooblen;
+	uint32_t oobmaxlen = ops->mode == MTD_OOB_AUTO ?
+				mtd->oobavail : mtd->oobsize;
+
 	uint8_t *oob = ops->oobbuf;
 	uint8_t *buf = ops->datbuf;
 	int ret, subpage;
@@ -2172,6 +2175,10 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 	if (likely(!oob))
 		memset(chip->oob_poi, 0xff, mtd->oobsize);
 
+	/* Don't allow multipage oob writes with offset */
+	if (ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
+		return -EINVAL;
+
 	while(1) {
 		int bytes = mtd->writesize;
 		int cached = writelen > bytes && page != blockmask;
@@ -2187,8 +2194,11 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
 			wbuf = chip->buffers->databuf;
 		}
 
-		if (unlikely(oob))
-			oob = nand_fill_oob(chip, oob, ops);
+		if (unlikely(oob)) {
+			size_t len = min(oobwritelen, oobmaxlen);
+			oob = nand_fill_oob(chip, oob, len, ops);
+			oobwritelen -= len;
+		}
 
 		ret = chip->write_page(mtd, chip, wbuf, page, cached,
 				       (ops->mode == MTD_OOB_RAW));
@@ -2362,7 +2372,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
 		chip->pagebuf = -1;
 
 	memset(chip->oob_poi, 0xff, mtd->oobsize);
-	nand_fill_oob(chip, ops->oobbuf, ops);
+	nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops);
 	status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask);
 	memset(chip->oob_poi, 0xff, mtd->oobsize);
 
Signature · 1 line
1.6.3.3
#10 lore raw

PATCH v10 10/15 MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

In reply to Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

---
 drivers/mtd/nand/nand_base.c |   19 +++++++------------
 drivers/mtd/nand/nand_bbt.c  |   26 ++++++++++++++++++++++----
 include/linux/mtd/mtd.h      |    4 +---
 3 files changed, 30 insertions(+), 19 deletions(-)
drivers/mtd/nand/nand_base.c +7 -12
index 1386741..51dfea1 100644
@@ -1474,18 +1474,13 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 			if (unlikely(oob)) {
 
-				/* Raw mode does data:oob:data:oob */
-				if (ops->mode != MTD_OOB_RAW) {
-					int toread = min(oobreadlen,
-								max_oobsize);
-					if (toread) {
-						oob = nand_transfer_oob(chip,
-							oob, ops, toread);
-						oobreadlen -= toread;
-					}
-				} else
-					buf = nand_transfer_oob(chip,
-						buf, ops, mtd->oobsize);
+				int toread = min(oobreadlen, max_oobsize);
+
+				if (toread) {
+					oob = nand_transfer_oob(chip,
+						oob, ops, toread);
+					oobreadlen -= toread;
+				}
 			}
 
 			if (!(chip->options & NAND_NO_READRDY)) {
drivers/mtd/nand/nand_bbt.c +22 -4
index 55c23e5..387c45c 100644
@@ -237,15 +237,33 @@ static int scan_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
 			 size_t len)
 {
 	struct mtd_oob_ops ops;
+	int res;
 
 	ops.mode = MTD_OOB_RAW;
 	ops.ooboffs = 0;
 	ops.ooblen = mtd->oobsize;
-	ops.oobbuf = buf;
-	ops.datbuf = buf;
-	ops.len = len;
 
-	return mtd->read_oob(mtd, offs, &ops);
+
+	while (len > 0) {
+		if (len <= mtd->writesize) {
+			ops.oobbuf = buf + len;
+			ops.datbuf = buf;
+			ops.len = len;
+			return mtd->read_oob(mtd, offs, &ops);
+		} else {
+			ops.oobbuf = buf + mtd->writesize;
+			ops.datbuf = buf;
+			ops.len = mtd->writesize;
+			res = mtd->read_oob(mtd, offs, &ops);
+
+			if (res)
+				return res;
+		}
+
+		buf += mtd->oobsize + mtd->writesize;
+		len -= mtd->writesize;
+	}
+	return 0;
 }
 
 /*
include/linux/mtd/mtd.h +1 -3
index 11d8e68..5326435 100644
@@ -60,9 +60,7 @@ struct mtd_erase_region_info {
  * MTD_OOB_PLACE:	oob data are placed at the given offset
  * MTD_OOB_AUTO:	oob data are automatically placed at the free areas
  *			which are defined by the ecclayout
- * MTD_OOB_RAW:		mode to read raw data+oob in one chunk. The oob data
- *			is inserted into the data. Thats a raw image of the
- *			flash contents.
+ * MTD_OOB_RAW:		mode to read oob and data without doing ECC checking
  */
 typedef enum {
 	MTD_OOB_PLACE,
Signature · 1 line
1.6.3.3
#11 lore raw

Re: [PATCH 10/15] MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

Quoted 7 lines · Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

Is this tested against existing user space tools like nanddump ? Can I still get the raw data from flash ?

Thanks,

tglx

#12 lore raw

Re: [PATCH 10/15] MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

Quoted 7 lines
Quoted 4 lines

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

Is this tested against existing user space tools like nanddump ? Can I still get the raw data from flash ?

Thats the point.
Userspace doesn't/can't use that mode.
It is not exposed through mtdchar.
Userspace reads the page, and then reads the oob.

It does use MTD_OOB_RAW, but without data buffer, and this path I don't change.

The only user of this, is the nand itself, when it reads bad block table.

I confess that I didn't run test that I ported this code correctly. But I did logically verified many times that the new code works just like old one.

Best regards,
Maxim Levitsky

#13 lore raw

Re: [PATCH 10/15] MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

Quoted 22 lines · Maxim Levitsky
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

Quoted 7 lines
Quoted 4 lines

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

Is this tested against existing user space tools like nanddump ? Can I still get the raw data from flash ?

Thats the point.
Userspace doesn't/can't use that mode.
It is not exposed through mtdchar.
Userspace reads the page, and then reads the oob.

It does use MTD_OOB_RAW, but without data buffer, and this path I don't change.

Quoted 6 lines

The only user of this, is the nand itself, when it reads bad block table.

I confess that I didn't run test that I ported this code correctly. But I did logically verified many times that the new code works just like old one.

Well, then it's about time to run the tests :)

Thanks,

tglx

#14 lore raw

Re: [PATCH 10/15] MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

Quoted 23 lines · Thomas Gleixner
Quoted 22 lines · Maxim Levitsky
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

Quoted 7 lines
Quoted 4 lines

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

Is this tested against existing user space tools like nanddump ? Can I still get the raw data from flash ?

Thats the point.
Userspace doesn't/can't use that mode.
It is not exposed through mtdchar.
Userspace reads the page, and then reads the oob.

It does use MTD_OOB_RAW, but without data buffer, and this path I don't change.

Quoted 8 lines
Quoted 6 lines

The only user of this, is the nand itself, when it reads bad block table.

I confess that I didn't run test that I ported this code correctly. But I did logically verified many times that the new code works just like old one.

Well, then it's about time to run the tests :)

Can this be done with nandsim?

Best regards,
Maxim Levitsky

#15 lore raw

Re: [PATCH 10/15] MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

Quoted 24 lines · Maxim Levitsky
Quoted 23 lines · Thomas Gleixner
Quoted 22 lines · Maxim Levitsky
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

Quoted 7 lines
Quoted 4 lines

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

Is this tested against existing user space tools like nanddump ? Can I still get the raw data from flash ?

Thats the point.
Userspace doesn't/can't use that mode.
It is not exposed through mtdchar.
Userspace reads the page, and then reads the oob.

It does use MTD_OOB_RAW, but without data buffer, and this path I don't change.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The only user of this, is the nand itself, when it reads bad block table.

I confess that I didn't run test that I ported this code correctly. But I did logically verified many times that the new code works just like old one.

Note that only this patch is in question, and only . Rest are tested with my driver,

While doing some testing, I tried to use ubi, but it appears to try 256 byte writes (subpage write I guess), and it fails _without_ my patches:

[  723.478676] UBI: attached mtd0 to ubi0
[  723.478686] UBI: MTD device name:            "NAND simulator partition 0"
[  723.478701] UBI: MTD device size:            8 MiB
[  723.478711] UBI: number of good PEBs:        1024
[  723.478720] UBI: number of bad PEBs:         0
[  723.478730] UBI: max. allowed volumes:       44
[  723.478739] UBI: wear-leveling threshold:    4096
[  723.478749] UBI: number of internal volumes: 1
[  723.478758] UBI: number of user volumes:     0
[  723.478767] UBI: available PEBs:             1010
[  723.478777] UBI: total number of reserved PEBs: 14
[  723.478787] UBI: number of PEBs reserved for bad PEB handling: 10
[  723.478800] UBI: max/mean erase counter: 0/0
[  723.478809] UBI: image sequence number: 0
[  723.480508] UBI: background thread "ubi_bgt0d" started, PID 4556
[  757.904206] UBI DBG (pid 4580): ubi_cdev_ioctl: create volume
[  757.904231] UBI DBG (pid 4580): ubi_create_volume: search for vacant volume ID
[  757.904246] UBI DBG (pid 4580): ubi_create_volume: create device 0, volume 0, 7756800 bytes, type 3, name aaa
[  757.906376] UBI error: ubi_io_write: error -5 while writing 256 bytes to PEB 0:256, written 0 bytes
[  757.906398] Pid: 4580, comm: ubimkvol Tainted: P           2.6.33-rc8-wl #25
[  757.906412] Call Trace:
[  757.906431]  [<ffffffffa0d8b1f2>] ubi_io_write+0x252/0x270 [ubi]
[  757.906447]  [<ffffffffa0d8b283>] ubi_io_write_vid_hdr+0x73/0x190 [ubi]
[  757.906464]  [<ffffffffa0d89f58>] ubi_eba_write_leb+0x198/0x7b0 [ubi]
[  757.906481]  [<ffffffff81350c90>] ? _raw_spin_unlock+0x30/0x60
[  757.906497]  [<ffffffffa0d892b1>] ? leb_write_unlock+0xa1/0xf0 [ubi]
[  757.906515]  [<ffffffffa0d82483>] ubi_change_vtbl_record+0x103/0x1c0 [ubi]
[  757.906534]  [<ffffffff81234474>] ? device_create_file+0x14/0x20
[  757.906552]  [<ffffffffa0d837ee>] ubi_create_volume+0x4ce/0x710 [ubi]
[  757.906569]  [<ffffffff8103418b>] ? release_console_sem+0x1eb/0x240
[  757.906586]  [<ffffffffa0d86589>] ubi_cdev_ioctl+0x2e9/0xb50 [ubi]
[  757.906603]  [<ffffffff810bf399>] ? __dentry_open+0x149/0x330
[  757.906619]  [<ffffffff810d0658>] vfs_ioctl+0x38/0xd0
[  757.906632]  [<ffffffff810d082a>] do_vfs_ioctl+0x8a/0x5b0
[  757.906645]  [<ffffffff8105e69d>] ? trace_hardirqs_on+0xd/0x10
[  757.906658]  [<ffffffff810d0d9a>] sys_ioctl+0x4a/0x80
[  757.906672]  [<ffffffff81002cab>] system_call_fastpath+0x16/0x1b
[  757.906753] UBI DBG (pid 4580): ubi_dbg_dump_flash: dumping 256 bytes of data from PEB 0, offset 256
[  757.906772] 00000000: 55 42 49 21 01 01 00 05 7f ff ef ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  UBI!............................
[  757.906797] 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 65 b3 bd 2d  ............................e..-
[  757.906821] 00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.906846] 00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.906874] 00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.906898] 000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.906920] 000000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.906943] 000000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.906977] UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 0
[  757.907016] UBI: run torture test for PEB 0
[  757.908132] UBI: PEB 0 passed torture test, do not mark it a bad
[  757.908211] UBI: try another PEB
[  757.908227] UBI error: ubi_io_write: error -5 while writing 256 bytes to PEB 0:256, written 0 bytes
[  757.908243] Pid: 4580, comm: ubimkvol Tainted: P           2.6.33-rc8-wl #25
[  757.908256] Call Trace:
[  757.908268]  [<ffffffffa0d8b1f2>] ubi_io_write+0x252/0x270 [ubi]
[  757.908284]  [<ffffffffa0d8b283>] ubi_io_write_vid_hdr+0x73/0x190 [ubi]
[  757.908300]  [<ffffffffa0d89f58>] ubi_eba_write_leb+0x198/0x7b0 [ubi]
[  757.908314]  [<ffffffff81350c90>] ? _raw_spin_unlock+0x30/0x60
[  757.908329]  [<ffffffffa0d892b1>] ? leb_write_unlock+0xa1/0xf0 [ubi]
[  757.908345]  [<ffffffffa0d82483>] ubi_change_vtbl_record+0x103/0x1c0 [ubi]
[  757.908359]  [<ffffffff81234474>] ? device_create_file+0x14/0x20
[  757.908374]  [<ffffffffa0d837ee>] ubi_create_volume+0x4ce/0x710 [ubi]
[  757.908388]  [<ffffffff8103418b>] ? release_console_sem+0x1eb/0x240
[  757.908404]  [<ffffffffa0d86589>] ubi_cdev_ioctl+0x2e9/0xb50 [ubi]
[  757.908418]  [<ffffffff810bf399>] ? __dentry_open+0x149/0x330
[  757.908431]  [<ffffffff810d0658>] vfs_ioctl+0x38/0xd0
[  757.908443]  [<ffffffff810d082a>] do_vfs_ioctl+0x8a/0x5b0
[  757.908455]  [<ffffffff8105e69d>] ? trace_hardirqs_on+0xd/0x10
[  757.908467]  [<ffffffff810d0d9a>] sys_ioctl+0x4a/0x80
[  757.908479]  [<ffffffff81002cab>] system_call_fastpath+0x16/0x1b
[  757.908543] UBI DBG (pid 4580): ubi_dbg_dump_flash: dumping 256 bytes of data from PEB 0, offset 256
[  757.908560] 00000000: 55 42 49 21 01 01 00 05 7f ff ef ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  UBI!............................
[  757.908582] 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 d8 79 d1 e3  .............................y..
[  757.908605] 00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.908628] 00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.908650] 00000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.908673] 000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.908695] 000000c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.908718] 000000e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................................
[  757.908752] UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 0
[  757.908788] UBI: run torture test for PEB 0
[  757.909892] UBI: PEB 0 passed torture test, do not mark it a bad
[  757.909971] UBI: try another PEB
[  757.909987] UBI error: ubi_io_write: error -5 while writing 256 bytes to PEB 0:256, written 0 bytes
[  757.910214] Pid: 4580, comm: ubimkvol Tainted: P           2.6.33-rc8-wl #25

What I did so far:

sudo modprobe nandsim
sudo modprobe ubi
sudo ubiformat /dev/mtd0
sudo ubiattach /dev/ubi_ctrl -m0 -d 0
sudo ubimkvol -m -N test /dev/ubi0

Then I suppose I can mount /dev/ubi0 with ubifs, right? (If there were no errors of course)

Best regards,
Maxim Levitsky

#16 lore raw

Re: [PATCH 10/15] MTD: nand: make reads using MTD_OOB_RAW affect only ECC validation

In reply to Thomas Gleixner
Quoted 26 lines · Thomas Gleixner
Quoted 25 lines · Maxim Levitsky
Quoted 5 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

This changes the behavier of MTD_OOB_RAW. It used to read both OOB and data to the data buffer, however you would still need to specify the dummy oob buffer.

Quoted 7 lines
Quoted 4 lines

This is only used in one place, but makes it hard to read data+oob without ECC test, thus I removed that behavier, and fixed the user.

Now MTD_OOB_RAW behaves just like MTD_OOB_PLACE, but doesn't do ECC validation

Is this tested against existing user space tools like nanddump ? Can I still get the raw data from flash ?

Thats the point.
Userspace doesn't/can't use that mode.
It is not exposed through mtdchar.
Userspace reads the page, and then reads the oob.

It does use MTD_OOB_RAW, but without data buffer, and this path I don't change.

The only user of this, is the nand itself, when it reads bad block table.

Quoted 7 lines
Quoted 3 lines

I confess that I didn't run test that I ported this code correctly. But I did logically verified many times that the new code works just like old one.

Well, then it's about time to run the tests :)

Thanks,

Just to be sure, I tested jffs2 and nanddump.

Works just fine.

Best regards,
Maxim Levitsky

#17 lore raw

PATCH v10 11/15 MTD: nand: add ->badblockbits to specify the minimum number of bits in bad block byte to consider the block good

In reply to Maxim Levitsky

This can be used to protect against bitflips in that field, but now mostly for smartmedia.

---
 drivers/mtd/nand/nand_base.c |   13 +++++++++----
 include/linux/mtd/nand.h     |    1 +
 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/mtd/nand/nand_base.c +9 -4
index 51dfea1..ba29a29 100644
@@ -364,14 +364,18 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
 		bad = cpu_to_le16(chip->read_word(mtd));
 		if (chip->badblockpos & 0x1)
 			bad >>= 8;
-		if ((bad & 0xFF) != 0xff)
-			res = 1;
+		else
+			bad &= 0xFF;
 	} else {
 		chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page);
-		if (chip->read_byte(mtd) != 0xff)
-			res = 1;
+		bad = chip->read_byte(mtd);
 	}
 
+	if (likely(chip->badblockbits == 8))
+		res = bad != 0xFF;
+	else
+		res = hweight8(bad) < chip->badblockbits;
+
 	if (getchip)
 		nand_release_device(mtd);
 
@@ -2884,6 +2888,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 	/* Set the bad block position */
 	chip->badblockpos = mtd->writesize > 512 ?
 		NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
+	chip->badblockbits = 8;
 
 	/* Get chip options, preserve non chip based options */
 	chip->options &= ~NAND_CHIPOPTIONS_MSK;
include/linux/mtd/nand.h +1 -0
index 48bc2c5..f2d4a1a 100644
@@ -401,6 +401,7 @@ struct nand_chip {
 	int		subpagesize;
 	uint8_t		cellinfo;
 	int		badblockpos;
+	int		badblockbits;
 
 	flstate_t	state;
 
Signature · 1 line
1.6.3.3
#18 lore raw

PATCH v10 12/15 MTD: common module for smartmedia/xD support

In reply to Maxim Levitsky

This small module implements few helpers that are usefull for nand drivers for SmartMedia/xD card readers.

---
 drivers/mtd/nand/Kconfig     |    9 ++++
 drivers/mtd/nand/Makefile    |    1 +
 drivers/mtd/nand/sm_common.c |  107 ++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/sm_common.h |   61 ++++++++++++++++++++++++
 4 files changed, 178 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/sm_common.c
 create mode 100644 drivers/mtd/nand/sm_common.h
drivers/mtd/nand/Kconfig +9 -0
index 22cee48..31273c7 100644
@@ -18,6 +18,10 @@ config MTD_NAND_VERIFY_WRITE
 	  device thinks the write was successful, a bit could have been
 	  flipped accidentally due to device wear or something else.
 
+config MTD_NAND_SMARTMEDIA
+	boolean
+	default n
+
 config MTD_NAND_ECC_SMC
 	bool "NAND ECC Smart Media byte order"
 	default n
@@ -25,6 +29,11 @@ config MTD_NAND_ECC_SMC
 	  Software ECC according to the Smart Media Specification.
 	  The original Linux implementation had byte 0 and 1 swapped.
 
+config MTD_SM_COMMON
+	select MTD_NAND_SMARTMEDIA
+	tristate
+	default n
+
 config MTD_NAND_MUSEUM_IDS
 	bool "Enable chip ids for obsolete ancient NAND devices"
 	depends on MTD_NAND
drivers/mtd/nand/Makefile +1 -0
index 39b4af2..e699bef 100644
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_MTD_NAND)			+= nand.o nand_ecc.o
 obj-$(CONFIG_MTD_NAND_IDS)		+= nand_ids.o
+obj-$(CONFIG_MTD_SM_COMMON) 		+= sm_common.o
 
 obj-$(CONFIG_MTD_NAND_CAFE)		+= cafe_nand.o
 obj-$(CONFIG_MTD_NAND_SPIA)		+= spia.o
drivers/mtd/nand/sm_common.c new file +107 -0

107 lines not on this page · raw message

drivers/mtd/nand/sm_common.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#19 lore raw

PATCH v10 13/15 MTD: add few workarounds to nand system for SmartMedia/xD chips.

In reply to Maxim Levitsky

* Add an option NAND_SMARTMEDIA that can be set by nand driver If set, it will cause separate ID table to be used, which includes mask rom devices and new xD cards

* Workaround for wrong write protect status on some xD cards

---
 drivers/mtd/nand/nand_base.c |   32 +++++++++++++++++++++++---------
 drivers/mtd/nand/nand_ids.c  |   39 +++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/nand.h     |   11 +++++++++++
 3 files changed, 73 insertions(+), 9 deletions(-)
drivers/mtd/nand/nand_base.c +23 -9
index ba29a29..fd9b00d 100644
@@ -434,9 +434,18 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
 static int nand_check_wp(struct mtd_info *mtd)
 {
 	struct nand_chip *chip = mtd->priv;
+	int wp;
+
+	/* broken xD cards report WP despite beeing writable */
+	if (chip->options & NAND_BROKEN_XD)
+		return 0;
+
 	/* Check the WP bit */
 	chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
-	return (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1;
+	wp = (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1;
+
+
+	return wp;
 }
 
 /**
@@ -2769,7 +2778,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 						  int busw, int *maf_id)
 {
 	struct nand_flash_dev *type = NULL;
-	int i, dev_id, maf_idx;
+	int dev_id, maf_idx;
 	int tmp_id, tmp_manf;
 
 	/* Select the device */
@@ -2809,14 +2818,18 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
 	}
 
 	/* Lookup the flash id */
-	for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-		if (dev_id == nand_flash_ids[i].id) {
-			type =  &nand_flash_ids[i];
+#ifdef CONFIG_MTD_NAND_SMARTMEDIA
+	if (chip->options & NAND_SMARTMEDIA)
+		type = nand_smartmedia_flash_ids;
+	else
+#endif
+		type = nand_flash_ids;
+
+	for (; type->name != NULL; type++)
+		if (dev_id == type->id)
 			break;
-		}
-	}
 
-	if (!type)
+	if (!type->name)
 		return ERR_PTR(-ENODEV);
 
 	if (!mtd->name)
@@ -3174,7 +3187,8 @@ int nand_scan_tail(struct mtd_info *mtd)
 
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
-	mtd->flags = MTD_CAP_NANDFLASH;
+	mtd->flags = chip->options & NAND_ROM ? MTD_CAP_ROM :
+							MTD_CAP_NANDFLASH;
 	mtd->erase = nand_erase;
 	mtd->point = NULL;
 	mtd->unpoint = NULL;
drivers/mtd/nand/nand_ids.c +39 -0
index 69ee2c9..f9e72d5 100644
@@ -127,6 +127,45 @@ struct nand_flash_dev nand_flash_ids[] = {
 	{NULL,}
 };
 
+#ifdef CONFIG_MTD_NAND_SMARTMEDIA
+struct nand_flash_dev nand_smartmedia_flash_ids[] = {
+
+	/* SmartMedia */
+	{"SmartMedia 1MiB 5V",		0x6e, 256, 1, 0x1000, 0},
+	{"SmartMedia 1MiB 3,3V",	0xe8, 256, 1, 0x1000, 0},
+	{"SmartMedia 1MiB 3,3V",	0xec, 256, 1, 0x1000, 0},
+	{"SmartMedia 2MiB 3,3V",	0xea, 256, 2, 0x1000, 0},
+	{"SmartMedia 2MiB 5V",		0x64, 256, 2, 0x1000, 0},
+	{"SmartMedia 2MiB 3,3V ROM",	0x5d, 512, 2, 0x2000, NAND_ROM},
+	{"SmartMedia 4MiB 3,3V",	0xe3, 512, 4, 0x2000, 0},
+	{"SmartMedia 4MiB 3,3/5V",	0xe5, 512, 4, 0x2000, 0},
+	{"SmartMedia 4MiB 5V",		0x6b, 512, 4, 0x2000, 0},
+	{"SmartMedia 4MiB 3,3V ROM",	0xd5, 512, 4, 0x2000, NAND_ROM},
+	{"SmartMedia 8MiB 3,3V",	0xe6, 512, 8, 0x2000, 0},
+	{"SmartMedia 8MiB 3,3V ROM",	0xd6, 512, 8, 0x2000, NAND_ROM},
+
+#define XD_TYPEM	(NAND_NO_AUTOINCR | NAND_BROKEN_XD)
+	/* xD / SmartMedia */
+	{"SmartMedia/xD 16MiB 3,3V",	0x73, 512, 16, 0x4000, 0},
+	{"SmartMedia 16MiB 3,3V ROM",	0x57, 512, 16, 0x4000, NAND_ROM},
+	{"SmartMedia/xD 32MiB 3,3V",	0x75, 512, 32, 0x4000, 0},
+	{"SmartMedia 32MiB 3,3V ROM",	0x58, 512, 32, 0x4000, NAND_ROM},
+	{"SmartMedia/xD 64MiB 3,3V",	0x76, 512, 64, 0x4000, 0},
+	{"SmartMedia 64MiB 3,3V ROM",	0xd9, 512, 64, 0x4000, NAND_ROM},
+	{"SmartMedia/xD 128MiB 3,3V",	0x79, 512, 128, 0x4000, 0},
+	{"SmartMedia 128MiB 3,3V ROM",	0xda, 512, 128, 0x4000, NAND_ROM},
+	{"SmartMedia/xD 256MiB 3,3V",	0x71, 512, 256, 0x4000, XD_TYPEM},
+	{"SmartMedia 256MiB 3,3V ROM",	0x5b, 512, 256, 0x4000, NAND_ROM},
+
+	/* xD only */
+	{"xD 512MiB 3,3V",		0xDC, 512, 512, 0x4000, XD_TYPEM},
+	{"xD 1GiB 3,3V",		0xD3, 512, 1024, 0x4000, XD_TYPEM},
+	{"xD 2GiB 3,3V",		0xD5, 512, 2048, 0x4000, XD_TYPEM},
+	{NULL,}
+};
+EXPORT_SYMBOL(nand_smartmedia_flash_ids);
+#endif
+
 /*
 *	Manufacturer ID list
 */
include/linux/mtd/nand.h +11 -0
index f2d4a1a..7291725 100644
@@ -180,6 +180,12 @@ typedef enum {
 /* Chip does not allow subpage writes */
 #define NAND_NO_SUBPAGE_WRITE	0x00000200
 
+/* Device is one of 'new' xD cards that expose fake nand command set */
+#define NAND_BROKEN_XD		0x00000400
+
+/* Device behaves just like nand, but is readonly */
+#define NAND_ROM		0x00000800
+
 /* Options valid for Samsung large page devices */
 #define NAND_SAMSUNG_LP_OPTIONS \
 	(NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)
@@ -205,9 +211,13 @@ typedef enum {
 /* This option is defined if the board driver allocates its own buffers
    (e.g. because it needs them DMA-coherent */
 #define NAND_OWN_BUFFERS	0x00040000
+
 /* Chip may not exist, so silence any errors in scan */
 #define NAND_SCAN_SILENT_NODEV	0x00080000
 
+/* controller supports only xD/SmartMedia cards*/
+#define NAND_SMARTMEDIA		0x00100000
+
 /* Options set by nand scan */
 /* Nand scan has allocated controller struct */
 #define NAND_CONTROLLER_ALLOC	0x80000000
@@ -469,6 +479,7 @@ struct nand_manufacturers {
 };
 
 extern struct nand_flash_dev nand_flash_ids[];
+extern struct nand_flash_dev nand_smartmedia_flash_ids[];
 extern struct nand_manufacturers nand_manuf_ids[];
 
 extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
Signature · 1 line
1.6.3.3
#20 lore raw

Re: [PATCH 13/15] MTD: add few workarounds to nand system for SmartMedia/xD chips.

Quoted 3 lines · Maxim Levitsky

* Add an option NAND_SMARTMEDIA that can be set by nand driver If set, it will cause separate ID table to be used, which includes mask rom devices and new xD cards

Why that option ? We can just extend the existing ids table and be done. No extra magic needed.

Thanks,

tglx

#21 lore raw

Re: [PATCH 13/15] MTD: add few workarounds to nand system for SmartMedia/xD chips.

Quoted 9 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

* Add an option NAND_SMARTMEDIA that can be set by nand driver If set, it will cause separate ID table to be used, which includes mask rom devices and new xD cards

Why that option ? We can just extend the existing ids table and be done. No extra magic needed.

Two reasons.

First of all several xD chips (I belive the Type M) have exactly same IDs like normal nand chips. However they don't report capabilities about pagesize, blocksize, etc.

I am confident that these cards have an internal FTL and controller, and just 'emulate' that nand interface.

Also, my card reports write protect, although, xD cards don't have any 'switch' to make them protected.
Even if there were readonly ROM xD cards (the odds of this are virtually zero), these won't just expose this in WP bit.

Best regards,
Maxim Levitsky

#22 lore raw

Re: [PATCH 13/15] MTD: add few workarounds to nand system for SmartMedia/xD chips.

Quoted 11 lines · Maxim Levitsky
Quoted 9 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

* Add an option NAND_SMARTMEDIA that can be set by nand driver If set, it will cause separate ID table to be used, which includes mask rom devices and new xD cards

Why that option ? We can just extend the existing ids table and be done. No extra magic needed.

Quoted 5 lines

Two reasons.

First of all several xD chips (I belive the Type M) have exactly same IDs like normal nand chips. However they don't report capabilities about pagesize, blocksize, etc.

You mean that crap ?

+       /* xD only */
+       {"xD 512MiB 3,3V",              0xDC, 512, 512, 0x4000, XD_TYPEM},
+       {"xD 1GiB 3,3V",                0xD3, 512, 1024, 0x4000, XD_TYPEM},
+       {"xD 2GiB 3,3V",                0xD5, 512, 2048, 0x4000, XD_TYPEM},

Oh well, that's a perfect example of designed by comittee shit.

They abuse the 2k chips IDs and define crappy sizes just to fit the stupid spec.

Quoted 2 lines

I am confident that these cards have an internal FTL and controller, and just 'emulate' that nand interface.

Either that or the adapter translates the 512B commands to 2K commands. I bet on the latter. AFAIK are xD cards just as stupid as SmartMedia ones, i.e. bare NAND chips in a flat plastic housing with gold contacts.

Quoted 2 lines

Also, my card reports write protect, although, xD cards don't have any 'switch' to make them protected.

Neither have SmartMedia Cards nor bare NAND chips. WP is a pin on the interface which is controlled by the adapter hardware.

Quoted 2 lines

Even if there were readonly ROM xD cards (the odds of this are virtually zero), these won't just expose this in WP bit.

Hmm, I wonder whether that horror has the WP bit inverted.

Thanks,

tglx

#23 lore raw

Re: [PATCH 13/15] MTD: add few workarounds to nand system for SmartMedia/xD chips.

Quoted 13 lines · Thomas Gleixner
Quoted 11 lines · Maxim Levitsky
Quoted 9 lines · Thomas Gleixner
Quoted 3 lines · Maxim Levitsky

* Add an option NAND_SMARTMEDIA that can be set by nand driver If set, it will cause separate ID table to be used, which includes mask rom devices and new xD cards

Why that option ? We can just extend the existing ids table and be done. No extra magic needed.

Quoted 5 lines
Quoted 5 lines

Two reasons.

First of all several xD chips (I belive the Type M) have exactly same IDs like normal nand chips. However they don't report capabilities about pagesize, blocksize, etc.

Sure, I didn't meant the #WP line. Sure it is set by the controller. I mean WP bit in status report.

Best regards,
Maxim Levitsky

#24 lore raw

PATCH v10 14/15 MTD: Add new SmartMedia/xD FTL

In reply to Maxim Levitsky

This implements new readwrite SmartMedia/xd FTL.

mtd driver must have support proper ECC and badblock vertification based on oob parts for 512 bytes nand.

Also mtd driver must define read_oob and write_oob, which are used to read and write both data and oob together.

---
 drivers/mtd/Kconfig  |   21 +
 drivers/mtd/Makefile |    1 +
 drivers/mtd/sm_ftl.c | 1284 ++++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/sm_ftl.h |   94 ++++
 4 files changed, 1400 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/sm_ftl.c
 create mode 100644 drivers/mtd/sm_ftl.h
drivers/mtd/Kconfig +21 -0
index ecf90f5..0105ae0 100644
@@ -304,6 +304,27 @@ config SSFDC
 	  This enables read only access to SmartMedia formatted NAND
 	  flash. You can mount it with FAT file system.
 
+
+config SM_FTL
+	tristate "SmartMedia/xD new translation layer"
+	depends on EXPERIMENTAL && BLOCK
+	select MTD_BLKDEVS
+	help
+	  This enables new and very EXPERMENTAL support for SmartMedia/xD
+	  FTL (Flash tanslation layer)
+	  Write support isn't yet well tested, therefore this code IS likely to
+	  eat your card, so please don't use it together with valuable data.
+	  Use readonly driver (CONFIG_SSFDC) instead.
+
+config SM_FTL_MUSEUM
+	boolean "Additional Support for 1MB and 2MB SmartMedia cards"
+	depends on SM_FTL && MTD_NAND
+	select MTD_NAND_ECC_SMC
+	help
+	  Very old SmartMedia cards need ECC to be caluculated in the FTL
+	  Such cards are very rare, thus enabling this option is mostly useless
+	  Also this support is completely UNTESTED.
+
 config MTD_OOPS
 	tristate "Log panic/oops to an MTD buffer"
 	depends on MTD
drivers/mtd/Makefile +1 -0
index 82d1e4d..d53357b 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_NFTL)		+= nftl.o
 obj-$(CONFIG_INFTL)		+= inftl.o
 obj-$(CONFIG_RFD_FTL)		+= rfd_ftl.o
 obj-$(CONFIG_SSFDC)		+= ssfdc.o
+obj-$(CONFIG_SM_FTL)		+= sm_ftl.o
 obj-$(CONFIG_MTD_OOPS)		+= mtdoops.o
 
 nftl-objs		:= nftlcore.o nftlmount.o
drivers/mtd/sm_ftl.c new file +1284 -0

1,284 lines not on this page · raw message

drivers/mtd/sm_ftl.h new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#25 lore raw

PATCH v10 15/15 MTD: Add nand driver for Ricoh xD/SmartMedia reader

In reply to Maxim Levitsky

This adds a driver for Ricoh R5C852 xD card reader.

This reader is a part of larger mulifunction chip
and found at least in R5C832

Driver is complete, but bewere of the fact that some (probably only type M) xD cards are 'fake' which means that they have an on board CPU and expose emulated nand command set

These cards don't even store the oob area on the flash, but generate it on the fly from something else.

Thus they demand to have proper values written in the oob area, and therefore only useful with SmartMedia FTL.

---
 MAINTAINERS               |    6 +
 drivers/mtd/nand/Kconfig  |   11 +
 drivers/mtd/nand/Makefile |    1 +
 drivers/mtd/nand/r852.c   | 1117 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/r852.h   |  163 +++++++
 include/linux/pci_ids.h   |    2 +
 6 files changed, 1300 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/r852.c
 create mode 100644 drivers/mtd/nand/r852.h
MAINTAINERS +6 -0
index 1b0f053..1723c54 100644
@@ -4577,6 +4577,12 @@ S:	Maintained
 F:	Documentation/rfkill.txt
 F:	net/rfkill/
 
+RICOH SMARTMEDIA/XD DRIVER
+M:	Maxim Levitsky <[email protected]>
+S:	Maintained
+F:	drivers/mtd/nand/r822.c
+F:	drivers/mtd/nand/r822.h
+
 RISCOM8 DRIVER
 S:	Orphan
 F:	Documentation/serial/riscom8.txt
drivers/mtd/nand/Kconfig +11 -0
index 31273c7..4ab2551 100644
@@ -107,6 +107,17 @@ config MTD_NAND_OMAP_PREFETCH_DMA
 config MTD_NAND_IDS
 	tristate
 
+config MTD_NAND_RICOH
+	tristate "Ricoh xD card reader"
+	default n
+	select MTD_SM_COMMON
+	help
+	  Enable support for Ricoh R5C852 xD card reader
+	  You also need to enable ether
+	  NAND SSFDC (SmartMedia) read only translation layer' or new
+	  expermental, readwrite
+	  'SmartMedia/xD new translation layer'
+
 config MTD_NAND_AU1550
 	tristate "Au1550/1200 NAND support"
 	depends on SOC_AU1200 || SOC_AU1550
drivers/mtd/nand/Makefile +1 -0
index e699bef..1d5797d 100644
@@ -42,5 +42,6 @@ obj-$(CONFIG_MTD_NAND_TXX9NDFMC)	+= txx9ndfmc.o
 obj-$(CONFIG_MTD_NAND_NUC900)		+= nuc900_nand.o
 obj-$(CONFIG_MTD_NAND_NOMADIK)		+= nomadik_nand.o
 obj-$(CONFIG_MTD_NAND_BCM_UMI)		+= bcm_umi_nand.o nand_bcm_umi.o
+obj-$(CONFIG_MTD_NAND_RICOH)		+= r852.o
 
 nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/r852.c new file +1117 -0

1,117 lines not on this page · raw message

drivers/mtd/nand/r852.h new file +163 -0

163 lines not on this page · raw message

include/linux/pci_ids.h +2 -0
index cca8a04..cef49f2 100644
@@ -1523,6 +1523,8 @@
 #define PCI_DEVICE_ID_RICOH_R5C822	0x0822
 #define PCI_DEVICE_ID_RICOH_R5C832	0x0832
 #define PCI_DEVICE_ID_RICOH_R5C843	0x0843
+#define PCI_DEVICE_ID_RICOH_R5C852	0x0852
+
 
 #define PCI_VENDOR_ID_DLINK		0x1186
 #define PCI_DEVICE_ID_DLINK_DGE510T	0x4c00
Signature · 1 line
1.6.3.3