summaryrefslogtreecommitdiff
path: root/include/part.h
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.com>2013-04-09 21:11:56 +0000
committerTom Rini <trini@ti.com>2013-05-01 16:24:02 -0400
commit0472fbfd3250d1a33d3de78afdcbf24f78ac026b (patch)
tree1d5f822e2d95f800121368bba96a185ae6f7b0fb /include/part.h
parentbc8d98713f10582f4e35b9208f1b967c6a9f9953 (diff)
part/dev_desc: Add log2 of blocksize to block_dev_desc data struct
log2 of the device block size serves as the shift value used to calculate the block number to read in file systems when implementing avaiable block sizes. It is needed quite often in file systems thus it is pre-calculated and stored in the block device descriptor. Signed-off-by: Egbert Eich <eich@suse.com>
Diffstat (limited to 'include/part.h')
-rw-r--r--include/part.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/part.h b/include/part.h
index 12e9b056e46..f7c7cc59fca 100644
--- a/include/part.h
+++ b/include/part.h
@@ -38,6 +38,7 @@ typedef struct block_dev_desc {
#endif
lbaint_t lba; /* number of blocks */
unsigned long blksz; /* block size */
+ int log2blksz; /* for convenience: log2(blksz) */
char vendor [40+1]; /* IDE model, SCSI Vendor */
char product[20+1]; /* IDE Serial no, SCSI product */
char revision[8+1]; /* firmware revision */
@@ -58,6 +59,10 @@ typedef struct block_dev_desc {
#define BLOCK_CNT(size, block_dev_desc) (PAD_COUNT(size, block_dev_desc->blksz))
#define PAD_TO_BLOCKSIZE(size, block_dev_desc) \
(PAD_SIZE(size, block_dev_desc->blksz))
+#define LOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x & 0xcccccccc) ? 2 : 0) + \
+ ((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 : 0) + \
+ ((x & 0xffff0000) ? 16 : 0))
+#define LOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))
/* Interface types: */
#define IF_TYPE_UNKNOWN 0