diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-16 07:24:14 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-25 09:41:24 -0500 |
commit | 896c0c06aa30147630e9a75949b6ae2014c841fc (patch) | |
tree | d34cbb7ed0995b92883311134e624b0d82686e4f | |
parent | ae616e1be13599c3b64e544ebe99e69ea851e99c (diff) |
UBI: use bit-fields
Save 12 bytes of RAM per volume by using bit-fields instead of integers.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 16 | ||||
-rw-r--r-- | drivers/mtd/ubi/vmt.c | 12 |
2 files changed, 9 insertions, 19 deletions
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 3cf1aa1a0240..90cdcad83cbb 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -144,7 +144,6 @@ struct ubi_volume_desc; | |||
144 | * @readers: number of users holding this volume in read-only mode | 144 | * @readers: number of users holding this volume in read-only mode |
145 | * @writers: number of users holding this volume in read-write mode | 145 | * @writers: number of users holding this volume in read-write mode |
146 | * @exclusive: whether somebody holds this volume in exclusive mode | 146 | * @exclusive: whether somebody holds this volume in exclusive mode |
147 | * @checked: if this static volume was checked | ||
148 | * | 147 | * |
149 | * @reserved_pebs: how many physical eraseblocks are reserved for this volume | 148 | * @reserved_pebs: how many physical eraseblocks are reserved for this volume |
150 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) | 149 | * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME) |
@@ -152,21 +151,22 @@ struct ubi_volume_desc; | |||
152 | * @used_ebs: how many logical eraseblocks in this volume contain data | 151 | * @used_ebs: how many logical eraseblocks in this volume contain data |
153 | * @last_eb_bytes: how many bytes are stored in the last logical eraseblock | 152 | * @last_eb_bytes: how many bytes are stored in the last logical eraseblock |
154 | * @used_bytes: how many bytes of data this volume contains | 153 | * @used_bytes: how many bytes of data this volume contains |
155 | * @upd_marker: non-zero if the update marker is set for this volume | ||
156 | * @corrupted: non-zero if the volume is corrupted (static volumes only) | ||
157 | * @alignment: volume alignment | 154 | * @alignment: volume alignment |
158 | * @data_pad: how many bytes are not used at the end of physical eraseblocks to | 155 | * @data_pad: how many bytes are not used at the end of physical eraseblocks to |
159 | * satisfy the requested alignment | 156 | * satisfy the requested alignment |
160 | * @name_len: volume name length | 157 | * @name_len: volume name length |
161 | * @name: volume name | 158 | * @name: volume name |
162 | * | 159 | * |
163 | * @updating: whether the volume is being updated | ||
164 | * @upd_ebs: how many eraseblocks are expected to be updated | 160 | * @upd_ebs: how many eraseblocks are expected to be updated |
165 | * @upd_bytes: how many bytes are expected to be received | 161 | * @upd_bytes: how many bytes are expected to be received |
166 | * @upd_received: how many update bytes were already received | 162 | * @upd_received: how many update bytes were already received |
167 | * @upd_buf: update buffer which is used to collect update data | 163 | * @upd_buf: update buffer which is used to collect update data |
168 | * | 164 | * |
169 | * @eba_tbl: EBA table of this volume (LEB->PEB mapping) | 165 | * @eba_tbl: EBA table of this volume (LEB->PEB mapping) |
166 | * @checked: %1 if this static volume was checked | ||
167 | * @corrupted: %1 if the volume is corrupted (static volumes only) | ||
168 | * @upd_marker: %1 if the update marker is set for this volume | ||
169 | * @updating: %1 if the volume is being updated | ||
170 | * | 170 | * |
171 | * @gluebi_desc: gluebi UBI volume descriptor | 171 | * @gluebi_desc: gluebi UBI volume descriptor |
172 | * @gluebi_refcount: reference count of the gluebi MTD device | 172 | * @gluebi_refcount: reference count of the gluebi MTD device |
@@ -189,7 +189,6 @@ struct ubi_volume { | |||
189 | int readers; | 189 | int readers; |
190 | int writers; | 190 | int writers; |
191 | int exclusive; | 191 | int exclusive; |
192 | int checked; | ||
193 | 192 | ||
194 | int reserved_pebs; | 193 | int reserved_pebs; |
195 | int vol_type; | 194 | int vol_type; |
@@ -197,20 +196,21 @@ struct ubi_volume { | |||
197 | int used_ebs; | 196 | int used_ebs; |
198 | int last_eb_bytes; | 197 | int last_eb_bytes; |
199 | long long used_bytes; | 198 | long long used_bytes; |
200 | int upd_marker; | ||
201 | int corrupted; | ||
202 | int alignment; | 199 | int alignment; |
203 | int data_pad; | 200 | int data_pad; |
204 | int name_len; | 201 | int name_len; |
205 | char name[UBI_VOL_NAME_MAX+1]; | 202 | char name[UBI_VOL_NAME_MAX+1]; |
206 | 203 | ||
207 | int updating; | ||
208 | int upd_ebs; | 204 | int upd_ebs; |
209 | long long upd_bytes; | 205 | long long upd_bytes; |
210 | long long upd_received; | 206 | long long upd_received; |
211 | void *upd_buf; | 207 | void *upd_buf; |
212 | 208 | ||
213 | int *eba_tbl; | 209 | int *eba_tbl; |
210 | int checked:1; | ||
211 | int corrupted:1; | ||
212 | int upd_marker:1; | ||
213 | int updating:1; | ||
214 | 214 | ||
215 | #ifdef CONFIG_MTD_UBI_GLUEBI | 215 | #ifdef CONFIG_MTD_UBI_GLUEBI |
216 | /* Gluebi-related stuff may be compiled out */ | 216 | /* Gluebi-related stuff may be compiled out */ |
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 177227e1f80d..221ce70be569 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c | |||
@@ -526,7 +526,6 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) | |||
526 | } | 526 | } |
527 | spin_unlock(&ubi->volumes_lock); | 527 | spin_unlock(&ubi->volumes_lock); |
528 | 528 | ||
529 | |||
530 | /* Reserve physical eraseblocks */ | 529 | /* Reserve physical eraseblocks */ |
531 | pebs = reserved_pebs - vol->reserved_pebs; | 530 | pebs = reserved_pebs - vol->reserved_pebs; |
532 | if (pebs > 0) { | 531 | if (pebs > 0) { |
@@ -746,11 +745,6 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) | |||
746 | goto fail; | 745 | goto fail; |
747 | } | 746 | } |
748 | 747 | ||
749 | if (vol->upd_marker != 0 && vol->upd_marker != 1) { | ||
750 | ubi_err("bad upd_marker"); | ||
751 | goto fail; | ||
752 | } | ||
753 | |||
754 | if (vol->upd_marker && vol->corrupted) { | 748 | if (vol->upd_marker && vol->corrupted) { |
755 | dbg_err("update marker and corrupted simultaneously"); | 749 | dbg_err("update marker and corrupted simultaneously"); |
756 | goto fail; | 750 | goto fail; |
@@ -785,7 +779,7 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) | |||
785 | 779 | ||
786 | n = (long long)vol->used_ebs * vol->usable_leb_size; | 780 | n = (long long)vol->used_ebs * vol->usable_leb_size; |
787 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) { | 781 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) { |
788 | if (vol->corrupted != 0) { | 782 | if (vol->corrupted) { |
789 | ubi_err("corrupted dynamic volume"); | 783 | ubi_err("corrupted dynamic volume"); |
790 | goto fail; | 784 | goto fail; |
791 | } | 785 | } |
@@ -802,10 +796,6 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id) | |||
802 | goto fail; | 796 | goto fail; |
803 | } | 797 | } |
804 | } else { | 798 | } else { |
805 | if (vol->corrupted != 0 && vol->corrupted != 1) { | ||
806 | ubi_err("bad corrupted"); | ||
807 | goto fail; | ||
808 | } | ||
809 | if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) { | 799 | if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) { |
810 | ubi_err("bad used_ebs"); | 800 | ubi_err("bad used_ebs"); |
811 | goto fail; | 801 | goto fail; |