Lines Matching +full:- +full:ant

1 // SPDX-License-Identifier: GPL-2.0+
24 * ubi_do_get_device_info - get information about UBI device.
33 di->ubi_num = ubi->ubi_num; in ubi_do_get_device_info()
34 di->leb_size = ubi->leb_size; in ubi_do_get_device_info()
35 di->leb_start = ubi->leb_start; in ubi_do_get_device_info()
36 di->min_io_size = ubi->min_io_size; in ubi_do_get_device_info()
37 di->max_write_size = ubi->max_write_size; in ubi_do_get_device_info()
38 di->ro_mode = ubi->ro_mode; in ubi_do_get_device_info()
40 di->cdev = ubi->cdev.dev; in ubi_do_get_device_info()
46 * ubi_get_device_info - get information about UBI device.
50 * This function returns %0 in case of success, %-EINVAL if the UBI device
51 * number is invalid, and %-ENODEV if there is no such UBI device.
58 return -EINVAL; in ubi_get_device_info()
61 return -ENODEV; in ubi_get_device_info()
69 * ubi_do_get_volume_info - get information about UBI volume.
77 vi->vol_id = vol->vol_id; in ubi_do_get_volume_info()
78 vi->ubi_num = ubi->ubi_num; in ubi_do_get_volume_info()
79 vi->size = vol->reserved_pebs; in ubi_do_get_volume_info()
80 vi->used_bytes = vol->used_bytes; in ubi_do_get_volume_info()
81 vi->vol_type = vol->vol_type; in ubi_do_get_volume_info()
82 vi->corrupted = vol->corrupted; in ubi_do_get_volume_info()
83 vi->upd_marker = vol->upd_marker; in ubi_do_get_volume_info()
84 vi->alignment = vol->alignment; in ubi_do_get_volume_info()
85 vi->usable_leb_size = vol->usable_leb_size; in ubi_do_get_volume_info()
86 vi->name_len = vol->name_len; in ubi_do_get_volume_info()
87 vi->name = vol->name; in ubi_do_get_volume_info()
88 vi->cdev = vol->cdev.dev; in ubi_do_get_volume_info()
92 * ubi_get_volume_info - get information about UBI volume.
99 ubi_do_get_volume_info(desc->vol->ubi, desc->vol, vi); in ubi_get_volume_info()
104 * ubi_open_volume - open UBI volume.
109 * The @mode parameter specifies if the volume should be opened in read-only
110 * mode, read-write mode, or exclusive mode. The exclusive mode guarantees that
131 return ERR_PTR(-EINVAL); in ubi_open_volume()
135 return ERR_PTR(-EINVAL); in ubi_open_volume()
142 return ERR_PTR(-ENODEV); in ubi_open_volume()
144 if (vol_id < 0 || vol_id >= ubi->vtbl_slots) { in ubi_open_volume()
145 err = -EINVAL; in ubi_open_volume()
151 err = -ENOMEM; in ubi_open_volume()
155 err = -ENODEV; in ubi_open_volume()
159 spin_lock(&ubi->volumes_lock); in ubi_open_volume()
160 vol = ubi->volumes[vol_id]; in ubi_open_volume()
164 err = -EBUSY; in ubi_open_volume()
167 if (vol->exclusive) in ubi_open_volume()
169 vol->readers += 1; in ubi_open_volume()
173 if (vol->exclusive || vol->writers > 0) in ubi_open_volume()
175 vol->writers += 1; in ubi_open_volume()
179 if (vol->exclusive || vol->writers || vol->readers || in ubi_open_volume()
180 vol->metaonly) in ubi_open_volume()
182 vol->exclusive = 1; in ubi_open_volume()
186 if (vol->metaonly || vol->exclusive) in ubi_open_volume()
188 vol->metaonly = 1; in ubi_open_volume()
191 get_device(&vol->dev); in ubi_open_volume()
192 vol->ref_count += 1; in ubi_open_volume()
193 spin_unlock(&ubi->volumes_lock); in ubi_open_volume()
195 desc->vol = vol; in ubi_open_volume()
196 desc->mode = mode; in ubi_open_volume()
198 mutex_lock(&ubi->ckvol_mutex); in ubi_open_volume()
199 if (!vol->checked) { in ubi_open_volume()
200 /* This is the first open - check the volume */ in ubi_open_volume()
203 mutex_unlock(&ubi->ckvol_mutex); in ubi_open_volume()
209 vol_id, ubi->ubi_num); in ubi_open_volume()
210 vol->corrupted = 1; in ubi_open_volume()
212 vol->checked = 1; in ubi_open_volume()
214 mutex_unlock(&ubi->ckvol_mutex); in ubi_open_volume()
219 spin_unlock(&ubi->volumes_lock); in ubi_open_volume()
232 * ubi_open_volume_nm - open UBI volume by name.
242 int i, vol_id = -1, len; in ubi_open_volume_nm()
249 return ERR_PTR(-EINVAL); in ubi_open_volume_nm()
253 return ERR_PTR(-EINVAL); in ubi_open_volume_nm()
256 return ERR_PTR(-EINVAL); in ubi_open_volume_nm()
260 return ERR_PTR(-ENODEV); in ubi_open_volume_nm()
262 spin_lock(&ubi->volumes_lock); in ubi_open_volume_nm()
264 for (i = 0; i < ubi->vtbl_slots; i++) { in ubi_open_volume_nm()
265 struct ubi_volume *vol = ubi->volumes[i]; in ubi_open_volume_nm()
267 if (vol && len == vol->name_len && !strcmp(name, vol->name)) { in ubi_open_volume_nm()
272 spin_unlock(&ubi->volumes_lock); in ubi_open_volume_nm()
277 ret = ERR_PTR(-ENODEV); in ubi_open_volume_nm()
290 * ubi_open_volume_path - open UBI volume by its character device node path.
306 return ERR_PTR(-EINVAL); in ubi_open_volume_path()
313 mod = inode->i_mode; in ubi_open_volume_path()
315 vol_id = iminor(inode) - 1; in ubi_open_volume_path()
319 return ERR_PTR(-EINVAL); in ubi_open_volume_path()
322 return ERR_PTR(-ENODEV); in ubi_open_volume_path()
328 * ubi_close_volume - close UBI volume.
333 struct ubi_volume *vol = desc->vol; in ubi_close_volume()
334 struct ubi_device *ubi = vol->ubi; in ubi_close_volume()
337 ubi->ubi_num, vol->vol_id, desc->mode); in ubi_close_volume()
339 spin_lock(&ubi->volumes_lock); in ubi_close_volume()
340 switch (desc->mode) { in ubi_close_volume()
342 vol->readers -= 1; in ubi_close_volume()
345 vol->writers -= 1; in ubi_close_volume()
348 vol->exclusive = 0; in ubi_close_volume()
351 vol->metaonly = 0; in ubi_close_volume()
354 vol->ref_count -= 1; in ubi_close_volume()
355 spin_unlock(&ubi->volumes_lock); in ubi_close_volume()
358 put_device(&vol->dev); in ubi_close_volume()
365 * leb_read_sanity_check - does sanity checks on read requests.
377 struct ubi_volume *vol = desc->vol; in leb_read_sanity_check()
378 struct ubi_device *ubi = vol->ubi; in leb_read_sanity_check()
379 int vol_id = vol->vol_id; in leb_read_sanity_check()
381 if (vol_id < 0 || vol_id >= ubi->vtbl_slots || lnum < 0 || in leb_read_sanity_check()
382 lnum >= vol->used_ebs || offset < 0 || len < 0 || in leb_read_sanity_check()
383 offset + len > vol->usable_leb_size) in leb_read_sanity_check()
384 return -EINVAL; in leb_read_sanity_check()
386 if (vol->vol_type == UBI_STATIC_VOLUME) { in leb_read_sanity_check()
387 if (vol->used_ebs == 0) in leb_read_sanity_check()
390 if (lnum == vol->used_ebs - 1 && in leb_read_sanity_check()
391 offset + len > vol->last_eb_bytes) in leb_read_sanity_check()
392 return -EINVAL; in leb_read_sanity_check()
395 if (vol->upd_marker) in leb_read_sanity_check()
396 return -EBADF; in leb_read_sanity_check()
402 * ubi_leb_read - read data.
414 * checksum is per-eraseblock). So checking may substantially slow down the
420 * %-EBADMSG error code is returned:
426 * returns immediately with %-EBADF error code.
431 struct ubi_volume *vol = desc->vol; in ubi_leb_read()
432 struct ubi_device *ubi = vol->ubi; in ubi_leb_read()
433 int err, vol_id = vol->vol_id; in ubi_leb_read()
445 if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) { in ubi_leb_read()
447 vol->corrupted = 1; in ubi_leb_read()
456 * ubi_leb_read_sg - read data into a scatter gather list.
471 struct ubi_volume *vol = desc->vol; in ubi_leb_read_sg()
472 struct ubi_device *ubi = vol->ubi; in ubi_leb_read_sg()
473 int err, vol_id = vol->vol_id; in ubi_leb_read_sg()
485 if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) { in ubi_leb_read_sg()
487 vol->corrupted = 1; in ubi_leb_read_sg()
496 * ubi_leb_write - write data.
508 * re-mapped to another physical eraseblock, the data is recovered, and the
518 * returns immediately with %-EBADF code.
523 struct ubi_volume *vol = desc->vol; in ubi_leb_write()
524 struct ubi_device *ubi = vol->ubi; in ubi_leb_write()
525 int vol_id = vol->vol_id; in ubi_leb_write()
529 if (vol_id < 0 || vol_id >= ubi->vtbl_slots) in ubi_leb_write()
530 return -EINVAL; in ubi_leb_write()
532 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) in ubi_leb_write()
533 return -EROFS; in ubi_leb_write()
535 if (lnum < 0 || lnum >= vol->reserved_pebs || offset < 0 || len < 0 || in ubi_leb_write()
536 offset + len > vol->usable_leb_size || in ubi_leb_write()
537 offset & (ubi->min_io_size - 1) || len & (ubi->min_io_size - 1)) in ubi_leb_write()
538 return -EINVAL; in ubi_leb_write()
540 if (vol->upd_marker) in ubi_leb_write()
541 return -EBADF; in ubi_leb_write()
551 * ubi_leb_change - change logical eraseblock atomically.
558 * has to contain new logical eraseblock data, and @len - the length of the
560 * eraseblock size, ant the logical eraseblock may be appended to more times
568 struct ubi_volume *vol = desc->vol; in ubi_leb_change()
569 struct ubi_device *ubi = vol->ubi; in ubi_leb_change()
570 int vol_id = vol->vol_id; in ubi_leb_change()
574 if (vol_id < 0 || vol_id >= ubi->vtbl_slots) in ubi_leb_change()
575 return -EINVAL; in ubi_leb_change()
577 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) in ubi_leb_change()
578 return -EROFS; in ubi_leb_change()
580 if (lnum < 0 || lnum >= vol->reserved_pebs || len < 0 || in ubi_leb_change()
581 len > vol->usable_leb_size || len & (ubi->min_io_size - 1)) in ubi_leb_change()
582 return -EINVAL; in ubi_leb_change()
584 if (vol->upd_marker) in ubi_leb_change()
585 return -EBADF; in ubi_leb_change()
595 * ubi_leb_erase - erase logical eraseblock.
599 * This function un-maps logical eraseblock @lnum and synchronously erases the
604 * returns immediately with %-EBADF code.
608 struct ubi_volume *vol = desc->vol; in ubi_leb_erase()
609 struct ubi_device *ubi = vol->ubi; in ubi_leb_erase()
612 dbg_gen("erase LEB %d:%d", vol->vol_id, lnum); in ubi_leb_erase()
614 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) in ubi_leb_erase()
615 return -EROFS; in ubi_leb_erase()
617 if (lnum < 0 || lnum >= vol->reserved_pebs) in ubi_leb_erase()
618 return -EINVAL; in ubi_leb_erase()
620 if (vol->upd_marker) in ubi_leb_erase()
621 return -EBADF; in ubi_leb_erase()
627 return ubi_wl_flush(ubi, vol->vol_id, lnum); in ubi_leb_erase()
632 * ubi_leb_unmap - un-map logical eraseblock.
636 * This function un-maps logical eraseblock @lnum and schedules the
641 * Unlike erase, the un-map operation does not guarantee that the logical
643 * example, if several logical eraseblocks are un-mapped, and an unclean reboot
645 * un-mapped again when this MTD device is attached. They may actually be
649 * In other words, when un-mapping a logical eraseblock, UBI does not store
651 * eraseblock as "un-mapped" in RAM. If UBI is detached before the physical
655 * The main and obvious use-case of this function is when the contents of a
656 * logical eraseblock has to be re-written. Then it is much more efficient to
657 * first un-map it, then write new data, rather than first erase it, then write
660 * unclean reboot happens after the logical eraseblock has been un-mapped and
665 * this function just returns immediately with %-EBADF code.
669 struct ubi_volume *vol = desc->vol; in ubi_leb_unmap()
670 struct ubi_device *ubi = vol->ubi; in ubi_leb_unmap()
672 dbg_gen("unmap LEB %d:%d", vol->vol_id, lnum); in ubi_leb_unmap()
674 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) in ubi_leb_unmap()
675 return -EROFS; in ubi_leb_unmap()
677 if (lnum < 0 || lnum >= vol->reserved_pebs) in ubi_leb_unmap()
678 return -EINVAL; in ubi_leb_unmap()
680 if (vol->upd_marker) in ubi_leb_unmap()
681 return -EBADF; in ubi_leb_unmap()
688 * ubi_leb_map - map logical eraseblock to a physical eraseblock.
692 * This function maps an un-mapped logical eraseblock @lnum to a physical
698 * This function returns zero in case of success, %-EBADF if the volume is
699 * damaged because of an interrupted update, %-EBADMSG if the logical
705 struct ubi_volume *vol = desc->vol; in ubi_leb_map()
706 struct ubi_device *ubi = vol->ubi; in ubi_leb_map()
708 dbg_gen("unmap LEB %d:%d", vol->vol_id, lnum); in ubi_leb_map()
710 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) in ubi_leb_map()
711 return -EROFS; in ubi_leb_map()
713 if (lnum < 0 || lnum >= vol->reserved_pebs) in ubi_leb_map()
714 return -EINVAL; in ubi_leb_map()
716 if (vol->upd_marker) in ubi_leb_map()
717 return -EBADF; in ubi_leb_map()
719 if (vol->eba_tbl[lnum] >= 0) in ubi_leb_map()
720 return -EBADMSG; in ubi_leb_map()
727 * ubi_is_mapped - check if logical eraseblock is mapped.
732 * eraseblock. If a logical eraseblock is un-mapped, this does not necessarily
733 * mean it will still be un-mapped after the UBI device is re-attached. The
739 * interrupted update this function just returns immediately with %-EBADF error
744 struct ubi_volume *vol = desc->vol; in ubi_is_mapped()
746 dbg_gen("test LEB %d:%d", vol->vol_id, lnum); in ubi_is_mapped()
748 if (lnum < 0 || lnum >= vol->reserved_pebs) in ubi_is_mapped()
749 return -EINVAL; in ubi_is_mapped()
751 if (vol->upd_marker) in ubi_is_mapped()
752 return -EBADF; in ubi_is_mapped()
754 return vol->eba_tbl[lnum] >= 0; in ubi_is_mapped()
759 * ubi_sync - synchronize UBI device buffers.
772 return -ENODEV; in ubi_sync()
774 mtd_sync(ubi->mtd); in ubi_sync()
781 * ubi_flush - flush UBI work queue.
799 return -ENODEV; in ubi_flush()
811 * ubi_register_volume_notifier - register a volume notifier.
813 * @ignore_existing: if non-zero, do not send "added" notification for all
817 * 'nb->notifier_call()' will be invoked when an UBI volume is created,
818 * removed, re-sized, re-named, or updated. The first argument of the function
852 * ubi_unregister_volume_notifier - unregister the volume notifier.