From b1dd9b349a5fb928b122c7d7c7714dc2145a5587 Mon Sep 17 00:00:00 2001 From: Krzysztof Mazur Date: Tue, 7 Jun 2011 23:47:54 +0200 Subject: [PATCH 39/84] lsbd: use LSBD_PARTITIONS for number of partitions This patch adds LSBD_PARTITIONS define. This define is used instead of hardcoded value. --- drivers/block/lsbd.c | 12 ++++++------ include/linux/lsbd.h | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/block/lsbd.c b/drivers/block/lsbd.c index 79d5e42..f6a05f0 100644 --- a/drivers/block/lsbd.c +++ b/drivers/block/lsbd.c @@ -111,7 +111,7 @@ struct lsbd { unsigned int blocks_to_write; struct semaphore req_sem; - struct lsbd_partition part[16]; + struct lsbd_partition part[LSBD_PARTITIONS]; int stop; struct task_struct *tsk; @@ -211,7 +211,7 @@ static unsigned int lsbd_map_sector(struct lsbd *p, unsigned int partition, return sector; } - BUG_ON(partition > 16); + BUG_ON(partition > LSBD_PARTITIONS); if (sector >= p->part[partition].size) return LSBD_SECT_INVALID; @@ -814,12 +814,12 @@ static int lsbd_load_partitions(struct lsbd *p, struct lsbd_block *b) unsigned int size; unsigned int i; - for (i = 0; i < 16; i++) { + for (i = 0; i < LSBD_PARTITIONS; i++) { p->part[i].start = 0; p->part[i].size = 0; } - for (i = 1; i < 16; i++) { + for (i = 1; i < LSBD_PARTITIONS; i++) { start = be32_to_cpu(b->part[i].start_flags) & LSBD_PART_MASK; size = be32_to_cpu(b->part[i].size_res) & LSBD_PART_MASK; @@ -847,7 +847,7 @@ static int lsbd_write_partitions(struct lsbd *p, struct lsbd_block *b) { unsigned int i; - for (i = 0; i < 16; i++) { + for (i = 0; i < LSBD_PARTITIONS; i++) { b->part[i].start_flags = cpu_to_be32(p->part[i].start); b->part[i].size_res = cpu_to_be32(p->part[i].size); } @@ -1145,7 +1145,7 @@ static int lsbd_partition(struct lsbd *p, struct lsbd_part_info *part) lsbd_debug(p, "part: %d %d %d %d\n", part->num, part->flags, part->start, part->size); - if (part->num > 16) + if (part->num > LSBD_PARTITIONS) return -EINVAL; if (part->flags & ~LSBD_PART_MIRRORED) diff --git a/include/linux/lsbd.h b/include/linux/lsbd.h index 63fe10b..419cb26 100644 --- a/include/linux/lsbd.h +++ b/include/linux/lsbd.h @@ -42,6 +42,9 @@ struct lsbd_part { u32 size_res; } __attribute__((packed)); +/* the number of LSBD partitions */ +#define LSBD_PARTITIONS 16 + #define LSBD_BLOCK_MAGIC 0x4c534244AA1122FFULL struct lsbd_block { u64 magic; /* 0x00 block magic */ @@ -77,7 +80,8 @@ struct lsbd_block { u32 pad2[(0x100 - 0xa0) / 4]; /* 0xc0 - reserved */ - struct lsbd_part part[16]; /* 0x100-0x17f partition table */ + /* 0x100-0x17f partition table */ + struct lsbd_part part[LSBD_PARTITIONS]; u32 pad3[256 - 0x180/4 - 1]; /* 0xc0 */ -- 1.8.4.652.g0d6e0ce