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