aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-18 06:00:10 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-05-20 14:01:28 -0400
commit0479ab48bb30019820c296a081ebd70a9cc6872a (patch)
tree9cf3d6ed8ecfd6977570a9851d3671a027f5b914 /drivers/mtd
parent9c47fb2fbe585698e9e6dac3ec033ea94765f38c (diff)
UBI: remove scan.h
This file is small and it does not make sense to have it separate from where everything else lives, so merge it with ubi.h. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/ubi/scan.h173
-rw-r--r--drivers/mtd/ubi/ubi.h148
2 files changed, 147 insertions, 174 deletions
diff --git a/drivers/mtd/ubi/scan.h b/drivers/mtd/ubi/scan.h
deleted file mode 100644
index e79524313d4b..000000000000
--- a/drivers/mtd/ubi/scan.h
+++ /dev/null
@@ -1,173 +0,0 @@
1/*
2 * Copyright (c) International Business Machines Corp., 2006
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Artem Bityutskiy (Битюцкий Артём)
19 */
20
21#ifndef __UBI_SCAN_H__
22#define __UBI_SCAN_H__
23
24/*
25 * When a field of the attaching information has this value - its real value is
26 * unknown.
27 */
28#define UBI_UNKNOWN (-1)
29
30/**
31 * struct ubi_ainf_peb - attach information about a physical eraseblock.
32 * @ec: erase counter (%UBI_UNKNOWN if it is unknown)
33 * @pnum: physical eraseblock number
34 * @lnum: logical eraseblock number
35 * @scrub: if this physical eraseblock needs scrubbing
36 * @copy_flag: this LEB is a copy (@copy_flag is set in VID header of this LEB)
37 * @sqnum: sequence number
38 * @u: unions RB-tree or @list links
39 * @u.rb: link in the per-volume RB-tree of &struct ubi_ainf_peb objects
40 * @u.list: link in one of the eraseblock lists
41 *
42 * One object of this type is allocated for each physical eraseblock when
43 * attaching an MTD device.
44 */
45struct ubi_ainf_peb {
46 int ec;
47 int pnum;
48 int lnum;
49 unsigned int scrub:1;
50 unsigned int copy_flag:1;
51 unsigned long long sqnum;
52 union {
53 struct rb_node rb;
54 struct list_head list;
55 } u;
56};
57
58/**
59 * struct ubi_ainf_volume - attaching information about a volume.
60 * @vol_id: volume ID
61 * @highest_lnum: highest logical eraseblock number in this volume
62 * @leb_count: number of logical eraseblocks in this volume
63 * @vol_type: volume type
64 * @used_ebs: number of used logical eraseblocks in this volume (only for
65 * static volumes)
66 * @last_data_size: amount of data in the last logical eraseblock of this
67 * volume (always equivalent to the usable logical eraseblock
68 * size in case of dynamic volumes)
69 * @data_pad: how many bytes at the end of logical eraseblocks of this volume
70 * are not used (due to volume alignment)
71 * @compat: compatibility flags of this volume
72 * @rb: link in the volume RB-tree
73 * @root: root of the RB-tree containing all the eraseblock belonging to this
74 * volume (&struct ubi_ainf_peb objects)
75 *
76 * One object of this type is allocated for each volume when attaching an MTD
77 * device.
78 */
79struct ubi_ainf_volume {
80 int vol_id;
81 int highest_lnum;
82 int leb_count;
83 int vol_type;
84 int used_ebs;
85 int last_data_size;
86 int data_pad;
87 int compat;
88 struct rb_node rb;
89 struct rb_root root;
90};
91
92/**
93 * struct ubi_attach_info - MTD device attaching information.
94 * @volumes: root of the volume RB-tree
95 * @corr: list of corrupted physical eraseblocks
96 * @free: list of free physical eraseblocks
97 * @erase: list of physical eraseblocks which have to be erased
98 * @alien: list of physical eraseblocks which should not be used by UBI (e.g.,
99 * those belonging to "preserve"-compatible internal volumes)
100 * @corr_peb_count: count of PEBs in the @corr list
101 * @empty_peb_count: count of PEBs which are presumably empty (contain only
102 * 0xFF bytes)
103 * @alien_peb_count: count of PEBs in the @alien list
104 * @bad_peb_count: count of bad physical eraseblocks
105 * @maybe_bad_peb_count: count of bad physical eraseblocks which are not marked
106 * as bad yet, but which look like bad
107 * @vols_found: number of volumes found
108 * @highest_vol_id: highest volume ID
109 * @is_empty: flag indicating whether the MTD device is empty or not
110 * @min_ec: lowest erase counter value
111 * @max_ec: highest erase counter value
112 * @max_sqnum: highest sequence number value
113 * @mean_ec: mean erase counter value
114 * @ec_sum: a temporary variable used when calculating @mean_ec
115 * @ec_count: a temporary variable used when calculating @mean_ec
116 * @aeb_slab_cache: slab cache for &struct ubi_ainf_peb objects
117 *
118 * This data structure contains the result of attaching an MTD device and may
119 * be used by other UBI sub-systems to build final UBI data structures, further
120 * error-recovery and so on.
121 */
122struct ubi_attach_info {
123 struct rb_root volumes;
124 struct list_head corr;
125 struct list_head free;
126 struct list_head erase;
127 struct list_head alien;
128 int corr_peb_count;
129 int empty_peb_count;
130 int alien_peb_count;
131 int bad_peb_count;
132 int maybe_bad_peb_count;
133 int vols_found;
134 int highest_vol_id;
135 int is_empty;
136 int min_ec;
137 int max_ec;
138 unsigned long long max_sqnum;
139 int mean_ec;
140 uint64_t ec_sum;
141 int ec_count;
142 struct kmem_cache *aeb_slab_cache;
143};
144
145struct ubi_device;
146struct ubi_vid_hdr;
147
148/*
149 * ubi_move_aeb_to_list - move a PEB from the volume tree to a list.
150 *
151 * @av: volume attaching information
152 * @aeb: attaching eraseblock information
153 * @list: the list to move to
154 */
155static inline void ubi_move_aeb_to_list(struct ubi_ainf_volume *av,
156 struct ubi_ainf_peb *aeb,
157 struct list_head *list)
158{
159 rb_erase(&aeb->u.rb, &av->root);
160 list_add_tail(&aeb->u.list, list);
161}
162
163int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
164 int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips);
165struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai,
166 int vol_id);
167void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av);
168struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
169 struct ubi_attach_info *ai);
170int ubi_attach(struct ubi_device *ubi);
171void ubi_destroy_ai(struct ubi_attach_info *ai);
172
173#endif /* !__UBI_SCAN_H__ */
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index e09e558bc539..52756327827a 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -43,7 +43,6 @@
43#include <asm/pgtable.h> 43#include <asm/pgtable.h>
44 44
45#include "ubi-media.h" 45#include "ubi-media.h"
46#include "scan.h"
47 46
48/* Maximum number of supported UBI devices */ 47/* Maximum number of supported UBI devices */
49#define UBI_MAX_DEVICES 32 48#define UBI_MAX_DEVICES 32
@@ -83,6 +82,12 @@
83#define UBI_PROT_QUEUE_LEN 10 82#define UBI_PROT_QUEUE_LEN 10
84 83
85/* 84/*
85 * When a field of the attaching information has this value - its real value is
86 * unknown.
87 */
88#define UBI_UNKNOWN -1
89
90/*
86 * Error codes returned by the I/O sub-system. 91 * Error codes returned by the I/O sub-system.
87 * 92 *
88 * UBI_IO_FF: the read region of flash contains only 0xFFs 93 * UBI_IO_FF: the read region of flash contains only 0xFFs
@@ -474,6 +479,121 @@ struct ubi_device {
474 struct ubi_debug_info *dbg; 479 struct ubi_debug_info *dbg;
475}; 480};
476 481
482/**
483 * struct ubi_ainf_peb - attach information about a physical eraseblock.
484 * @ec: erase counter (%UBI_UNKNOWN if it is unknown)
485 * @pnum: physical eraseblock number
486 * @lnum: logical eraseblock number
487 * @scrub: if this physical eraseblock needs scrubbing
488 * @copy_flag: this LEB is a copy (@copy_flag is set in VID header of this LEB)
489 * @sqnum: sequence number
490 * @u: unions RB-tree or @list links
491 * @u.rb: link in the per-volume RB-tree of &struct ubi_ainf_peb objects
492 * @u.list: link in one of the eraseblock lists
493 *
494 * One object of this type is allocated for each physical eraseblock when
495 * attaching an MTD device.
496 */
497struct ubi_ainf_peb {
498 int ec;
499 int pnum;
500 int lnum;
501 unsigned int scrub:1;
502 unsigned int copy_flag:1;
503 unsigned long long sqnum;
504 union {
505 struct rb_node rb;
506 struct list_head list;
507 } u;
508};
509
510/**
511 * struct ubi_ainf_volume - attaching information about a volume.
512 * @vol_id: volume ID
513 * @highest_lnum: highest logical eraseblock number in this volume
514 * @leb_count: number of logical eraseblocks in this volume
515 * @vol_type: volume type
516 * @used_ebs: number of used logical eraseblocks in this volume (only for
517 * static volumes)
518 * @last_data_size: amount of data in the last logical eraseblock of this
519 * volume (always equivalent to the usable logical eraseblock
520 * size in case of dynamic volumes)
521 * @data_pad: how many bytes at the end of logical eraseblocks of this volume
522 * are not used (due to volume alignment)
523 * @compat: compatibility flags of this volume
524 * @rb: link in the volume RB-tree
525 * @root: root of the RB-tree containing all the eraseblock belonging to this
526 * volume (&struct ubi_ainf_peb objects)
527 *
528 * One object of this type is allocated for each volume when attaching an MTD
529 * device.
530 */
531struct ubi_ainf_volume {
532 int vol_id;
533 int highest_lnum;
534 int leb_count;
535 int vol_type;
536 int used_ebs;
537 int last_data_size;
538 int data_pad;
539 int compat;
540 struct rb_node rb;
541 struct rb_root root;
542};
543
544/**
545 * struct ubi_attach_info - MTD device attaching information.
546 * @volumes: root of the volume RB-tree
547 * @corr: list of corrupted physical eraseblocks
548 * @free: list of free physical eraseblocks
549 * @erase: list of physical eraseblocks which have to be erased
550 * @alien: list of physical eraseblocks which should not be used by UBI (e.g.,
551 * those belonging to "preserve"-compatible internal volumes)
552 * @corr_peb_count: count of PEBs in the @corr list
553 * @empty_peb_count: count of PEBs which are presumably empty (contain only
554 * 0xFF bytes)
555 * @alien_peb_count: count of PEBs in the @alien list
556 * @bad_peb_count: count of bad physical eraseblocks
557 * @maybe_bad_peb_count: count of bad physical eraseblocks which are not marked
558 * as bad yet, but which look like bad
559 * @vols_found: number of volumes found
560 * @highest_vol_id: highest volume ID
561 * @is_empty: flag indicating whether the MTD device is empty or not
562 * @min_ec: lowest erase counter value
563 * @max_ec: highest erase counter value
564 * @max_sqnum: highest sequence number value
565 * @mean_ec: mean erase counter value
566 * @ec_sum: a temporary variable used when calculating @mean_ec
567 * @ec_count: a temporary variable used when calculating @mean_ec
568 * @aeb_slab_cache: slab cache for &struct ubi_ainf_peb objects
569 *
570 * This data structure contains the result of attaching an MTD device and may
571 * be used by other UBI sub-systems to build final UBI data structures, further
572 * error-recovery and so on.
573 */
574struct ubi_attach_info {
575 struct rb_root volumes;
576 struct list_head corr;
577 struct list_head free;
578 struct list_head erase;
579 struct list_head alien;
580 int corr_peb_count;
581 int empty_peb_count;
582 int alien_peb_count;
583 int bad_peb_count;
584 int maybe_bad_peb_count;
585 int vols_found;
586 int highest_vol_id;
587 int is_empty;
588 int min_ec;
589 int max_ec;
590 unsigned long long max_sqnum;
591 int mean_ec;
592 uint64_t ec_sum;
593 int ec_count;
594 struct kmem_cache *aeb_slab_cache;
595};
596
477#include "debug.h" 597#include "debug.h"
478 598
479extern struct kmem_cache *ubi_wl_entry_slab; 599extern struct kmem_cache *ubi_wl_entry_slab;
@@ -484,6 +604,17 @@ extern struct class *ubi_class;
484extern struct mutex ubi_devices_mutex; 604extern struct mutex ubi_devices_mutex;
485extern struct blocking_notifier_head ubi_notifiers; 605extern struct blocking_notifier_head ubi_notifiers;
486 606
607/* scan.c */
608int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
609 int ec, const struct ubi_vid_hdr *vid_hdr, int bitflips);
610struct ubi_ainf_volume *ubi_find_av(const struct ubi_attach_info *ai,
611 int vol_id);
612void ubi_remove_av(struct ubi_attach_info *ai, struct ubi_ainf_volume *av);
613struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
614 struct ubi_attach_info *ai);
615int ubi_attach(struct ubi_device *ubi);
616void ubi_destroy_ai(struct ubi_attach_info *ai);
617
487/* vtbl.c */ 618/* vtbl.c */
488int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, 619int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
489 struct ubi_vtbl_record *vtbl_rec); 620 struct ubi_vtbl_record *vtbl_rec);
@@ -590,6 +721,21 @@ void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol,
590 rb = rb_next(rb), \ 721 rb = rb_next(rb), \
591 pos = (rb ? container_of(rb, typeof(*pos), member) : NULL)) 722 pos = (rb ? container_of(rb, typeof(*pos), member) : NULL))
592 723
724/*
725 * ubi_move_aeb_to_list - move a PEB from the volume tree to a list.
726 *
727 * @av: volume attaching information
728 * @aeb: attaching eraseblock information
729 * @list: the list to move to
730 */
731static inline void ubi_move_aeb_to_list(struct ubi_ainf_volume *av,
732 struct ubi_ainf_peb *aeb,
733 struct list_head *list)
734{
735 rb_erase(&aeb->u.rb, &av->root);
736 list_add_tail(&aeb->u.list, list);
737}
738
593/** 739/**
594 * ubi_zalloc_vid_hdr - allocate a volume identifier header object. 740 * ubi_zalloc_vid_hdr - allocate a volume identifier header object.
595 * @ubi: UBI device description object 741 * @ubi: UBI device description object