V4L/DVB: hdpvr: fix disconnect sequence
[safe/jmp/linux-2.6] / drivers / mtd / inftlmount.c
index b4cda7d..32e82ae 100644 (file)
@@ -8,8 +8,6 @@
  * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
  * Copyright (C) 2000 Netgem S.A.
  *
- * $Id: inftlmount.c,v 1.18 2005/11/07 11:14:20 gleixner Exp $
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-#include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nftl.h>
 #include <linux/mtd/inftl.h>
 #include <linux/mtd/compatmac.h>
 
-char inftlmountrev[]="$Revision: 1.18 $";
-
 /*
  * find_boot_record: Find the INFTL Media Header and its Spare copy which
  *     contains the various device information of the INFTL partition and
@@ -69,7 +62,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
         * otherwise.
         */
        inftl->EraseSize = inftl->mbd.mtd->erasesize;
-        inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize;
+        inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
 
        inftl->MediaUnit = BLOCK_NIL;
 
@@ -107,9 +100,9 @@ static int find_boot_record(struct INFTLrecord *inftl)
                }
 
                /* To be safer with BIOS, also use erase mark as discriminant */
-               if ((ret = mtd->read_oob(mtd, block * inftl->EraseSize +
-                                        SECTORSIZE + 8, 8, &retlen,
-                                        (char *)&h1) < 0)) {
+               if ((ret = inftl_read_oob(mtd, block * inftl->EraseSize +
+                                         SECTORSIZE + 8, 8, &retlen,
+                                         (char *)&h1) < 0)) {
                        printk(KERN_WARNING "INFTL: ANAND header found at "
                                "0x%x in mtd%d, but OOB data read failed "
                                "(err %d)\n", block * inftl->EraseSize,
@@ -193,7 +186,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
                                mh->BlockMultiplierBits);
                        inftl->EraseSize = inftl->mbd.mtd->erasesize <<
                                mh->BlockMultiplierBits;
-                       inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize;
+                       inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
                        block >>= mh->BlockMultiplierBits;
                }
 
@@ -363,8 +356,8 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
                        return -1;
 
                if (check_oob) {
-                       if(mtd->read_oob(mtd, address, mtd->oobsize,
-                                        &retlen, &buf[SECTORSIZE]) < 0)
+                       if(inftl_read_oob(mtd, address, mtd->oobsize,
+                                         &retlen, &buf[SECTORSIZE]) < 0)
                                return -1;
                        if (memcmpb(buf + SECTORSIZE, 0xff, mtd->oobsize) != 0)
                                return -1;
@@ -433,7 +426,7 @@ int INFTL_formatblock(struct INFTLrecord *inftl, int block)
        uci.Reserved[2] = 0;
        uci.Reserved[3] = 0;
        instr->addr = block * inftl->EraseSize + SECTORSIZE * 2;
-       if (mtd->write_oob(mtd, instr->addr + 8, 8, &retlen, (char *)&uci) < 0)
+       if (inftl_write_oob(mtd, instr->addr + 8, 8, &retlen, (char *)&uci) < 0)
                goto fail;
        return 0;
 fail:
@@ -577,14 +570,13 @@ int INFTL_mount(struct INFTLrecord *s)
        logical_block = block = BLOCK_NIL;
 
        /* Temporary buffer to store ANAC numbers. */
-       ANACtable = kmalloc(s->nb_blocks * sizeof(u8), GFP_KERNEL);
+       ANACtable = kcalloc(s->nb_blocks, sizeof(u8), GFP_KERNEL);
        if (!ANACtable) {
                printk(KERN_WARNING "INFTL: allocation of ANACtable "
                                "failed (%zd bytes)\n",
                                s->nb_blocks * sizeof(u8));
                return -ENOMEM;
        }
-       memset(ANACtable, 0, s->nb_blocks);
 
        /*
         * First pass is to explore each physical unit, and construct the
@@ -611,11 +603,11 @@ int INFTL_mount(struct INFTLrecord *s)
                                break;
                        }
 
-                       if (mtd->read_oob(mtd, block * s->EraseSize + 8,
-                                         8, &retlen, (char *)&h0) < 0 ||
-                           mtd->read_oob(mtd, block * s->EraseSize +
-                                         2 * SECTORSIZE + 8, 8, &retlen,
-                                         (char *)&h1) < 0) {
+                       if (inftl_read_oob(mtd, block * s->EraseSize + 8,
+                                          8, &retlen, (char *)&h0) < 0 ||
+                           inftl_read_oob(mtd, block * s->EraseSize +
+                                          2 * SECTORSIZE + 8, 8, &retlen,
+                                          (char *)&h1) < 0) {
                                /* Should never happen? */
                                do_format_chain++;
                                break;