819-v6.6-0017-nvmem-core-Notify-when-a-new-layout-is-registered.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 0991afbe4b1805e7f0113ef10d7c5f0698a739e4 Mon Sep 17 00:00:00 2001
  2. From: Miquel Raynal <[email protected]>
  3. Date: Tue, 8 Aug 2023 08:29:29 +0200
  4. Subject: [PATCH] nvmem: core: Notify when a new layout is registered
  5. Tell listeners a new layout was introduced and is now available.
  6. Signed-off-by: Miquel Raynal <[email protected]>
  7. Signed-off-by: Srinivas Kandagatla <[email protected]>
  8. ---
  9. drivers/nvmem/core.c | 4 ++++
  10. include/linux/nvmem-consumer.h | 2 ++
  11. 2 files changed, 6 insertions(+)
  12. --- a/drivers/nvmem/core.c
  13. +++ b/drivers/nvmem/core.c
  14. @@ -772,12 +772,16 @@ int __nvmem_layout_register(struct nvmem
  15. list_add(&layout->node, &nvmem_layouts);
  16. spin_unlock(&nvmem_layout_lock);
  17. + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_ADD, layout);
  18. +
  19. return 0;
  20. }
  21. EXPORT_SYMBOL_GPL(__nvmem_layout_register);
  22. void nvmem_layout_unregister(struct nvmem_layout *layout)
  23. {
  24. + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_REMOVE, layout);
  25. +
  26. spin_lock(&nvmem_layout_lock);
  27. list_del(&layout->node);
  28. spin_unlock(&nvmem_layout_lock);
  29. --- a/include/linux/nvmem-consumer.h
  30. +++ b/include/linux/nvmem-consumer.h
  31. @@ -43,6 +43,8 @@ enum {
  32. NVMEM_REMOVE,
  33. NVMEM_CELL_ADD,
  34. NVMEM_CELL_REMOVE,
  35. + NVMEM_LAYOUT_ADD,
  36. + NVMEM_LAYOUT_REMOVE,
  37. };
  38. #if IS_ENABLED(CONFIG_NVMEM)