+ if (shdr.s_magic == SQUASHFS_MAGIC) {
+ uint32_t fs_size = (uint32_t)shdr.bytes_used;
+
+ printk(KERN_INFO "%s: Filesystem type: squashfs, size=%dkB\n",
+ mtd->name, fs_size>>10);
+
+ /* Update rootfs based on the superblock info, and
+ * stretch to end of MTD. rootfs_split will split it */
+ adm8668_parts[PART_ROOTFS].offset = off;
+ adm8668_parts[PART_ROOTFS].size = mtd->size -
+ adm8668_parts[PART_ROOTFS].offset;
+
+ /* kernel ends where rootfs starts
+ * but we'll keep it full-length for upgrades */
+ linux_len = adm8668_parts[PART_LINUX+1].offset -
+ adm8668_parts[PART_LINUX].offset;
+#if 1
+ adm8668_parts[PART_LINUX].size = mtd->size -
+ adm8668_parts[PART_LINUX].offset;
+#else
+ adm8668_parts[PART_LINUX].size = linux_len;
+#endif
+ goto found;
+ }
+ }
+
+ printk(KERN_NOTICE
+ "%s: Couldn't find root filesystem\n",
+ mtd->name);
+ return NR_PARTS;
+
+ found:
+ if (mtd->read(mtd, adm8668_parts[PART_LINUX].offset, sizeof(uhdr), &len, (char *)&uhdr) ||
+ len != sizeof(uhdr))
+ return NR_PARTS;
+
+ /* that's odd. how'd ya boot it then */
+ if (uhdr.ih_magic != IH_MAGIC)
+ return NR_PARTS;
+
+ if (be32_to_cpu(uhdr.ih_size) != (linux_len - sizeof(uhdr))) {
+ unsigned char *block, *data = (unsigned char *)(WINDOW_ADDR | (adm8668_parts[PART_LINUX].offset + sizeof(struct uboot_header)) | 0xA0000000);
+
+ printk(KERN_NOTICE "Updating U-boot image:\n");
+ printk(KERN_NOTICE " old: [size: %8d crc32: 0x%08x]\n",
+ be32_to_cpu(uhdr.ih_size), be32_to_cpu(uhdr.ih_dcrc));
+
+ /* Update the data length & crc32 */
+ uhdr.ih_size = cpu_to_be32(linux_len - sizeof(uhdr));
+ uhdr.ih_dcrc = crc32_le(~0, data, linux_len - sizeof(uhdr)) ^ (~0);
+ uhdr.ih_dcrc = cpu_to_be32(uhdr.ih_dcrc);
+
+ printk(KERN_NOTICE " new: [size: %8d crc32: 0x%08x]\n",
+ be32_to_cpu(uhdr.ih_size), be32_to_cpu(uhdr.ih_dcrc));
+
+ /* update header's crc... */
+ uhdr.ih_hcrc = 0;
+ uhdr.ih_hcrc = crc32_le(~0, (unsigned char *)&uhdr,
+ sizeof(uhdr)) ^ (~0);
+ uhdr.ih_hcrc = cpu_to_be32(uhdr.ih_hcrc);
+
+ /* read first eraseblock from the image */
+ block = kmalloc(mtd->erasesize, GFP_KERNEL);
+ if (mtd->read(mtd, adm8668_parts[PART_LINUX].offset, mtd->erasesize, &len, block) || len != mtd->erasesize) {
+ printk("Error copying first eraseblock\n");
+ return 0;