1 diff -urN linux.old/drivers/mtd/chips/cfi_cmdset_0001.c linux.dev/drivers/mtd/chips/cfi_cmdset_0001.c
2 --- linux.old/drivers/mtd/chips/cfi_cmdset_0001.c 2004-11-17 12:54:21.000000000 +0100
3 +++ linux.dev/drivers/mtd/chips/cfi_cmdset_0001.c 2006-03-16 17:25:04.000000000 +0100
5 #include <linux/slab.h>
6 #include <linux/delay.h>
7 #include <linux/interrupt.h>
8 +#include <linux/notifier.h>
9 +#include <linux/reboot.h>
10 #include <linux/mtd/map.h>
11 #include <linux/mtd/cfi.h>
12 #include <linux/mtd/compatmac.h>
15 +#define container_of(ptr, type, member) ({ \
16 + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
17 + (type *)( (char *)__mptr - offsetof(type,member) );})
20 // debugging, turns off buffer write mode #define FORCE_WORD_WRITE
22 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
24 static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len);
25 static int cfi_intelext_suspend (struct mtd_info *);
26 static void cfi_intelext_resume (struct mtd_info *);
27 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v);
29 static void cfi_intelext_destroy(struct mtd_info *);
32 map->fldrv = &cfi_intelext_chipdrv;
34 mtd->name = map->name;
35 + mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
36 + register_reboot_notifier(&mtd->reboot_notifier);
41 @@ -1960,10 +1972,40 @@
46 +static void cfi_intelext_reset(struct mtd_info *mtd)
48 + struct map_info *map = mtd->priv;
49 + struct cfi_private *cfi = map->fldrv_priv;
51 + struct flchip *chip;
53 + cfi_intelext_sync(mtd);
54 + for (i=0; i<cfi->numchips; i++) {
55 + chip = &cfi->chips[i];
57 + spin_lock(chip->mutex);
58 + cfi_write(map, CMD(0xFF), 0);
59 + chip->state = FL_READY;
60 + spin_unlock(chip->mutex);
64 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v)
66 + struct mtd_info *mtd;
68 + mtd = container_of(nb, struct mtd_info, reboot_notifier);
69 + cfi_intelext_reset(mtd);
73 static void cfi_intelext_destroy(struct mtd_info *mtd)
75 struct map_info *map = mtd->priv;
76 struct cfi_private *cfi = map->fldrv_priv;
77 + cfi_intelext_reset(mtd);
78 + unregister_reboot_notifier(&mtd->reboot_notifier);
79 kfree(cfi->cmdset_priv);
82 diff -urN linux.old/include/linux/mtd/mtd.h linux.dev/include/linux/mtd/mtd.h
83 --- linux.old/include/linux/mtd/mtd.h 2003-08-25 13:44:44.000000000 +0200
84 +++ linux.dev/include/linux/mtd/mtd.h 2006-03-16 17:00:10.000000000 +0100
86 #include <linux/version.h>
87 #include <linux/types.h>
88 #include <linux/mtd/compatmac.h>
89 +#include <linux/notifier.h>
90 #include <linux/module.h>
91 #include <linux/uio.h>
94 int (*suspend) (struct mtd_info *mtd);
95 void (*resume) (struct mtd_info *mtd);
97 + struct notifier_block reboot_notifier;