Lines Matching full:ubi

28 #include <linux/mtd/ubi.h>
31 #include "ubi-media.h"
33 /* Maximum number of supported UBI devices */
36 /* UBI name used for character devices, sysfs, etc */
37 #define UBI_NAME_STR "ubi"
41 /* Normal UBI messages */
43 void ubi_msg(const struct ubi_device *ubi, const char *fmt, ...);
45 /* UBI warning messages */
47 void ubi_warn(const struct ubi_device *ubi, const char *fmt, ...);
49 /* UBI error messages */
51 void ubi_err(const struct ubi_device *ubi, const char *fmt, ...);
63 * In case of errors, UBI tries to repeat the operation several times before
64 * returning error. The below constant defines how many times UBI re-tries.
79 * The UBI debugfs directory name pattern and maximum name length (3 for "ubi"
82 #define UBI_DFS_DIR_NAME "ubi%d"
190 * &struct ubi_ltree_entry object is inserted to the lock tree (@ubi->ltree).
210 * UBI first creates a list of &struct ubi_rename_entry objects from the
265 * UBI implementation.
275 * struct ubi_volume - UBI volume description data structure.
278 * @ubi: reference to the UBI device description object
320 * protected by UBI LEB lock tree.
323 * Since UBI protects only static volumes, this field is not relevant to
333 struct ubi_device *ubi; member
374 * struct ubi_volume_desc - UBI volume descriptor returned when it is opened.
385 * struct ubi_debug_info - debugging information for an UBI device.
387 * @chk_gen: if UBI general extra checks are enabled
388 * @chk_io: if UBI I/O extra checks are enabled
389 * @chk_fastmap: if UBI fastmap extra checks are enabled
398 * @dfs_dir_name: name of debugfs directory containing files of this UBI device
399 * @dfs_dir: direntry object of the UBI device debugfs directory
400 * @dfs_chk_gen: debugfs knob to enable UBI general extra checks
401 * @dfs_chk_io: debugfs knob to enable UBI I/O extra checks
402 * @dfs_chk_fastmap: debugfs knob to enable UBI fastmap extra checks
438 * struct ubi_device - UBI device description structure
439 * @dev: UBI device object to use the Linux device model
441 * @ubi_num: UBI device number
442 * @ubi_name: UBI device name
443 * @vol_count: number of volumes in this UBI device
444 * @volumes: volumes of this UBI device
450 * @ref_count: count of references on the UBI device
460 * of UBI initialization
488 * @fast_attach: non-zero if UBI was attached by fastmap
527 * used by UBI)
532 * @ro_mode: if the UBI device is in read-only mode
553 * @dbg: debugging information for this UBI device
729 * @alien: list of physical eraseblocks which should not be used by UBI (e.g.,
756 * be used by other UBI sub-systems to build final UBI data structures, further
787 * struct ubi_work - UBI work description data structure.
803 int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int shutdown);
825 int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
831 struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
833 int ubi_attach(struct ubi_device *ubi, int force_scan);
837 int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
839 int ubi_vtbl_rename_volumes(struct ubi_device *ubi,
841 int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai);
844 int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req);
847 int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list);
848 int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol);
849 void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol);
852 int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
854 int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol,
856 int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
858 int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
862 int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
864 int ubi_check_volume(struct ubi_device *ubi, int vol_id);
865 void ubi_update_reserved(struct ubi_device *ubi);
866 void ubi_calculate_reserved(struct ubi_device *ubi);
884 int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,
886 int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
888 int ubi_eba_read_leb_sg(struct ubi_device *ubi, struct ubi_volume *vol,
891 int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
893 int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol,
895 int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
897 int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
899 int ubi_eba_init(struct ubi_device *ubi, struct ubi_attach_info *ai);
900 unsigned long long ubi_next_sqnum(struct ubi_device *ubi);
901 int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
905 int ubi_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, int torture);
906 int ubi_wl_get_peb(struct ubi_device *ubi);
907 int ubi_wl_put_peb(struct ubi_device *ubi, int vol_id, int lnum,
909 int ubi_wl_flush(struct ubi_device *ubi, int vol_id, int lnum);
910 int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum);
911 int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai);
912 void ubi_wl_close(struct ubi_device *ubi);
914 struct ubi_wl_entry *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor);
915 int ubi_wl_put_fm_peb(struct ubi_device *ubi, struct ubi_wl_entry *used_e,
918 void ubi_refill_pools_and_lock(struct ubi_device *ubi);
919 int ubi_ensure_anchor_pebs(struct ubi_device *ubi);
920 int ubi_bitflip_check(struct ubi_device *ubi, int pnum, int force_scrub);
923 int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
925 int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
927 int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture);
928 int ubi_io_is_bad(const struct ubi_device *ubi, int pnum);
929 int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum);
930 int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
932 int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
934 int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
936 int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
945 void ubi_put_device(struct ubi_device *ubi);
948 int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol,
950 int ubi_notify_all(struct ubi_device *ubi, int ntype,
953 void ubi_free_all_volumes(struct ubi_device *ubi);
954 void ubi_free_internal_volumes(struct ubi_device *ubi);
957 void ubi_do_get_device_info(struct ubi_device *ubi, struct ubi_device_info *di);
958 void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol,
962 int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb,
967 size_t ubi_calc_fm_size(struct ubi_device *ubi);
968 int ubi_update_fastmap(struct ubi_device *ubi);
969 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
974 static inline int ubi_update_fastmap(struct ubi_device *ubi) { return 0; } in ubi_update_fastmap() argument
999 * ubi_for_each_free_peb - walk the UBI free RB tree.
1000 * @ubi: UBI device description object
1004 #define ubi_for_each_free_peb(ubi, e, tmp_rb) \ argument
1005 ubi_rb_for_each_entry((tmp_rb), (e), &(ubi)->free, u.rb)
1008 * ubi_for_each_used_peb - walk the UBI used RB tree.
1009 * @ubi: UBI device description object
1013 #define ubi_for_each_used_peb(ubi, e, tmp_rb) \ argument
1014 ubi_rb_for_each_entry((tmp_rb), (e), &(ubi)->used, u.rb)
1017 * ubi_for_each_scub_peb - walk the UBI scub RB tree.
1018 * @ubi: UBI device description object
1022 #define ubi_for_each_scrub_peb(ubi, e, tmp_rb) \ argument
1023 ubi_rb_for_each_entry((tmp_rb), (e), &(ubi)->scrub, u.rb)
1026 * ubi_for_each_protected_peb - walk the UBI protection queue.
1027 * @ubi: UBI device description object
1031 #define ubi_for_each_protected_peb(ubi, i, e) \ argument
1033 list_for_each_entry((e), &(ubi->pq[(i)]), u.list)
1066 * @ubi: the UBI device
1070 static inline void ubi_init_vid_buf(const struct ubi_device *ubi, in ubi_init_vid_buf() argument
1075 memset(buf, 0, ubi->vid_hdr_alsize); in ubi_init_vid_buf()
1078 vidb->hdr = buf + ubi->vid_hdr_shift; in ubi_init_vid_buf()
1083 * @ubi: the UBI device
1087 ubi_alloc_vid_buf(const struct ubi_device *ubi, gfp_t gfp_flags) in ubi_alloc_vid_buf() argument
1096 buf = kmalloc(ubi->vid_hdr_alsize, gfp_flags); in ubi_alloc_vid_buf()
1102 ubi_init_vid_buf(ubi, vidb, buf); in ubi_alloc_vid_buf()
1131 * @ubi: UBI device description object
1133 static inline void ubi_ro_mode(struct ubi_device *ubi) in ubi_ro_mode() argument
1135 if (!ubi->ro_mode) { in ubi_ro_mode()
1136 ubi->ro_mode = 1; in ubi_ro_mode()
1137 ubi_warn(ubi, "switch to read-only mode"); in ubi_ro_mode()
1147 static inline int ubi_io_read_data(const struct ubi_device *ubi, void *buf, in ubi_io_read_data() argument
1151 return ubi_io_read(ubi, buf, pnum, offset + ubi->leb_start, len); in ubi_io_read_data()
1159 static inline int ubi_io_write_data(struct ubi_device *ubi, const void *buf, in ubi_io_write_data() argument
1164 if (ubi_dbg_power_cut(ubi, MASK_POWER_CUT_DATA)) { in ubi_io_write_data()
1165 ubi_warn(ubi, "XXXXX emulating a power cut when writing data XXXXX"); in ubi_io_write_data()
1166 ubi_ro_mode(ubi); in ubi_io_write_data()
1169 return ubi_io_write(ubi, buf, pnum, offset + ubi->leb_start, len); in ubi_io_write_data()
1174 * @ubi: UBI device description object
1177 static inline int vol_id2idx(const struct ubi_device *ubi, int vol_id) in vol_id2idx() argument
1180 return vol_id - UBI_INTERNAL_VOL_START + ubi->vtbl_slots; in vol_id2idx()
1187 * @ubi: UBI device description object
1190 static inline int idx2vol_id(const struct ubi_device *ubi, int idx) in idx2vol_id() argument
1192 if (idx >= ubi->vtbl_slots) in idx2vol_id()
1193 return idx - ubi->vtbl_slots + UBI_INTERNAL_VOL_START; in idx2vol_id()
1215 * @ubi: UBI device description object
1221 static inline struct ubi_wl_entry *ubi_find_fm_block(const struct ubi_device *ubi, in ubi_find_fm_block() argument
1226 if (ubi->fm) { in ubi_find_fm_block()
1227 for (i = 0; i < ubi->fm->used_blocks; i++) { in ubi_find_fm_block()
1228 if (ubi->fm->e[i]->pnum == pnum) in ubi_find_fm_block()
1229 return ubi->fm->e[i]; in ubi_find_fm_block()