forked from Minki/linux
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>
This commit is contained in:
parent
ae616e1be1
commit
896c0c06aa
@ -144,7 +144,6 @@ struct ubi_volume_desc;
|
|||||||
* @readers: number of users holding this volume in read-only mode
|
* @readers: number of users holding this volume in read-only mode
|
||||||
* @writers: number of users holding this volume in read-write mode
|
* @writers: number of users holding this volume in read-write mode
|
||||||
* @exclusive: whether somebody holds this volume in exclusive mode
|
* @exclusive: whether somebody holds this volume in exclusive mode
|
||||||
* @checked: if this static volume was checked
|
|
||||||
*
|
*
|
||||||
* @reserved_pebs: how many physical eraseblocks are reserved for this volume
|
* @reserved_pebs: how many physical eraseblocks are reserved for this volume
|
||||||
* @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
|
* @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
|
||||||
@ -152,21 +151,22 @@ struct ubi_volume_desc;
|
|||||||
* @used_ebs: how many logical eraseblocks in this volume contain data
|
* @used_ebs: how many logical eraseblocks in this volume contain data
|
||||||
* @last_eb_bytes: how many bytes are stored in the last logical eraseblock
|
* @last_eb_bytes: how many bytes are stored in the last logical eraseblock
|
||||||
* @used_bytes: how many bytes of data this volume contains
|
* @used_bytes: how many bytes of data this volume contains
|
||||||
* @upd_marker: non-zero if the update marker is set for this volume
|
|
||||||
* @corrupted: non-zero if the volume is corrupted (static volumes only)
|
|
||||||
* @alignment: volume alignment
|
* @alignment: volume alignment
|
||||||
* @data_pad: how many bytes are not used at the end of physical eraseblocks to
|
* @data_pad: how many bytes are not used at the end of physical eraseblocks to
|
||||||
* satisfy the requested alignment
|
* satisfy the requested alignment
|
||||||
* @name_len: volume name length
|
* @name_len: volume name length
|
||||||
* @name: volume name
|
* @name: volume name
|
||||||
*
|
*
|
||||||
* @updating: whether the volume is being updated
|
|
||||||
* @upd_ebs: how many eraseblocks are expected to be updated
|
* @upd_ebs: how many eraseblocks are expected to be updated
|
||||||
* @upd_bytes: how many bytes are expected to be received
|
* @upd_bytes: how many bytes are expected to be received
|
||||||
* @upd_received: how many update bytes were already received
|
* @upd_received: how many update bytes were already received
|
||||||
* @upd_buf: update buffer which is used to collect update data
|
* @upd_buf: update buffer which is used to collect update data
|
||||||
*
|
*
|
||||||
* @eba_tbl: EBA table of this volume (LEB->PEB mapping)
|
* @eba_tbl: EBA table of this volume (LEB->PEB mapping)
|
||||||
|
* @checked: %1 if this static volume was checked
|
||||||
|
* @corrupted: %1 if the volume is corrupted (static volumes only)
|
||||||
|
* @upd_marker: %1 if the update marker is set for this volume
|
||||||
|
* @updating: %1 if the volume is being updated
|
||||||
*
|
*
|
||||||
* @gluebi_desc: gluebi UBI volume descriptor
|
* @gluebi_desc: gluebi UBI volume descriptor
|
||||||
* @gluebi_refcount: reference count of the gluebi MTD device
|
* @gluebi_refcount: reference count of the gluebi MTD device
|
||||||
@ -189,7 +189,6 @@ struct ubi_volume {
|
|||||||
int readers;
|
int readers;
|
||||||
int writers;
|
int writers;
|
||||||
int exclusive;
|
int exclusive;
|
||||||
int checked;
|
|
||||||
|
|
||||||
int reserved_pebs;
|
int reserved_pebs;
|
||||||
int vol_type;
|
int vol_type;
|
||||||
@ -197,20 +196,21 @@ struct ubi_volume {
|
|||||||
int used_ebs;
|
int used_ebs;
|
||||||
int last_eb_bytes;
|
int last_eb_bytes;
|
||||||
long long used_bytes;
|
long long used_bytes;
|
||||||
int upd_marker;
|
|
||||||
int corrupted;
|
|
||||||
int alignment;
|
int alignment;
|
||||||
int data_pad;
|
int data_pad;
|
||||||
int name_len;
|
int name_len;
|
||||||
char name[UBI_VOL_NAME_MAX+1];
|
char name[UBI_VOL_NAME_MAX+1];
|
||||||
|
|
||||||
int updating;
|
|
||||||
int upd_ebs;
|
int upd_ebs;
|
||||||
long long upd_bytes;
|
long long upd_bytes;
|
||||||
long long upd_received;
|
long long upd_received;
|
||||||
void *upd_buf;
|
void *upd_buf;
|
||||||
|
|
||||||
int *eba_tbl;
|
int *eba_tbl;
|
||||||
|
int checked:1;
|
||||||
|
int corrupted:1;
|
||||||
|
int upd_marker:1;
|
||||||
|
int updating:1;
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_UBI_GLUEBI
|
#ifdef CONFIG_MTD_UBI_GLUEBI
|
||||||
/* Gluebi-related stuff may be compiled out */
|
/* Gluebi-related stuff may be compiled out */
|
||||||
|
@ -526,7 +526,6 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
|
|||||||
}
|
}
|
||||||
spin_unlock(&ubi->volumes_lock);
|
spin_unlock(&ubi->volumes_lock);
|
||||||
|
|
||||||
|
|
||||||
/* Reserve physical eraseblocks */
|
/* Reserve physical eraseblocks */
|
||||||
pebs = reserved_pebs - vol->reserved_pebs;
|
pebs = reserved_pebs - vol->reserved_pebs;
|
||||||
if (pebs > 0) {
|
if (pebs > 0) {
|
||||||
@ -746,11 +745,6 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vol->upd_marker != 0 && vol->upd_marker != 1) {
|
|
||||||
ubi_err("bad upd_marker");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vol->upd_marker && vol->corrupted) {
|
if (vol->upd_marker && vol->corrupted) {
|
||||||
dbg_err("update marker and corrupted simultaneously");
|
dbg_err("update marker and corrupted simultaneously");
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -785,7 +779,7 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
|
|||||||
|
|
||||||
n = (long long)vol->used_ebs * vol->usable_leb_size;
|
n = (long long)vol->used_ebs * vol->usable_leb_size;
|
||||||
if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
|
if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
|
||||||
if (vol->corrupted != 0) {
|
if (vol->corrupted) {
|
||||||
ubi_err("corrupted dynamic volume");
|
ubi_err("corrupted dynamic volume");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -802,10 +796,6 @@ static void paranoid_check_volume(struct ubi_device *ubi, int vol_id)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (vol->corrupted != 0 && vol->corrupted != 1) {
|
|
||||||
ubi_err("bad corrupted");
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) {
|
if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) {
|
||||||
ubi_err("bad used_ebs");
|
ubi_err("bad used_ebs");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
Reference in New Issue
Block a user