diff options
author | Dmitry Pervushin <dpervushin@embeddedalley.com> | 2009-04-29 11:29:38 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-06-02 06:53:35 -0400 |
commit | 0e0ee1cc33de8f0cc603269b354085dee340afa0 (patch) | |
tree | 5dfd658b85eabadfbf0c94bee94d46f8d74b839b /include/linux/mtd/ubi.h | |
parent | b86a2c56e512f46d140a4bcb4e35e8a7d4a99a4b (diff) |
UBI: add notification API
UBI volume notifications are intended to create the API to get clients
notified about volume creation/deletion, renaming and re-sizing. A
client can subscribe to these notifications using 'ubi_volume_register()'
and cancel the subscription using 'ubi_volume_unregister()'. When UBI
volumes change, a blocking notifier is called. Clients also can request
"added" events on all volumes that existed before client subscribed
to the notifications.
If we use notifications instead of calling functions like 'ubi_gluebi_xxx()',
we can make the MTD emulation layer to be more flexible: build it as a
separate module and load/unload it on demand.
[Artem: many cleanups, rework locking, add "updated" event, provide
device/volume info in notifiers]
Signed-off-by: Dmitry Pervushin <dpervushin@embeddedalley.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'include/linux/mtd/ubi.h')
-rw-r--r-- | include/linux/mtd/ubi.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h index 6316fafe5c2a..6913b71d9ab2 100644 --- a/include/linux/mtd/ubi.h +++ b/include/linux/mtd/ubi.h | |||
@@ -132,6 +132,39 @@ struct ubi_device_info { | |||
132 | dev_t cdev; | 132 | dev_t cdev; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | /* | ||
136 | * enum - volume notification types. | ||
137 | * @UBI_VOLUME_ADDED: volume has been added | ||
138 | * @UBI_VOLUME_REMOVED: start volume volume | ||
139 | * @UBI_VOLUME_RESIZED: volume size has been re-sized | ||
140 | * @UBI_VOLUME_RENAMED: volume name has been re-named | ||
141 | * @UBI_VOLUME_UPDATED: volume name has been updated | ||
142 | * | ||
143 | * These constants define which type of event has happened when a volume | ||
144 | * notification function is invoked. | ||
145 | */ | ||
146 | enum { | ||
147 | UBI_VOLUME_ADDED, | ||
148 | UBI_VOLUME_REMOVED, | ||
149 | UBI_VOLUME_RESIZED, | ||
150 | UBI_VOLUME_RENAMED, | ||
151 | UBI_VOLUME_UPDATED, | ||
152 | }; | ||
153 | |||
154 | /* | ||
155 | * struct ubi_notification - UBI notification description structure. | ||
156 | * @di: UBI device description object | ||
157 | * @vi: UBI volume description object | ||
158 | * | ||
159 | * UBI notifiers are called with a pointer to an object of this type. The | ||
160 | * object describes the notification. Namely, it provides a description of the | ||
161 | * UBI device and UBI volume the notification informs about. | ||
162 | */ | ||
163 | struct ubi_notification { | ||
164 | struct ubi_device_info di; | ||
165 | struct ubi_volume_info vi; | ||
166 | }; | ||
167 | |||
135 | /* UBI descriptor given to users when they open UBI volumes */ | 168 | /* UBI descriptor given to users when they open UBI volumes */ |
136 | struct ubi_volume_desc; | 169 | struct ubi_volume_desc; |
137 | 170 | ||
@@ -141,6 +174,10 @@ void ubi_get_volume_info(struct ubi_volume_desc *desc, | |||
141 | struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode); | 174 | struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode); |
142 | struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name, | 175 | struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name, |
143 | int mode); | 176 | int mode); |
177 | int ubi_register_volume_notifier(struct notifier_block *nb, | ||
178 | int ignore_existing); | ||
179 | int ubi_unregister_volume_notifier(struct notifier_block *nb); | ||
180 | |||
144 | void ubi_close_volume(struct ubi_volume_desc *desc); | 181 | void ubi_close_volume(struct ubi_volume_desc *desc); |
145 | int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, | 182 | int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, |
146 | int len, int check); | 183 | int len, int check); |