[ramips] use gpio_led package rather than staticly linking it into the kernel
[openwrt.git] / target / linux / generic-2.4 / patches / 008-intel_flashchip_fix.patch
1 --- a/drivers/mtd/chips/cfi_cmdset_0001.c
2 +++ b/drivers/mtd/chips/cfi_cmdset_0001.c
3 @@ -28,10 +28,18 @@
4 #include <linux/slab.h>
5 #include <linux/delay.h>
6 #include <linux/interrupt.h>
7 +#include <linux/notifier.h>
8 +#include <linux/reboot.h>
9 #include <linux/mtd/map.h>
10 #include <linux/mtd/cfi.h>
11 #include <linux/mtd/compatmac.h>
12
13 +#ifndef container_of
14 +#define container_of(ptr, type, member) ({ \
15 + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
16 + (type *)( (char *)__mptr - offsetof(type,member) );})
17 +#endif
18 +
19 // debugging, turns off buffer write mode #define FORCE_WORD_WRITE
20
21 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
22 @@ -45,6 +53,7 @@ static int cfi_intelext_lock(struct mtd_
23 static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len);
24 static int cfi_intelext_suspend (struct mtd_info *);
25 static void cfi_intelext_resume (struct mtd_info *);
26 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v);
27
28 static void cfi_intelext_destroy(struct mtd_info *);
29
30 @@ -288,6 +297,9 @@ static struct mtd_info *cfi_intelext_set
31 map->fldrv = &cfi_intelext_chipdrv;
32 MOD_INC_USE_COUNT;
33 mtd->name = map->name;
34 + mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
35 + register_reboot_notifier(&mtd->reboot_notifier);
36 +
37 return mtd;
38
39 setup_err:
40 @@ -1961,10 +1973,40 @@ static void cfi_intelext_resume(struct m
41 }
42 }
43
44 +
45 +static void cfi_intelext_reset(struct mtd_info *mtd)
46 +{
47 + struct map_info *map = mtd->priv;
48 + struct cfi_private *cfi = map->fldrv_priv;
49 + int i;
50 + struct flchip *chip;
51 +
52 + cfi_intelext_sync(mtd);
53 + for (i=0; i<cfi->numchips; i++) {
54 + chip = &cfi->chips[i];
55 +
56 + spin_lock(chip->mutex);
57 + cfi_write(map, CMD(0xFF), 0);
58 + chip->state = FL_READY;
59 + spin_unlock(chip->mutex);
60 + }
61 +}
62 +
63 +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v)
64 +{
65 + struct mtd_info *mtd;
66 +
67 + mtd = container_of(nb, struct mtd_info, reboot_notifier);
68 + cfi_intelext_reset(mtd);
69 + return NOTIFY_DONE;
70 +}
71 +
72 static void cfi_intelext_destroy(struct mtd_info *mtd)
73 {
74 struct map_info *map = mtd->priv;
75 struct cfi_private *cfi = map->fldrv_priv;
76 + cfi_intelext_reset(mtd);
77 + unregister_reboot_notifier(&mtd->reboot_notifier);
78 kfree(cfi->cmdset_priv);
79 kfree(cfi->cfiq);
80 kfree(cfi);
81 --- a/include/linux/mtd/mtd.h
82 +++ b/include/linux/mtd/mtd.h
83 @@ -10,6 +10,7 @@
84 #include <linux/version.h>
85 #include <linux/types.h>
86 #include <linux/mtd/compatmac.h>
87 +#include <linux/notifier.h>
88 #include <linux/module.h>
89 #include <linux/uio.h>
90
91 @@ -217,6 +218,8 @@ struct mtd_info {
92 int (*suspend) (struct mtd_info *mtd);
93 void (*resume) (struct mtd_info *mtd);
94
95 + struct notifier_block reboot_notifier;
96 +
97 void *priv;
98 };
99
This page took 0.045027 seconds and 5 git commands to generate.