File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,23 @@ static int ubi_get_compat(const struct ubi_device *ubi, int vol_id)
83
83
return 0 ;
84
84
}
85
85
86
+ /**
87
+ * ubi_eba_get_ldesc - get information about a LEB
88
+ * @vol: volume description object
89
+ * @lnum: logical eraseblock number
90
+ * @ldesc: the LEB descriptor to fill
91
+ *
92
+ * Used to query information about a specific LEB.
93
+ * It is currently only returning the physical position of the LEB, but will be
94
+ * extended to provide more information.
95
+ */
96
+ void ubi_eba_get_ldesc (struct ubi_volume * vol , int lnum ,
97
+ struct ubi_eba_leb_desc * ldesc )
98
+ {
99
+ ldesc -> lnum = lnum ;
100
+ ldesc -> pnum = vol -> eba_tbl [lnum ];
101
+ }
102
+
86
103
/**
87
104
* ltree_lookup - look up the lock tree.
88
105
* @ubi: UBI device description object
Original file line number Diff line number Diff line change @@ -1257,8 +1257,12 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
1257
1257
fm_pos += sizeof (* feba ) + (sizeof (__be32 ) * vol -> reserved_pebs );
1258
1258
ubi_assert (fm_pos <= ubi -> fm_size );
1259
1259
1260
- for (j = 0 ; j < vol -> reserved_pebs ; j ++ )
1261
- feba -> pnum [j ] = cpu_to_be32 (vol -> eba_tbl [j ]);
1260
+ for (j = 0 ; j < vol -> reserved_pebs ; j ++ ) {
1261
+ struct ubi_eba_leb_desc ldesc ;
1262
+
1263
+ ubi_eba_get_ldesc (vol , j , & ldesc );
1264
+ feba -> pnum [j ] = cpu_to_be32 (ldesc .pnum );
1265
+ }
1262
1266
1263
1267
feba -> reserved_pebs = cpu_to_be32 (j );
1264
1268
feba -> magic = cpu_to_be32 (UBI_FM_EBA_MAGIC );
Original file line number Diff line number Diff line change @@ -266,6 +266,21 @@ struct ubi_fm_pool {
266
266
int max_size ;
267
267
};
268
268
269
+ /**
270
+ * struct ubi_eba_leb_desc - EBA logical eraseblock descriptor
271
+ * @lnum: the logical eraseblock number
272
+ * @pnum: the physical eraseblock where the LEB can be found
273
+ *
274
+ * This structure is here to hide EBA's internal from other part of the
275
+ * UBI implementation.
276
+ *
277
+ * One can query the position of a LEB by calling ubi_eba_get_ldesc().
278
+ */
279
+ struct ubi_eba_leb_desc {
280
+ int lnum ;
281
+ int pnum ;
282
+ };
283
+
269
284
/**
270
285
* struct ubi_volume - UBI volume description data structure.
271
286
* @dev: device object to make use of the the Linux device model
@@ -849,6 +864,8 @@ static inline bool ubi_leb_valid(struct ubi_volume *vol, int lnum)
849
864
}
850
865
851
866
/* eba.c */
867
+ void ubi_eba_get_ldesc (struct ubi_volume * vol , int lnum ,
868
+ struct ubi_eba_leb_desc * ldesc );
852
869
bool ubi_eba_is_mapped (struct ubi_volume * vol , int lnum );
853
870
int ubi_eba_unmap_leb (struct ubi_device * ubi , struct ubi_volume * vol ,
854
871
int lnum );
You can’t perform that action at this time.
0 commit comments