Merge tag 'r8169-20060920-00' of git://electric-eye.fr.zoreil.com/home/romieu/linux...
[sfrench/cifs-2.6.git] / drivers / mtd / mtdcore.c
index 9905870f56e5e0c6ced0dcb53c5f0d6f8128ee47..c4d26de74349e55f9ae32269ff780b0dde50e767 100644 (file)
@@ -6,7 +6,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -47,6 +46,7 @@ int add_mtd_device(struct mtd_info *mtd)
 {
        int i;
 
+       BUG_ON(mtd->writesize == 0);
        mutex_lock(&mtd_table_mutex);
 
        for (i=0; i < MAX_MTD_DEVICES; i++)
@@ -57,6 +57,16 @@ int add_mtd_device(struct mtd_info *mtd)
                        mtd->index = i;
                        mtd->usecount = 0;
 
+                       /* Some chips always power up locked. Unlock them now */
+                       if ((mtd->flags & MTD_WRITEABLE)
+                           && (mtd->flags & MTD_STUPID_LOCK) && mtd->unlock) {
+                               if (mtd->unlock(mtd, 0, mtd->size))
+                                       printk(KERN_WARNING
+                                              "%s: unlock failed, "
+                                              "writes may not work\n",
+                                              mtd->name);
+                       }
+
                        DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
                        /* No need to get a refcount on the module containing
                           the notifier, since we hold the mtd_table_mutex */
@@ -254,37 +264,6 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
        return ret;
 }
 
-
-/* default_mtd_readv - default mtd readv method for MTD devices that dont
- *                    implement their own
- */
-
-int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs,
-                     unsigned long count, loff_t from, size_t *retlen)
-{
-       unsigned long i;
-       size_t totlen = 0, thislen;
-       int ret = 0;
-
-       if(!mtd->read) {
-               ret = -EIO;
-       } else {
-               for (i=0; i<count; i++) {
-                       if (!vecs[i].iov_len)
-                               continue;
-                       ret = mtd->read(mtd, from, vecs[i].iov_len, &thislen, vecs[i].iov_base);
-                       totlen += thislen;
-                       if (ret || thislen != vecs[i].iov_len)
-                               break;
-                       from += vecs[i].iov_len;
-               }
-       }
-       if (retlen)
-               *retlen = totlen;
-       return ret;
-}
-
-
 EXPORT_SYMBOL(add_mtd_device);
 EXPORT_SYMBOL(del_mtd_device);
 EXPORT_SYMBOL(get_mtd_device);
@@ -292,7 +271,6 @@ EXPORT_SYMBOL(put_mtd_device);
 EXPORT_SYMBOL(register_mtd_user);
 EXPORT_SYMBOL(unregister_mtd_user);
 EXPORT_SYMBOL(default_mtd_writev);
-EXPORT_SYMBOL(default_mtd_readv);
 
 #ifdef CONFIG_PROC_FS