[ar71xx] add initial profiles
[openwrt.git] / target / linux / generic-2.4 / patches / 008-intel_flashchip_fix.patch
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
4 +++ linux-2.4.35.4/drivers/mtd/chips/cfi_cmdset_0001.c
5 @@ -28,10 +28,18 @@
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>
14
15 +#ifndef container_of
16 +#define container_of(ptr, type, member) ({ \
17 + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
18 + (type *)( (char *)__mptr - offsetof(type,member) );})
19 +#endif
20 +
21 // debugging, turns off buffer write mode #define FORCE_WORD_WRITE
22
23 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
24 @@ -45,6 +53,7 @@ static int cfi_intelext_lock(struct mtd_
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);
29
30 static void cfi_intelext_destroy(struct mtd_info *);
31
32 @@ -288,6 +297,9 @@ static struct mtd_info *cfi_intelext_set
33 map->fldrv = &cfi_intelext_chipdrv;
34 MOD_INC_USE_COUNT;
35 mtd->name = map->name;
36 + mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
37 + register_reboot_notifier(&mtd->reboot_notifier);
38 +
39 return mtd;
40
41 setup_err:
42 @@ -1961,10 +1973,40 @@ static void cfi_intelext_resume(struct m
43 }
44 }
45
46 +
47 +static void cfi_intelext_reset(struct mtd_info *mtd)
48 +{
49 + struct map_info *map = mtd->priv;
50 + struct cfi_private *cfi = map->fldrv_priv;
51 + int i;
52 + struct flchip *chip;
53 +
54 + cfi_intelext_sync(mtd);
55 + for (i=0; i<cfi->numchips; i++) {
56 + chip = &cfi->chips[i];
57 +
58 + spin_lock(chip->mutex);
59 + cfi_write(map, CMD(0xFF), 0);
60 + chip->state = FL_READY;
61 + spin_unlock(chip->mutex);
62 + }
63 +}
64 +
65 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v)
66 +{
67 + struct mtd_info *mtd;
68 +
69 + mtd = container_of(nb, struct mtd_info, reboot_notifier);
70 + cfi_intelext_reset(mtd);
71 + return NOTIFY_DONE;
72 +}
73 +
74 static void cfi_intelext_destroy(struct mtd_info *mtd)
75 {
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);
81 kfree(cfi->cfiq);
82 kfree(cfi);
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
86 +++ linux-2.4.35.4/include/linux/mtd/mtd.h
87 @@ -10,6 +10,7 @@
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>
94
95 @@ -217,6 +218,8 @@ struct mtd_info {
96 int (*suspend) (struct mtd_info *mtd);
97 void (*resume) (struct mtd_info *mtd);
98
99 + struct notifier_block reboot_notifier;
100 +
101 void *priv;
102 };
103
This page took 0.048398 seconds and 5 git commands to generate.