1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) International Business Machines Corp., 2006
5 * Author: Artem Bityutskiy (Битюцкий Артём)
8 /* This file mostly implements UBI kernel API functions */
10 #include <linux/module.h>
11 #include <linux/err.h>
12 #include <linux/slab.h>
13 #include <linux/namei.h>
15 #include <asm/div64.h>
19 * ubi_do_get_device_info - get information about UBI device.
20 * @ubi: UBI device description object
21 * @di: the information is stored here
23 * This function is the same as 'ubi_get_device_info()', but it assumes the UBI
24 * device is locked and cannot disappear.
26 void ubi_do_get_device_info(struct ubi_device *ubi, struct ubi_device_info *di)
28 di->ubi_num = ubi->ubi_num;
29 di->leb_size = ubi->leb_size;
30 di->leb_start = ubi->leb_start;
31 di->min_io_size = ubi->min_io_size;
32 di->max_write_size = ubi->max_write_size;
33 di->ro_mode = ubi->ro_mode;
34 di->cdev = ubi->cdev.dev;
36 EXPORT_SYMBOL_GPL(ubi_do_get_device_info);
39 * ubi_get_device_info - get information about UBI device.
40 * @ubi_num: UBI device number
41 * @di: the information is stored here
43 * This function returns %0 in case of success, %-EINVAL if the UBI device
44 * number is invalid, and %-ENODEV if there is no such UBI device.
46 int ubi_get_device_info(int ubi_num, struct ubi_device_info *di)
48 struct ubi_device *ubi;
50 if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES)
52 ubi = ubi_get_device(ubi_num);
55 ubi_do_get_device_info(ubi, di);
59 EXPORT_SYMBOL_GPL(ubi_get_device_info);
62 * ubi_do_get_volume_info - get information about UBI volume.
63 * @ubi: UBI device description object
64 * @vol: volume description object
65 * @vi: the information is stored here
67 void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol,
68 struct ubi_volume_info *vi)
70 vi->vol_id = vol->vol_id;
71 vi->ubi_num = ubi->ubi_num;
72 vi->size = vol->reserved_pebs;
73 vi->used_bytes = vol->used_bytes;
74 vi->vol_type = vol->vol_type;
75 vi->corrupted = vol->corrupted;
76 vi->upd_marker = vol->upd_marker;
77 vi->alignment = vol->alignment;
78 vi->usable_leb_size = vol->usable_leb_size;
79 vi->name_len = vol->name_len;
81 vi->cdev = vol->cdev.dev;
86 * ubi_get_volume_info - get information about UBI volume.
87 * @desc: volume descriptor
88 * @vi: the information is stored here
90 void ubi_get_volume_info(struct ubi_volume_desc *desc,
91 struct ubi_volume_info *vi)
93 ubi_do_get_volume_info(desc->vol->ubi, desc->vol, vi);
95 EXPORT_SYMBOL_GPL(ubi_get_volume_info);
98 * ubi_open_volume - open UBI volume.
99 * @ubi_num: UBI device number
103 * The @mode parameter specifies if the volume should be opened in read-only
104 * mode, read-write mode, or exclusive mode. The exclusive mode guarantees that
105 * nobody else will be able to open this volume. UBI allows to have many volume
106 * readers and one writer at a time.
108 * If a static volume is being opened for the first time since boot, it will be
109 * checked by this function, which means it will be fully read and the CRC
110 * checksum of each logical eraseblock will be checked.
112 * This function returns volume descriptor in case of success and a negative
113 * error code in case of failure.
115 struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
118 struct ubi_volume_desc *desc;
119 struct ubi_device *ubi;
120 struct ubi_volume *vol;
122 dbg_gen("open device %d, volume %d, mode %d", ubi_num, vol_id, mode);
124 if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES)
125 return ERR_PTR(-EINVAL);
127 if (mode != UBI_READONLY && mode != UBI_READWRITE &&
128 mode != UBI_EXCLUSIVE && mode != UBI_METAONLY)
129 return ERR_PTR(-EINVAL);
132 * First of all, we have to get the UBI device to prevent its removal.
134 ubi = ubi_get_device(ubi_num);
136 return ERR_PTR(-ENODEV);
138 if (vol_id < 0 || vol_id >= ubi->vtbl_slots) {
143 desc = kmalloc(sizeof(struct ubi_volume_desc), GFP_KERNEL);
150 if (!try_module_get(THIS_MODULE))
153 spin_lock(&ubi->volumes_lock);
154 vol = ubi->volumes[vol_id];
167 if (vol->exclusive || vol->writers > 0)
173 if (vol->exclusive || vol->writers || vol->readers ||
180 if (vol->metaonly || vol->exclusive)
185 get_device(&vol->dev);
187 spin_unlock(&ubi->volumes_lock);
192 mutex_lock(&ubi->ckvol_mutex);
193 if (!vol->checked && !vol->skip_check) {
194 /* This is the first open - check the volume */
195 err = ubi_check_volume(ubi, vol_id);
197 mutex_unlock(&ubi->ckvol_mutex);
198 ubi_close_volume(desc);
202 ubi_warn(ubi, "volume %d on UBI device %d is corrupted",
203 vol_id, ubi->ubi_num);
208 mutex_unlock(&ubi->ckvol_mutex);
213 spin_unlock(&ubi->volumes_lock);
214 module_put(THIS_MODULE);
218 ubi_err(ubi, "cannot open device %d, volume %d, error %d",
219 ubi_num, vol_id, err);
223 EXPORT_SYMBOL_GPL(ubi_open_volume);
226 * ubi_open_volume_nm - open UBI volume by name.
227 * @ubi_num: UBI device number
231 * This function is similar to 'ubi_open_volume()', but opens a volume by name.
233 struct ubi_volume_desc *ubi_open_volume_nm(int ubi_num, const char *name,
236 int i, vol_id = -1, len;
237 struct ubi_device *ubi;
238 struct ubi_volume_desc *ret;
240 dbg_gen("open device %d, volume %s, mode %d", ubi_num, name, mode);
243 return ERR_PTR(-EINVAL);
245 len = strnlen(name, UBI_VOL_NAME_MAX + 1);
246 if (len > UBI_VOL_NAME_MAX)
247 return ERR_PTR(-EINVAL);
249 if (ubi_num < 0 || ubi_num >= UBI_MAX_DEVICES)
250 return ERR_PTR(-EINVAL);
252 ubi = ubi_get_device(ubi_num);
254 return ERR_PTR(-ENODEV);
256 spin_lock(&ubi->volumes_lock);
257 /* Walk all volumes of this UBI device */
258 for (i = 0; i < ubi->vtbl_slots; i++) {
259 struct ubi_volume *vol = ubi->volumes[i];
261 if (vol && len == vol->name_len && !strcmp(name, vol->name)) {
266 spin_unlock(&ubi->volumes_lock);
269 ret = ubi_open_volume(ubi_num, vol_id, mode);
271 ret = ERR_PTR(-ENODEV);
274 * We should put the UBI device even in case of success, because
275 * 'ubi_open_volume()' took a reference as well.
280 EXPORT_SYMBOL_GPL(ubi_open_volume_nm);
283 * ubi_open_volume_path - open UBI volume by its character device node path.
284 * @pathname: volume character device node path
287 * This function is similar to 'ubi_open_volume()', but opens a volume the path
288 * to its character device node.
290 struct ubi_volume_desc *ubi_open_volume_path(const char *pathname, int mode)
292 int error, ubi_num, vol_id;
296 dbg_gen("open volume %s, mode %d", pathname, mode);
298 if (!pathname || !*pathname)
299 return ERR_PTR(-EINVAL);
301 error = kern_path(pathname, LOOKUP_FOLLOW, &path);
303 return ERR_PTR(error);
305 error = vfs_getattr(&path, &stat, STATX_TYPE, AT_STATX_SYNC_AS_STAT);
308 return ERR_PTR(error);
310 if (!S_ISCHR(stat.mode))
311 return ERR_PTR(-EINVAL);
313 ubi_num = ubi_major2num(MAJOR(stat.rdev));
314 vol_id = MINOR(stat.rdev) - 1;
316 if (vol_id >= 0 && ubi_num >= 0)
317 return ubi_open_volume(ubi_num, vol_id, mode);
318 return ERR_PTR(-ENODEV);
320 EXPORT_SYMBOL_GPL(ubi_open_volume_path);
323 * ubi_close_volume - close UBI volume.
324 * @desc: volume descriptor
326 void ubi_close_volume(struct ubi_volume_desc *desc)
328 struct ubi_volume *vol = desc->vol;
329 struct ubi_device *ubi = vol->ubi;
331 dbg_gen("close device %d, volume %d, mode %d",
332 ubi->ubi_num, vol->vol_id, desc->mode);
334 spin_lock(&ubi->volumes_lock);
335 switch (desc->mode) {
350 spin_unlock(&ubi->volumes_lock);
353 put_device(&vol->dev);
355 module_put(THIS_MODULE);
357 EXPORT_SYMBOL_GPL(ubi_close_volume);
360 * leb_read_sanity_check - does sanity checks on read requests.
361 * @desc: volume descriptor
362 * @lnum: logical eraseblock number to read from
363 * @offset: offset within the logical eraseblock to read from
364 * @len: how many bytes to read
366 * This function is used by ubi_leb_read() and ubi_leb_read_sg()
367 * to perform sanity checks.
369 static int leb_read_sanity_check(struct ubi_volume_desc *desc, int lnum,
372 struct ubi_volume *vol = desc->vol;
373 struct ubi_device *ubi = vol->ubi;
374 int vol_id = vol->vol_id;
376 if (vol_id < 0 || vol_id >= ubi->vtbl_slots || lnum < 0 ||
377 lnum >= vol->used_ebs || offset < 0 || len < 0 ||
378 offset + len > vol->usable_leb_size)
381 if (vol->vol_type == UBI_STATIC_VOLUME) {
382 if (vol->used_ebs == 0)
383 /* Empty static UBI volume */
385 if (lnum == vol->used_ebs - 1 &&
386 offset + len > vol->last_eb_bytes)
397 * ubi_leb_read - read data.
398 * @desc: volume descriptor
399 * @lnum: logical eraseblock number to read from
400 * @buf: buffer where to store the read data
401 * @offset: offset within the logical eraseblock to read from
402 * @len: how many bytes to read
403 * @check: whether UBI has to check the read data's CRC or not.
405 * This function reads data from offset @offset of logical eraseblock @lnum and
406 * stores the data at @buf. When reading from static volumes, @check specifies
407 * whether the data has to be checked or not. If yes, the whole logical
408 * eraseblock will be read and its CRC checksum will be checked (i.e., the CRC
409 * checksum is per-eraseblock). So checking may substantially slow down the
410 * read speed. The @check argument is ignored for dynamic volumes.
412 * In case of success, this function returns zero. In case of failure, this
413 * function returns a negative error code.
415 * %-EBADMSG error code is returned:
416 * o for both static and dynamic volumes if MTD driver has detected a data
417 * integrity problem (unrecoverable ECC checksum mismatch in case of NAND);
418 * o for static volumes in case of data CRC mismatch.
420 * If the volume is damaged because of an interrupted update this function just
421 * returns immediately with %-EBADF error code.
423 int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
426 struct ubi_volume *vol = desc->vol;
427 struct ubi_device *ubi = vol->ubi;
428 int err, vol_id = vol->vol_id;
430 dbg_gen("read %d bytes from LEB %d:%d:%d", len, vol_id, lnum, offset);
432 err = leb_read_sanity_check(desc, lnum, offset, len);
439 err = ubi_eba_read_leb(ubi, vol, lnum, buf, offset, len, check);
440 if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) {
441 ubi_warn(ubi, "mark volume %d as corrupted", vol_id);
447 EXPORT_SYMBOL_GPL(ubi_leb_read);
451 * ubi_leb_read_sg - read data into a scatter gather list.
452 * @desc: volume descriptor
453 * @lnum: logical eraseblock number to read from
454 * @sgl: UBI scatter gather list to store the read data
455 * @offset: offset within the logical eraseblock to read from
456 * @len: how many bytes to read
457 * @check: whether UBI has to check the read data's CRC or not.
459 * This function works exactly like ubi_leb_read_sg(). But instead of
460 * storing the read data into a buffer it writes to an UBI scatter gather
463 int ubi_leb_read_sg(struct ubi_volume_desc *desc, int lnum, struct ubi_sgl *sgl,
464 int offset, int len, int check)
466 struct ubi_volume *vol = desc->vol;
467 struct ubi_device *ubi = vol->ubi;
468 int err, vol_id = vol->vol_id;
470 dbg_gen("read %d bytes from LEB %d:%d:%d", len, vol_id, lnum, offset);
472 err = leb_read_sanity_check(desc, lnum, offset, len);
479 err = ubi_eba_read_leb_sg(ubi, vol, sgl, lnum, offset, len, check);
480 if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) {
481 ubi_warn(ubi, "mark volume %d as corrupted", vol_id);
487 EXPORT_SYMBOL_GPL(ubi_leb_read_sg);
490 * ubi_leb_write - write data.
491 * @desc: volume descriptor
492 * @lnum: logical eraseblock number to write to
493 * @buf: data to write
494 * @offset: offset within the logical eraseblock where to write
495 * @len: how many bytes to write
497 * This function writes @len bytes of data from @buf to offset @offset of
498 * logical eraseblock @lnum.
500 * This function takes care of physical eraseblock write failures. If write to
501 * the physical eraseblock write operation fails, the logical eraseblock is
502 * re-mapped to another physical eraseblock, the data is recovered, and the
503 * write finishes. UBI has a pool of reserved physical eraseblocks for this.
505 * If all the data were successfully written, zero is returned. If an error
506 * occurred and UBI has not been able to recover from it, this function returns
507 * a negative error code. Note, in case of an error, it is possible that
508 * something was still written to the flash media, but that may be some
511 * If the volume is damaged because of an interrupted update this function just
512 * returns immediately with %-EBADF code.
514 int ubi_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
517 struct ubi_volume *vol = desc->vol;
518 struct ubi_device *ubi = vol->ubi;
519 int vol_id = vol->vol_id;
521 dbg_gen("write %d bytes to LEB %d:%d:%d", len, vol_id, lnum, offset);
523 if (vol_id < 0 || vol_id >= ubi->vtbl_slots)
526 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
529 if (!ubi_leb_valid(vol, lnum) || offset < 0 || len < 0 ||
530 offset + len > vol->usable_leb_size ||
531 offset & (ubi->min_io_size - 1) || len & (ubi->min_io_size - 1))
540 return ubi_eba_write_leb(ubi, vol, lnum, buf, offset, len);
542 EXPORT_SYMBOL_GPL(ubi_leb_write);
545 * ubi_leb_change - change logical eraseblock atomically.
546 * @desc: volume descriptor
547 * @lnum: logical eraseblock number to change
548 * @buf: data to write
549 * @len: how many bytes to write
551 * This function changes the contents of a logical eraseblock atomically. @buf
552 * has to contain new logical eraseblock data, and @len - the length of the
553 * data, which has to be aligned. The length may be shorter than the logical
554 * eraseblock size, ant the logical eraseblock may be appended to more times
555 * later on. This function guarantees that in case of an unclean reboot the old
556 * contents is preserved. Returns zero in case of success and a negative error
557 * code in case of failure.
559 int ubi_leb_change(struct ubi_volume_desc *desc, int lnum, const void *buf,
562 struct ubi_volume *vol = desc->vol;
563 struct ubi_device *ubi = vol->ubi;
564 int vol_id = vol->vol_id;
566 dbg_gen("atomically write %d bytes to LEB %d:%d", len, vol_id, lnum);
568 if (vol_id < 0 || vol_id >= ubi->vtbl_slots)
571 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
574 if (!ubi_leb_valid(vol, lnum) || len < 0 ||
575 len > vol->usable_leb_size || len & (ubi->min_io_size - 1))
584 return ubi_eba_atomic_leb_change(ubi, vol, lnum, buf, len);
586 EXPORT_SYMBOL_GPL(ubi_leb_change);
589 * ubi_leb_erase - erase logical eraseblock.
590 * @desc: volume descriptor
591 * @lnum: logical eraseblock number
593 * This function un-maps logical eraseblock @lnum and synchronously erases the
594 * correspondent physical eraseblock. Returns zero in case of success and a
595 * negative error code in case of failure.
597 * If the volume is damaged because of an interrupted update this function just
598 * returns immediately with %-EBADF code.
600 int ubi_leb_erase(struct ubi_volume_desc *desc, int lnum)
602 struct ubi_volume *vol = desc->vol;
603 struct ubi_device *ubi = vol->ubi;
606 dbg_gen("erase LEB %d:%d", vol->vol_id, lnum);
608 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
611 if (!ubi_leb_valid(vol, lnum))
617 err = ubi_eba_unmap_leb(ubi, vol, lnum);
621 return ubi_wl_flush(ubi, vol->vol_id, lnum);
623 EXPORT_SYMBOL_GPL(ubi_leb_erase);
626 * ubi_leb_unmap - un-map logical eraseblock.
627 * @desc: volume descriptor
628 * @lnum: logical eraseblock number
630 * This function un-maps logical eraseblock @lnum and schedules the
631 * corresponding physical eraseblock for erasure, so that it will eventually be
632 * physically erased in background. This operation is much faster than the
635 * Unlike erase, the un-map operation does not guarantee that the logical
636 * eraseblock will contain all 0xFF bytes when UBI is initialized again. For
637 * example, if several logical eraseblocks are un-mapped, and an unclean reboot
638 * happens after this, the logical eraseblocks will not necessarily be
639 * un-mapped again when this MTD device is attached. They may actually be
640 * mapped to the same physical eraseblocks again. So, this function has to be
643 * In other words, when un-mapping a logical eraseblock, UBI does not store
644 * any information about this on the flash media, it just marks the logical
645 * eraseblock as "un-mapped" in RAM. If UBI is detached before the physical
646 * eraseblock is physically erased, it will be mapped again to the same logical
647 * eraseblock when the MTD device is attached again.
649 * The main and obvious use-case of this function is when the contents of a
650 * logical eraseblock has to be re-written. Then it is much more efficient to
651 * first un-map it, then write new data, rather than first erase it, then write
652 * new data. Note, once new data has been written to the logical eraseblock,
653 * UBI guarantees that the old contents has gone forever. In other words, if an
654 * unclean reboot happens after the logical eraseblock has been un-mapped and
655 * then written to, it will contain the last written data.
657 * This function returns zero in case of success and a negative error code in
658 * case of failure. If the volume is damaged because of an interrupted update
659 * this function just returns immediately with %-EBADF code.
661 int ubi_leb_unmap(struct ubi_volume_desc *desc, int lnum)
663 struct ubi_volume *vol = desc->vol;
664 struct ubi_device *ubi = vol->ubi;
666 dbg_gen("unmap LEB %d:%d", vol->vol_id, lnum);
668 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
671 if (!ubi_leb_valid(vol, lnum))
677 return ubi_eba_unmap_leb(ubi, vol, lnum);
679 EXPORT_SYMBOL_GPL(ubi_leb_unmap);
682 * ubi_leb_map - map logical eraseblock to a physical eraseblock.
683 * @desc: volume descriptor
684 * @lnum: logical eraseblock number
686 * This function maps an un-mapped logical eraseblock @lnum to a physical
687 * eraseblock. This means, that after a successful invocation of this
688 * function the logical eraseblock @lnum will be empty (contain only %0xFF
689 * bytes) and be mapped to a physical eraseblock, even if an unclean reboot
692 * This function returns zero in case of success, %-EBADF if the volume is
693 * damaged because of an interrupted update, %-EBADMSG if the logical
694 * eraseblock is already mapped, and other negative error codes in case of
697 int ubi_leb_map(struct ubi_volume_desc *desc, int lnum)
699 struct ubi_volume *vol = desc->vol;
700 struct ubi_device *ubi = vol->ubi;
702 dbg_gen("map LEB %d:%d", vol->vol_id, lnum);
704 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
707 if (!ubi_leb_valid(vol, lnum))
713 if (ubi_eba_is_mapped(vol, lnum))
716 return ubi_eba_write_leb(ubi, vol, lnum, NULL, 0, 0);
718 EXPORT_SYMBOL_GPL(ubi_leb_map);
721 * ubi_is_mapped - check if logical eraseblock is mapped.
722 * @desc: volume descriptor
723 * @lnum: logical eraseblock number
725 * This function checks if logical eraseblock @lnum is mapped to a physical
726 * eraseblock. If a logical eraseblock is un-mapped, this does not necessarily
727 * mean it will still be un-mapped after the UBI device is re-attached. The
728 * logical eraseblock may become mapped to the physical eraseblock it was last
731 * This function returns %1 if the LEB is mapped, %0 if not, and a negative
732 * error code in case of failure. If the volume is damaged because of an
733 * interrupted update this function just returns immediately with %-EBADF error
736 int ubi_is_mapped(struct ubi_volume_desc *desc, int lnum)
738 struct ubi_volume *vol = desc->vol;
740 dbg_gen("test LEB %d:%d", vol->vol_id, lnum);
742 if (!ubi_leb_valid(vol, lnum))
748 return ubi_eba_is_mapped(vol, lnum);
750 EXPORT_SYMBOL_GPL(ubi_is_mapped);
753 * ubi_sync - synchronize UBI device buffers.
754 * @ubi_num: UBI device to synchronize
756 * The underlying MTD device may cache data in hardware or in software. This
757 * function ensures the caches are flushed. Returns zero in case of success and
758 * a negative error code in case of failure.
760 int ubi_sync(int ubi_num)
762 struct ubi_device *ubi;
764 ubi = ubi_get_device(ubi_num);
772 EXPORT_SYMBOL_GPL(ubi_sync);
775 * ubi_flush - flush UBI work queue.
776 * @ubi_num: UBI device to flush work queue
777 * @vol_id: volume id to flush for
778 * @lnum: logical eraseblock number to flush for
780 * This function executes all pending works for a particular volume id / logical
781 * eraseblock number pair. If either value is set to %UBI_ALL, then it acts as
782 * a wildcard for all of the corresponding volume numbers or logical
783 * eraseblock numbers. It returns zero in case of success and a negative error
784 * code in case of failure.
786 int ubi_flush(int ubi_num, int vol_id, int lnum)
788 struct ubi_device *ubi;
791 ubi = ubi_get_device(ubi_num);
795 err = ubi_wl_flush(ubi, vol_id, lnum);
799 EXPORT_SYMBOL_GPL(ubi_flush);
801 BLOCKING_NOTIFIER_HEAD(ubi_notifiers);
804 * ubi_register_volume_notifier - register a volume notifier.
805 * @nb: the notifier description object
806 * @ignore_existing: if non-zero, do not send "added" notification for all
807 * already existing volumes
809 * This function registers a volume notifier, which means that
810 * 'nb->notifier_call()' will be invoked when an UBI volume is created,
811 * removed, re-sized, re-named, or updated. The first argument of the function
812 * is the notification type. The second argument is pointer to a
813 * &struct ubi_notification object which describes the notification event.
814 * Using UBI API from the volume notifier is prohibited.
816 * This function returns zero in case of success and a negative error code
817 * in case of failure.
819 int ubi_register_volume_notifier(struct notifier_block *nb,
824 err = blocking_notifier_chain_register(&ubi_notifiers, nb);
831 * We are going to walk all UBI devices and all volumes, and
832 * notify the user about existing volumes by the %UBI_VOLUME_ADDED
833 * event. We have to lock the @ubi_devices_mutex to make sure UBI
834 * devices do not disappear.
836 mutex_lock(&ubi_devices_mutex);
837 ubi_enumerate_volumes(nb);
838 mutex_unlock(&ubi_devices_mutex);
842 EXPORT_SYMBOL_GPL(ubi_register_volume_notifier);
845 * ubi_unregister_volume_notifier - unregister the volume notifier.
846 * @nb: the notifier description object
848 * This function unregisters volume notifier @nm and returns zero in case of
849 * success and a negative error code in case of failure.
851 int ubi_unregister_volume_notifier(struct notifier_block *nb)
853 return blocking_notifier_chain_unregister(&ubi_notifiers, nb);
855 EXPORT_SYMBOL_GPL(ubi_unregister_volume_notifier);