ar71xx: rb91x-nand: rewrite to use GPIO API
[oweals/openwrt.git] / target / linux / ar71xx / files / drivers / mtd / tplinkpart.c
index 2cbad5ada1b0deeb080260f3423c5be2ba61b44a..cabb96033d6cbdfe14bbe6ba2ad3facda8d39c90 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/magic.h>
@@ -59,8 +60,8 @@ tplink_read_header(struct mtd_info *mtd, size_t offset)
                goto err;
 
        header_len = sizeof(struct tplink_fw_header);
-       ret = mtd->read(mtd, offset, header_len, &retlen,
-                       (unsigned char *) header);
+       ret = mtd_read(mtd, offset, header_len, &retlen,
+                      (unsigned char *) header);
        if (ret)
                goto err_free_header;
 
@@ -84,21 +85,22 @@ err:
        return NULL;
 }
 
-static int tplink_check_squashfs_magic(struct mtd_info *mtd, size_t offset)
+static int tplink_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
 {
        u32 magic;
        size_t retlen;
        int ret;
 
-       ret = mtd->read(mtd, offset, sizeof(magic), &retlen,
-                       (unsigned char *) &magic);
+       ret = mtd_read(mtd, offset, sizeof(magic), &retlen,
+                      (unsigned char *) &magic);
        if (ret)
                return ret;
 
        if (retlen != sizeof(magic))
                return -EIO;
 
-       if (le32_to_cpu(magic) != SQUASHFS_MAGIC)
+       if (le32_to_cpu(magic) != SQUASHFS_MAGIC &&
+           magic != 0x19852003)
                return -EINVAL;
 
        return 0;
@@ -106,7 +108,7 @@ static int tplink_check_squashfs_magic(struct mtd_info *mtd, size_t offset)
 
 static int tplink_parse_partitions(struct mtd_info *master,
                                   struct mtd_partition **pparts,
-                                  unsigned long origin)
+                                  struct mtd_part_parser_data *data)
 {
        struct mtd_partition *parts;
        struct tplink_fw_header *header;
@@ -136,7 +138,7 @@ static int tplink_parse_partitions(struct mtd_info *master,
        squashfs_offset = offset + sizeof(struct tplink_fw_header) +
                          be32_to_cpu(header->kernel_len);
 
-       ret = tplink_check_squashfs_magic(master, squashfs_offset);
+       ret = tplink_check_rootfs_magic(master, squashfs_offset);
        if (ret == 0)
                rootfs_offset = squashfs_offset;
        else