2009-05-15 13:36:04 +03:00
|
|
|
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
|
|
|
|
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
|
2006-03-16 18:59:58 +02:00
|
|
|
@@ -28,10 +28,18 @@
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
+#include <linux/notifier.h>
|
|
|
|
+#include <linux/reboot.h>
|
|
|
|
#include <linux/mtd/map.h>
|
|
|
|
#include <linux/mtd/cfi.h>
|
|
|
|
#include <linux/mtd/compatmac.h>
|
|
|
|
|
|
|
|
+#ifndef container_of
|
|
|
|
+#define container_of(ptr, type, member) ({ \
|
|
|
|
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
|
|
+ (type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
// debugging, turns off buffer write mode #define FORCE_WORD_WRITE
|
|
|
|
|
|
|
|
static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
|
2008-05-19 16:44:11 +03:00
|
|
|
@@ -45,6 +53,7 @@ static int cfi_intelext_lock(struct mtd_
|
2006-03-16 18:59:58 +02:00
|
|
|
static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len);
|
|
|
|
static int cfi_intelext_suspend (struct mtd_info *);
|
|
|
|
static void cfi_intelext_resume (struct mtd_info *);
|
|
|
|
+static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v);
|
|
|
|
|
|
|
|
static void cfi_intelext_destroy(struct mtd_info *);
|
|
|
|
|
2008-05-19 16:44:11 +03:00
|
|
|
@@ -288,6 +297,9 @@ static struct mtd_info *cfi_intelext_set
|
2006-03-16 18:59:58 +02:00
|
|
|
map->fldrv = &cfi_intelext_chipdrv;
|
|
|
|
MOD_INC_USE_COUNT;
|
|
|
|
mtd->name = map->name;
|
|
|
|
+ mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
|
|
|
|
+ register_reboot_notifier(&mtd->reboot_notifier);
|
|
|
|
+
|
|
|
|
return mtd;
|
|
|
|
|
|
|
|
setup_err:
|
2008-05-19 16:44:11 +03:00
|
|
|
@@ -1961,10 +1973,40 @@ static void cfi_intelext_resume(struct m
|
2006-03-16 18:59:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+static void cfi_intelext_reset(struct mtd_info *mtd)
|
|
|
|
+{
|
|
|
|
+ struct map_info *map = mtd->priv;
|
|
|
|
+ struct cfi_private *cfi = map->fldrv_priv;
|
|
|
|
+ int i;
|
|
|
|
+ struct flchip *chip;
|
|
|
|
+
|
|
|
|
+ cfi_intelext_sync(mtd);
|
|
|
|
+ for (i=0; i<cfi->numchips; i++) {
|
|
|
|
+ chip = &cfi->chips[i];
|
|
|
|
+
|
|
|
|
+ spin_lock(chip->mutex);
|
|
|
|
+ cfi_write(map, CMD(0xFF), 0);
|
|
|
|
+ chip->state = FL_READY;
|
|
|
|
+ spin_unlock(chip->mutex);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v)
|
|
|
|
+{
|
|
|
|
+ struct mtd_info *mtd;
|
|
|
|
+
|
|
|
|
+ mtd = container_of(nb, struct mtd_info, reboot_notifier);
|
|
|
|
+ cfi_intelext_reset(mtd);
|
|
|
|
+ return NOTIFY_DONE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void cfi_intelext_destroy(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
struct map_info *map = mtd->priv;
|
|
|
|
struct cfi_private *cfi = map->fldrv_priv;
|
|
|
|
+ cfi_intelext_reset(mtd);
|
|
|
|
+ unregister_reboot_notifier(&mtd->reboot_notifier);
|
|
|
|
kfree(cfi->cmdset_priv);
|
|
|
|
kfree(cfi->cfiq);
|
|
|
|
kfree(cfi);
|
2009-05-15 13:36:04 +03:00
|
|
|
--- a/include/linux/mtd/mtd.h
|
|
|
|
+++ b/include/linux/mtd/mtd.h
|
2006-03-16 18:59:58 +02:00
|
|
|
@@ -10,6 +10,7 @@
|
|
|
|
#include <linux/version.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/mtd/compatmac.h>
|
|
|
|
+#include <linux/notifier.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/uio.h>
|
|
|
|
|
2008-05-19 16:44:11 +03:00
|
|
|
@@ -217,6 +218,8 @@ struct mtd_info {
|
2006-03-16 18:59:58 +02:00
|
|
|
int (*suspend) (struct mtd_info *mtd);
|
|
|
|
void (*resume) (struct mtd_info *mtd);
|
|
|
|
|
|
|
|
+ struct notifier_block reboot_notifier;
|
|
|
|
+
|
|
|
|
void *priv;
|
|
|
|
};
|
|
|
|
|