]> Pileus Git - ~andy/linux/blobdiff - drivers/mtd/chips/cfi_probe.c
ps3vram: Fix error path (return -EIO) for short read/write
[~andy/linux] / drivers / mtd / chips / cfi_probe.c
index c418e92e1d92b79286f46a173bd1f93ff3591939..e63e6749429a29c282323ebc7c5d5949ef284616 100644 (file)
@@ -44,17 +44,14 @@ do { \
 
 #define xip_enable(base, map, cfi) \
 do { \
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); \
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); \
+       cfi_qry_mode_off(base, map, cfi);               \
        xip_allowed(base, map); \
 } while (0)
 
 #define xip_disable_qry(base, map, cfi) \
 do { \
        xip_disable(); \
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); \
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); \
-       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL); \
+       cfi_qry_mode_on(base, map, cfi); \
 } while (0)
 
 #else
@@ -70,32 +67,6 @@ do { \
    in: interleave,type,mode
    ret: table index, <0 for error
  */
-static int __xipram qry_present(struct map_info *map, __u32 base,
-                               struct cfi_private *cfi)
-{
-       int osf = cfi->interleave * cfi->device_type;   // scale factor
-       map_word val[3];
-       map_word qry[3];
-
-       qry[0] = cfi_build_cmd('Q', map, cfi);
-       qry[1] = cfi_build_cmd('R', map, cfi);
-       qry[2] = cfi_build_cmd('Y', map, cfi);
-
-       val[0] = map_read(map, base + osf*0x10);
-       val[1] = map_read(map, base + osf*0x11);
-       val[2] = map_read(map, base + osf*0x12);
-
-       if (!map_word_equal(map, qry[0], val[0]))
-               return 0;
-
-       if (!map_word_equal(map, qry[1], val[1]))
-               return 0;
-
-       if (!map_word_equal(map, qry[2], val[2]))
-               return 0;
-
-       return 1;       // "QRY" found
-}
 
 static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
                                   unsigned long *chip_map, struct cfi_private *cfi)
@@ -116,11 +87,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
        }
 
        xip_disable();
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
-
-       if (!qry_present(map,base,cfi)) {
+       if (!cfi_qry_mode_on(base, map, cfi)) {
                xip_enable(base, map, cfi);
                return 0;
        }
@@ -141,14 +108,13 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
                start = i << cfi->chipshift;
                /* This chip should be in read mode if it's one
                   we've already touched. */
-               if (qry_present(map, start, cfi)) {
+               if (cfi_qry_present(map, start, cfi)) {
                        /* Eep. This chip also had the QRY marker.
                         * Is it an alias for the new one? */
-                       cfi_send_gen_cmd(0xF0, 0, start, map, cfi, cfi->device_type, NULL);
-                       cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL);
+                       cfi_qry_mode_off(start, map, cfi);
 
                        /* If the QRY marker goes away, it's an alias */
-                       if (!qry_present(map, start, cfi)) {
+                       if (!cfi_qry_present(map, start, cfi)) {
                                xip_allowed(base, map);
                                printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n",
                                       map->name, base, start);
@@ -158,10 +124,9 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
                         * unfortunate. Stick the new chip in read mode
                         * too and if it's the same, assume it's an alias. */
                        /* FIXME: Use other modes to do a proper check */
-                       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-                       cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL);
+                       cfi_qry_mode_off(base, map, cfi);
 
-                       if (qry_present(map, base, cfi)) {
+                       if (cfi_qry_present(map, base, cfi)) {
                                xip_allowed(base, map);
                                printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n",
                                       map->name, base, start);
@@ -176,8 +141,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
        cfi->numchips++;
 
        /* Put it back into Read Mode */
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_qry_mode_off(base, map, cfi);
        xip_allowed(base, map);
 
        printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n",
@@ -237,9 +201,7 @@ static int __xipram cfi_chip_setup(struct map_info *map,
                          cfi_read_query(map, base + 0xf * ofs_factor);
 
        /* Put it back into Read Mode */
-       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-       /* ... even if it's an Intel chip */
-       cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_qry_mode_off(base, map, cfi);
        xip_allowed(base, map);
 
        /* Do any necessary byteswapping */