aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-07-29 04:18:44 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-11-29 23:32:06 -0500
commit36673307aee535f951f4eede81049c6962bc4ba9 (patch)
tree20f238a8883ba449e9a9634a74d65c0632827794
parent4e7c77a385efac81d6677a4a761b1b66cd2cb59e (diff)
powerpc/nvram: nvram_create_partitions() now uses bytes
This converts nvram_create_partition() to use a size in bytes rather than blocks. It does the appropriate alignment internally The size passed is also the data size (ie. doesn't include the header anymore). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/kernel/nvram_64.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 9e133355f74..a5a5587121a 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -34,10 +34,10 @@
34 34
35#undef DEBUG_NVRAM 35#undef DEBUG_NVRAM
36 36
37#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */ 37#define NVRAM_HEADER_LEN sizeof(struct nvram_header)
38#define NVRAM_BLOCK_LEN 16 38#define NVRAM_BLOCK_LEN NVRAM_HEADER_LEN
39#define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN) 39#define NVRAM_MAX_REQ 2079
40#define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN) 40#define NVRAM_MIN_REQ 1055
41 41
42/* If change this size, then change the size of NVNAME_LEN */ 42/* If change this size, then change the size of NVNAME_LEN */
43struct nvram_header { 43struct nvram_header {
@@ -311,7 +311,7 @@ static int __init nvram_remove_os_partition(void)
311 * nvram_create_partition - Create a partition in nvram 311 * nvram_create_partition - Create a partition in nvram
312 * @name: name of the partition to create 312 * @name: name of the partition to create
313 * @sig: signature of the partition to create 313 * @sig: signature of the partition to create
314 * @req_size: size to allocate preferrably 314 * @req_size: size of data to allocate in bytes
315 * @min_size: minimum acceptable size (0 means req_size) 315 * @min_size: minimum acceptable size (0 means req_size)
316 */ 316 */
317static int __init nvram_create_partition(const char *name, int sig, 317static int __init nvram_create_partition(const char *name, int sig,
@@ -325,12 +325,20 @@ static int __init nvram_create_partition(const char *name, int sig,
325 long size = 0; 325 long size = 0;
326 int rc; 326 int rc;
327 327
328 /* Convert sizes from bytes to blocks */
329 req_size = _ALIGN_UP(req_size, NVRAM_BLOCK_LEN) / NVRAM_BLOCK_LEN;
330 min_size = _ALIGN_UP(min_size, NVRAM_BLOCK_LEN) / NVRAM_BLOCK_LEN;
331
328 /* If no minimum size specified, make it the same as the 332 /* If no minimum size specified, make it the same as the
329 * requested size 333 * requested size
330 */ 334 */
331 if (min_size == 0) 335 if (min_size == 0)
332 min_size = req_size; 336 min_size = req_size;
333 337
338 /* Now add one block to each for the header */
339 req_size += 1;
340 min_size += 1;
341
334 /* Find a free partition that will give us the maximum needed size 342 /* Find a free partition that will give us the maximum needed size
335 If can't find one that will give us the minimum size needed */ 343 If can't find one that will give us the minimum size needed */
336 list_for_each_entry(part, &nvram_part->partition, partition) { 344 list_for_each_entry(part, &nvram_part->partition, partition) {
@@ -450,7 +458,7 @@ static int __init nvram_setup_partition(void)
450 if (strcmp(part->header.name, "ppc64,linux")) 458 if (strcmp(part->header.name, "ppc64,linux"))
451 continue; 459 continue;
452 460
453 if (part->header.length >= NVRAM_MIN_REQ) { 461 if ((part->header.length - 1) * NVRAM_BLOCK_LEN >= NVRAM_MIN_REQ) {
454 /* found our partition */ 462 /* found our partition */
455 nvram_error_log_index = part->index + NVRAM_HEADER_LEN; 463 nvram_error_log_index = part->index + NVRAM_HEADER_LEN;
456 nvram_error_log_size = ((part->header.length - 1) * 464 nvram_error_log_size = ((part->header.length - 1) *