001-fix-mtd-defines.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From: Paul B. Henson <henson@acm.org>
  2. Newer kernel headers renamed mtd mode defines and no longer support
  3. MEMSETOOBSEL. Allow code to work with both older and newer kernel
  4. versions.
  5. Signed-off-by: Paul B. Henson <henson@acm.org>
  6. ---
  7. http://git.buildroot.net/buildroot/plain/package/kobs-ng/kobs-ng-fix-mtd-defines.patch
  8. --- a/src/mtd.c
  9. +++ b/src/mtd.c
  10. @@ -852,8 +852,11 @@ void mtd_close(struct mtd_data *md)
  11. mp = &md->part[i];
  12. if (mp->fd != -1) {
  13. +/* Newer kernels dropped MEMSETOOBSEL */
  14. +#ifdef MEMSETOOBSEL
  15. (void)ioctl(mp->fd, MEMSETOOBSEL,
  16. &mp->old_oobinfo);
  17. +#endif
  18. close(mp->fd);
  19. }
  20. @@ -896,6 +899,8 @@ int mtd_set_ecc_mode(struct mtd_data *md
  21. continue;
  22. }
  23. +/* Newer kernels dropped MEMSETOOBSEL */
  24. +#ifdef MEMSETOOBSEL
  25. if (r == -ENOTTY) {
  26. r = ioctl(mp->fd, MEMSETOOBSEL, &mp->old_oobinfo);
  27. if (r != 0) {
  28. @@ -904,6 +909,7 @@ int mtd_set_ecc_mode(struct mtd_data *md
  29. }
  30. mp->oobinfochanged = 0;
  31. }
  32. +#endif
  33. } else {
  34. r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_RAW);
  35. if (r != 0 && r != -ENOTTY) {
  36. @@ -911,6 +917,8 @@ int mtd_set_ecc_mode(struct mtd_data *md
  37. continue;
  38. }
  39. +/* Newer kernels dropped MEMSETOOBSEL */
  40. +#ifdef MEMSETOOBSEL
  41. if (r == -ENOTTY) {
  42. r = ioctl(mp->fd, MEMSETOOBSEL, &none_oobinfo);
  43. if (r != 0) {
  44. @@ -920,6 +928,7 @@ int mtd_set_ecc_mode(struct mtd_data *md
  45. mp->oobinfochanged = 1;
  46. } else
  47. mp->oobinfochanged = 2;
  48. +#endif
  49. }
  50. mp->ecc = ecc;
  51. --- a/src/mtd.h
  52. +++ b/src/mtd.h
  53. @@ -31,6 +31,14 @@
  54. #include "BootControlBlocks.h"
  55. #include "rom_nand_hamming_code_ecc.h"
  56. +// Newer kernel headers renamed define
  57. +#ifndef MTD_MODE_NORMAL
  58. +#define MTD_MODE_NORMAL MTD_FILE_MODE_NORMAL
  59. +#endif
  60. +#ifndef MTD_MODE_RAW
  61. +#define MTD_MODE_RAW MTD_FILE_MODE_RAW
  62. +#endif
  63. +
  64. //------------------------------------------------------------------------------
  65. // Re-definitions of true and false, because the standard ones aren't good
  66. // enough?