1
0

401-mtd-physmap-add-lock-unlock.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. --- a/drivers/mtd/maps/physmap.c
  2. +++ b/drivers/mtd/maps/physmap.c
  3. @@ -31,6 +31,66 @@ struct physmap_flash_info {
  4. int vpp_refcnt;
  5. };
  6. +static struct platform_device *physmap_map2pdev(struct map_info *map)
  7. +{
  8. + return (struct platform_device *) map->map_priv_1;
  9. +}
  10. +
  11. +static void physmap_lock(struct map_info *map)
  12. +{
  13. + struct platform_device *pdev;
  14. + struct physmap_flash_data *physmap_data;
  15. +
  16. + pdev = physmap_map2pdev(map);
  17. + physmap_data = pdev->dev.platform_data;
  18. + physmap_data->lock(pdev);
  19. +}
  20. +
  21. +static void physmap_unlock(struct map_info *map)
  22. +{
  23. + struct platform_device *pdev;
  24. + struct physmap_flash_data *physmap_data;
  25. +
  26. + pdev = physmap_map2pdev(map);
  27. + physmap_data = pdev->dev.platform_data;
  28. + physmap_data->unlock(pdev);
  29. +}
  30. +
  31. +static map_word physmap_flash_read_lock(struct map_info *map, unsigned long ofs)
  32. +{
  33. + map_word ret;
  34. +
  35. + physmap_lock(map);
  36. + ret = inline_map_read(map, ofs);
  37. + physmap_unlock(map);
  38. +
  39. + return ret;
  40. +}
  41. +
  42. +static void physmap_flash_write_lock(struct map_info *map, map_word d,
  43. + unsigned long ofs)
  44. +{
  45. + physmap_lock(map);
  46. + inline_map_write(map, d, ofs);
  47. + physmap_unlock(map);
  48. +}
  49. +
  50. +static void physmap_flash_copy_from_lock(struct map_info *map, void *to,
  51. + unsigned long from, ssize_t len)
  52. +{
  53. + physmap_lock(map);
  54. + inline_map_copy_from(map, to, from, len);
  55. + physmap_unlock(map);
  56. +}
  57. +
  58. +static void physmap_flash_copy_to_lock(struct map_info *map, unsigned long to,
  59. + const void *from, ssize_t len)
  60. +{
  61. + physmap_lock(map);
  62. + inline_map_copy_to(map, to, from, len);
  63. + physmap_unlock(map);
  64. +}
  65. +
  66. static int physmap_flash_remove(struct platform_device *dev)
  67. {
  68. struct physmap_flash_info *info;
  69. @@ -153,6 +213,13 @@ static int physmap_flash_probe(struct pl
  70. simple_map_init(&info->map[i]);
  71. + if (physmap_data->lock && physmap_data->unlock) {
  72. + info->map[i].read = physmap_flash_read_lock;
  73. + info->map[i].write = physmap_flash_write_lock;
  74. + info->map[i].copy_from = physmap_flash_copy_from_lock;
  75. + info->map[i].copy_to = physmap_flash_copy_to_lock;
  76. + }
  77. +
  78. probe_type = rom_probe_types;
  79. if (physmap_data->probe_type == NULL) {
  80. for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++)
  81. --- a/include/linux/mtd/physmap.h
  82. +++ b/include/linux/mtd/physmap.h
  83. @@ -25,6 +25,8 @@ struct physmap_flash_data {
  84. unsigned int width;
  85. int (*init)(struct platform_device *);
  86. void (*exit)(struct platform_device *);
  87. + void (*lock)(struct platform_device *);
  88. + void (*unlock)(struct platform_device *);
  89. void (*set_vpp)(struct platform_device *, int);
  90. unsigned int nr_parts;
  91. unsigned int pfow_base;