aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Keniston <jkenisto@us.ibm.com>2010-11-11 13:54:22 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-11-29 23:43:51 -0500
commit690d1a9bd14bd861328ca66473a223f60cf1ad31 (patch)
tree5193d0b167e2251817d0bf3a4339087f09dda779
parent9a866b870880065364c894823257e6982103d4e4 (diff)
powerpc/nvram: Fix NVRAM partition list setup
Simplify creation and use of the NVRAM partition list. Signed-off-by: Jim Keniston <jkenisto@us.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/kernel/nvram_64.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 125d86cf0afc..b8a50fa5875b 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -51,7 +51,7 @@ struct nvram_partition {
51 unsigned int index; 51 unsigned int index;
52}; 52};
53 53
54static struct nvram_partition * nvram_part; 54static LIST_HEAD(nvram_partitions);
55 55
56static loff_t dev_nvram_llseek(struct file *file, loff_t offset, int origin) 56static loff_t dev_nvram_llseek(struct file *file, loff_t offset, int origin)
57{ 57{
@@ -196,13 +196,11 @@ static struct miscdevice nvram_dev = {
196#ifdef DEBUG_NVRAM 196#ifdef DEBUG_NVRAM
197static void __init nvram_print_partitions(char * label) 197static void __init nvram_print_partitions(char * label)
198{ 198{
199 struct list_head * p;
200 struct nvram_partition * tmp_part; 199 struct nvram_partition * tmp_part;
201 200
202 printk(KERN_WARNING "--------%s---------\n", label); 201 printk(KERN_WARNING "--------%s---------\n", label);
203 printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n"); 202 printk(KERN_WARNING "indx\t\tsig\tchks\tlen\tname\n");
204 list_for_each(p, &nvram_part->partition) { 203 list_for_each_entry(tmp_part, &nvram_partitions, partition) {
205 tmp_part = list_entry(p, struct nvram_partition, partition);
206 printk(KERN_WARNING "%4d \t%02x\t%02x\t%d\t%s\n", 204 printk(KERN_WARNING "%4d \t%02x\t%02x\t%d\t%s\n",
207 tmp_part->index, tmp_part->header.signature, 205 tmp_part->index, tmp_part->header.signature,
208 tmp_part->header.checksum, tmp_part->header.length, 206 tmp_part->header.checksum, tmp_part->header.length,
@@ -250,7 +248,7 @@ int __init nvram_remove_partition(const char *name, int sig)
250 struct nvram_partition *part, *prev, *tmp; 248 struct nvram_partition *part, *prev, *tmp;
251 int rc; 249 int rc;
252 250
253 list_for_each_entry(part, &nvram_part->partition, partition) { 251 list_for_each_entry(part, &nvram_partitions, partition) {
254 if (part->header.signature != sig) 252 if (part->header.signature != sig)
255 continue; 253 continue;
256 if (name && strncmp(name, part->header.name, 12)) 254 if (name && strncmp(name, part->header.name, 12))
@@ -269,7 +267,7 @@ int __init nvram_remove_partition(const char *name, int sig)
269 267
270 /* Merge contiguous ones */ 268 /* Merge contiguous ones */
271 prev = NULL; 269 prev = NULL;
272 list_for_each_entry_safe(part, tmp, &nvram_part->partition, partition) { 270 list_for_each_entry_safe(part, tmp, &nvram_partitions, partition) {
273 if (part->header.signature != NVRAM_SIG_FREE) { 271 if (part->header.signature != NVRAM_SIG_FREE) {
274 prev = NULL; 272 prev = NULL;
275 continue; 273 continue;
@@ -333,7 +331,7 @@ loff_t __init nvram_create_partition(const char *name, int sig,
333 331
334 /* Find a free partition that will give us the maximum needed size 332 /* 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 */ 333 If can't find one that will give us the minimum size needed */
336 list_for_each_entry(part, &nvram_part->partition, partition) { 334 list_for_each_entry(part, &nvram_partitions, partition) {
337 if (part->header.signature != NVRAM_SIG_FREE) 335 if (part->header.signature != NVRAM_SIG_FREE)
338 continue; 336 continue;
339 337
@@ -412,7 +410,7 @@ int nvram_get_partition_size(loff_t data_index)
412{ 410{
413 struct nvram_partition *part; 411 struct nvram_partition *part;
414 412
415 list_for_each_entry(part, &nvram_part->partition, partition) { 413 list_for_each_entry(part, &nvram_partitions, partition) {
416 if (part->index + NVRAM_HEADER_LEN == data_index) 414 if (part->index + NVRAM_HEADER_LEN == data_index)
417 return (part->header.length - 1) * NVRAM_BLOCK_LEN; 415 return (part->header.length - 1) * NVRAM_BLOCK_LEN;
418 } 416 }
@@ -430,7 +428,7 @@ loff_t nvram_find_partition(const char *name, int sig, int *out_size)
430{ 428{
431 struct nvram_partition *p; 429 struct nvram_partition *p;
432 430
433 list_for_each_entry(p, &nvram_part->partition, partition) { 431 list_for_each_entry(p, &nvram_partitions, partition) {
434 if (p->header.signature == sig && 432 if (p->header.signature == sig &&
435 (!name || !strncmp(p->header.name, name, 12))) { 433 (!name || !strncmp(p->header.name, name, 12))) {
436 if (out_size) 434 if (out_size)
@@ -452,14 +450,6 @@ int __init nvram_scan_partitions(void)
452 int total_size; 450 int total_size;
453 int err; 451 int err;
454 452
455 /* Initialize our anchor for the nvram partition list */
456 nvram_part = kmalloc(sizeof(struct nvram_partition), GFP_KERNEL);
457 if (!nvram_part) {
458 printk(KERN_ERR "nvram_init: Failed kmalloc\n");
459 return -ENOMEM;
460 }
461 INIT_LIST_HEAD(&nvram_part->partition);
462
463 if (ppc_md.nvram_size == NULL || ppc_md.nvram_size() <= 0) 453 if (ppc_md.nvram_size == NULL || ppc_md.nvram_size() <= 0)
464 return -ENODEV; 454 return -ENODEV;
465 total_size = ppc_md.nvram_size(); 455 total_size = ppc_md.nvram_size();
@@ -507,7 +497,7 @@ int __init nvram_scan_partitions(void)
507 497
508 memcpy(&tmp_part->header, &phead, NVRAM_HEADER_LEN); 498 memcpy(&tmp_part->header, &phead, NVRAM_HEADER_LEN);
509 tmp_part->index = cur_index; 499 tmp_part->index = cur_index;
510 list_add_tail(&tmp_part->partition, &nvram_part->partition); 500 list_add_tail(&tmp_part->partition, &nvram_partitions);
511 501
512 cur_index += phead.length * NVRAM_BLOCK_LEN; 502 cur_index += phead.length * NVRAM_BLOCK_LEN;
513 } 503 }