008-intel_flashchip_fix.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. +#ifndef container_of
  15. +#define container_of(ptr, type, member) ({ \
  16. + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  17. + (type *)( (char *)__mptr - offsetof(type,member) );})
  18. +#endif
  19. +
  20. // debugging, turns off buffer write mode #define FORCE_WORD_WRITE
  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. static void cfi_intelext_destroy(struct mtd_info *);
  28. @@ -288,6 +297,9 @@ static struct mtd_info *cfi_intelext_set
  29. map->fldrv = &cfi_intelext_chipdrv;
  30. MOD_INC_USE_COUNT;
  31. mtd->name = map->name;
  32. + mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
  33. + register_reboot_notifier(&mtd->reboot_notifier);
  34. +
  35. return mtd;
  36. setup_err:
  37. @@ -1961,10 +1973,40 @@ static void cfi_intelext_resume(struct m
  38. }
  39. }
  40. +
  41. +static void cfi_intelext_reset(struct mtd_info *mtd)
  42. +{
  43. + struct map_info *map = mtd->priv;
  44. + struct cfi_private *cfi = map->fldrv_priv;
  45. + int i;
  46. + struct flchip *chip;
  47. +
  48. + cfi_intelext_sync(mtd);
  49. + for (i=0; i<cfi->numchips; i++) {
  50. + chip = &cfi->chips[i];
  51. +
  52. + spin_lock(chip->mutex);
  53. + cfi_write(map, CMD(0xFF), 0);
  54. + chip->state = FL_READY;
  55. + spin_unlock(chip->mutex);
  56. + }
  57. +}
  58. +
  59. +static int cfi_intelext_reboot(struct notifier_block *nb, unsigned long val, void *v)
  60. +{
  61. + struct mtd_info *mtd;
  62. +
  63. + mtd = container_of(nb, struct mtd_info, reboot_notifier);
  64. + cfi_intelext_reset(mtd);
  65. + return NOTIFY_DONE;
  66. +}
  67. +
  68. static void cfi_intelext_destroy(struct mtd_info *mtd)
  69. {
  70. struct map_info *map = mtd->priv;
  71. struct cfi_private *cfi = map->fldrv_priv;
  72. + cfi_intelext_reset(mtd);
  73. + unregister_reboot_notifier(&mtd->reboot_notifier);
  74. kfree(cfi->cmdset_priv);
  75. kfree(cfi->cfiq);
  76. kfree(cfi);
  77. Index: linux-2.4.35.4/include/linux/mtd/mtd.h
  78. ===================================================================
  79. --- linux-2.4.35.4.orig/include/linux/mtd/mtd.h
  80. +++ linux-2.4.35.4/include/linux/mtd/mtd.h
  81. @@ -10,6 +10,7 @@
  82. #include <linux/version.h>
  83. #include <linux/types.h>
  84. #include <linux/mtd/compatmac.h>
  85. +#include <linux/notifier.h>
  86. #include <linux/module.h>
  87. #include <linux/uio.h>
  88. @@ -217,6 +218,8 @@ struct mtd_info {
  89. int (*suspend) (struct mtd_info *mtd);
  90. void (*resume) (struct mtd_info *mtd);
  91. + struct notifier_block reboot_notifier;
  92. +
  93. void *priv;
  94. };