1 Index: linux-2.4.35.4/drivers/mtd/chips/cfi_cmdset_0001.c
2 ===================================================================
3 --- linux-2.4.35.4.orig/drivers/mtd/chips/cfi_cmdset_0001.c 2007-12-15 05:19:42.414838122 +0100
4 +++ linux-2.4.35.4/drivers/mtd/chips/cfi_cmdset_0001.c 2007-12-15 05:19:50.315288342 +0100
6 #include <linux/slab.h>
7 #include <linux/delay.h>
8 #include <linux/interrupt.h>
9 +#include <linux/notifier.h>
10 +#include <linux/reboot.h>
11 #include <linux/mtd/map.h>
12 #include <linux/mtd/cfi.h>
13 #include <linux/mtd/compatmac.h>
16 +#define container_of(ptr, type, member) ({ \
17 + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
18 + (type *)( (char *)__mptr - offsetof(type,member) );})
21 // debugging, turns off buffer write mode #define FORCE_WORD_WRITE
23 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
25 static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len);
26 static int cfi_intelext_suspend (struct mtd_info *);
27 static void cfi_intelext_resume (struct mtd_info *);
28 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v);
30 static void cfi_intelext_destroy(struct mtd_info *);
33 map->fldrv = &cfi_intelext_chipdrv;
35 mtd->name = map->name;
36 + mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
37 + register_reboot_notifier(&mtd->reboot_notifier);
42 @@ -1961,10 +1973,40 @@
47 +static void cfi_intelext_reset(struct mtd_info *mtd)
49 + struct map_info *map = mtd->priv;
50 + struct cfi_private *cfi = map->fldrv_priv;
52 + struct flchip *chip;
54 + cfi_intelext_sync(mtd);
55 + for (i=0; i<cfi->numchips; i++) {
56 + chip = &cfi->chips[i];
58 + spin_lock(chip->mutex);
59 + cfi_write(map, CMD(0xFF), 0);
60 + chip->state = FL_READY;
61 + spin_unlock(chip->mutex);
65 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v)
67 + struct mtd_info *mtd;
69 + mtd = container_of(nb, struct mtd_info, reboot_notifier);
70 + cfi_intelext_reset(mtd);
74 static void cfi_intelext_destroy(struct mtd_info *mtd)
76 struct map_info *map = mtd->priv;
77 struct cfi_private *cfi = map->fldrv_priv;
78 + cfi_intelext_reset(mtd);
79 + unregister_reboot_notifier(&mtd->reboot_notifier);
80 kfree(cfi->cmdset_priv);
83 Index: linux-2.4.35.4/include/linux/mtd/mtd.h
84 ===================================================================
85 --- linux-2.4.35.4.orig/include/linux/mtd/mtd.h 2007-12-15 05:19:42.422838578 +0100
86 +++ linux-2.4.35.4/include/linux/mtd/mtd.h 2007-12-15 05:19:50.315288342 +0100
88 #include <linux/version.h>
89 #include <linux/types.h>
90 #include <linux/mtd/compatmac.h>
91 +#include <linux/notifier.h>
92 #include <linux/module.h>
93 #include <linux/uio.h>
96 int (*suspend) (struct mtd_info *mtd);
97 void (*resume) (struct mtd_info *mtd);
99 + struct notifier_block reboot_notifier;