aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/rtas_flash.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc64/kernel/rtas_flash.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ppc64/kernel/rtas_flash.c')
-rw-r--r--arch/ppc64/kernel/rtas_flash.c725
1 files changed, 725 insertions, 0 deletions
diff --git a/arch/ppc64/kernel/rtas_flash.c b/arch/ppc64/kernel/rtas_flash.c
new file mode 100644
index 000000000000..3213837282ca
--- /dev/null
+++ b/arch/ppc64/kernel/rtas_flash.c
@@ -0,0 +1,725 @@
1/*
2 * c 2001 PPC 64 Team, IBM Corp
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 * /proc/ppc64/rtas/firmware_flash interface
10 *
11 * This file implements a firmware_flash interface to pump a firmware
12 * image into the kernel. At reboot time rtas_restart() will see the
13 * firmware image and flash it as it reboots (see rtas.c).
14 */
15
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/proc_fs.h>
19#include <asm/delay.h>
20#include <asm/uaccess.h>
21#include <asm/rtas.h>
22
23#define MODULE_VERS "1.0"
24#define MODULE_NAME "rtas_flash"
25
26#define FIRMWARE_FLASH_NAME "firmware_flash"
27#define FIRMWARE_UPDATE_NAME "firmware_update"
28#define MANAGE_FLASH_NAME "manage_flash"
29#define VALIDATE_FLASH_NAME "validate_flash"
30
31/* General RTAS Status Codes */
32#define RTAS_RC_SUCCESS 0
33#define RTAS_RC_HW_ERR -1
34#define RTAS_RC_BUSY -2
35
36/* Flash image status values */
37#define FLASH_AUTH -9002 /* RTAS Not Service Authority Partition */
38#define FLASH_NO_OP -1099 /* No operation initiated by user */
39#define FLASH_IMG_SHORT -1005 /* Flash image shorter than expected */
40#define FLASH_IMG_BAD_LEN -1004 /* Bad length value in flash list block */
41#define FLASH_IMG_NULL_DATA -1003 /* Bad data value in flash list block */
42#define FLASH_IMG_READY 0 /* Firmware img ready for flash on reboot */
43
44/* Manage image status values */
45#define MANAGE_AUTH -9002 /* RTAS Not Service Authority Partition */
46#define MANAGE_ACTIVE_ERR -9001 /* RTAS Cannot Overwrite Active Img */
47#define MANAGE_NO_OP -1099 /* No operation initiated by user */
48#define MANAGE_PARAM_ERR -3 /* RTAS Parameter Error */
49#define MANAGE_HW_ERR -1 /* RTAS Hardware Error */
50
51/* Validate image status values */
52#define VALIDATE_AUTH -9002 /* RTAS Not Service Authority Partition */
53#define VALIDATE_NO_OP -1099 /* No operation initiated by the user */
54#define VALIDATE_INCOMPLETE -1002 /* User copied < VALIDATE_BUF_SIZE */
55#define VALIDATE_READY -1001 /* Firmware image ready for validation */
56#define VALIDATE_PARAM_ERR -3 /* RTAS Parameter Error */
57#define VALIDATE_HW_ERR -1 /* RTAS Hardware Error */
58#define VALIDATE_TMP_UPDATE 0 /* Validate Return Status */
59#define VALIDATE_FLASH_AUTH 1 /* Validate Return Status */
60#define VALIDATE_INVALID_IMG 2 /* Validate Return Status */
61#define VALIDATE_CUR_UNKNOWN 3 /* Validate Return Status */
62#define VALIDATE_TMP_COMMIT_DL 4 /* Validate Return Status */
63#define VALIDATE_TMP_COMMIT 5 /* Validate Return Status */
64#define VALIDATE_TMP_UPDATE_DL 6 /* Validate Return Status */
65
66/* ibm,manage-flash-image operation tokens */
67#define RTAS_REJECT_TMP_IMG 0
68#define RTAS_COMMIT_TMP_IMG 1
69
70/* Array sizes */
71#define VALIDATE_BUF_SIZE 4096
72#define RTAS_MSG_MAXLEN 64
73
74/* Local copy of the flash block list.
75 * We only allow one open of the flash proc file and create this
76 * list as we go. This list will be put in the kernel's
77 * rtas_firmware_flash_list global var once it is fully read.
78 *
79 * For convenience as we build the list we use virtual addrs,
80 * we do not fill in the version number, and the length field
81 * is treated as the number of entries currently in the block
82 * (i.e. not a byte count). This is all fixed on release.
83 */
84
85/* Status int must be first member of struct */
86struct rtas_update_flash_t
87{
88 int status; /* Flash update status */
89 struct flash_block_list *flist; /* Local copy of flash block list */
90};
91
92/* Status int must be first member of struct */
93struct rtas_manage_flash_t
94{
95 int status; /* Returned status */
96 unsigned int op; /* Reject or commit image */
97};
98
99/* Status int must be first member of struct */
100struct rtas_validate_flash_t
101{
102 int status; /* Returned status */
103 char buf[VALIDATE_BUF_SIZE]; /* Candidate image buffer */
104 unsigned int buf_size; /* Size of image buf */
105 unsigned int update_results; /* Update results token */
106};
107
108static DEFINE_SPINLOCK(flash_file_open_lock);
109static struct proc_dir_entry *firmware_flash_pde;
110static struct proc_dir_entry *firmware_update_pde;
111static struct proc_dir_entry *validate_pde;
112static struct proc_dir_entry *manage_pde;
113
114/* Do simple sanity checks on the flash image. */
115static int flash_list_valid(struct flash_block_list *flist)
116{
117 struct flash_block_list *f;
118 int i;
119 unsigned long block_size, image_size;
120
121 /* Paranoid self test here. We also collect the image size. */
122 image_size = 0;
123 for (f = flist; f; f = f->next) {
124 for (i = 0; i < f->num_blocks; i++) {
125 if (f->blocks[i].data == NULL) {
126 return FLASH_IMG_NULL_DATA;
127 }
128 block_size = f->blocks[i].length;
129 if (block_size <= 0 || block_size > PAGE_SIZE) {
130 return FLASH_IMG_BAD_LEN;
131 }
132 image_size += block_size;
133 }
134 }
135
136 if (image_size < (256 << 10)) {
137 if (image_size < 2)
138 return FLASH_NO_OP;
139 }
140
141 printk(KERN_INFO "FLASH: flash image with %ld bytes stored for hardware flash on reboot\n", image_size);
142
143 return FLASH_IMG_READY;
144}
145
146static void free_flash_list(struct flash_block_list *f)
147{
148 struct flash_block_list *next;
149 int i;
150
151 while (f) {
152 for (i = 0; i < f->num_blocks; i++)
153 free_page((unsigned long)(f->blocks[i].data));
154 next = f->next;
155 free_page((unsigned long)f);
156 f = next;
157 }
158}
159
160static int rtas_flash_release(struct inode *inode, struct file *file)
161{
162 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
163 struct rtas_update_flash_t *uf;
164
165 uf = (struct rtas_update_flash_t *) dp->data;
166 if (uf->flist) {
167 /* File was opened in write mode for a new flash attempt */
168 /* Clear saved list */
169 if (rtas_firmware_flash_list.next) {
170 free_flash_list(rtas_firmware_flash_list.next);
171 rtas_firmware_flash_list.next = NULL;
172 }
173
174 if (uf->status != FLASH_AUTH)
175 uf->status = flash_list_valid(uf->flist);
176
177 if (uf->status == FLASH_IMG_READY)
178 rtas_firmware_flash_list.next = uf->flist;
179 else
180 free_flash_list(uf->flist);
181
182 uf->flist = NULL;
183 }
184
185 atomic_dec(&dp->count);
186 return 0;
187}
188
189static void get_flash_status_msg(int status, char *buf)
190{
191 char *msg;
192
193 switch (status) {
194 case FLASH_AUTH:
195 msg = "error: this partition does not have service authority\n";
196 break;
197 case FLASH_NO_OP:
198 msg = "info: no firmware image for flash\n";
199 break;
200 case FLASH_IMG_SHORT:
201 msg = "error: flash image short\n";
202 break;
203 case FLASH_IMG_BAD_LEN:
204 msg = "error: internal error bad length\n";
205 break;
206 case FLASH_IMG_NULL_DATA:
207 msg = "error: internal error null data\n";
208 break;
209 case FLASH_IMG_READY:
210 msg = "ready: firmware image ready for flash on reboot\n";
211 break;
212 default:
213 sprintf(buf, "error: unexpected status value %d\n", status);
214 return;
215 }
216
217 strcpy(buf, msg);
218}
219
220/* Reading the proc file will show status (not the firmware contents) */
221static ssize_t rtas_flash_read(struct file *file, char *buf,
222 size_t count, loff_t *ppos)
223{
224 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
225 struct rtas_update_flash_t *uf;
226 char msg[RTAS_MSG_MAXLEN];
227 int msglen;
228
229 uf = (struct rtas_update_flash_t *) dp->data;
230
231 if (!strcmp(dp->name, FIRMWARE_FLASH_NAME)) {
232 get_flash_status_msg(uf->status, msg);
233 } else { /* FIRMWARE_UPDATE_NAME */
234 sprintf(msg, "%d\n", uf->status);
235 }
236 msglen = strlen(msg);
237 if (msglen > count)
238 msglen = count;
239
240 if (ppos && *ppos != 0)
241 return 0; /* be cheap */
242
243 if (!access_ok(VERIFY_WRITE, buf, msglen))
244 return -EINVAL;
245
246 if (copy_to_user(buf, msg, msglen))
247 return -EFAULT;
248
249 if (ppos)
250 *ppos = msglen;
251 return msglen;
252}
253
254/* We could be much more efficient here. But to keep this function
255 * simple we allocate a page to the block list no matter how small the
256 * count is. If the system is low on memory it will be just as well
257 * that we fail....
258 */
259static ssize_t rtas_flash_write(struct file *file, const char *buffer,
260 size_t count, loff_t *off)
261{
262 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
263 struct rtas_update_flash_t *uf;
264 char *p;
265 int next_free;
266 struct flash_block_list *fl;
267
268 uf = (struct rtas_update_flash_t *) dp->data;
269
270 if (uf->status == FLASH_AUTH || count == 0)
271 return count; /* discard data */
272
273 /* In the case that the image is not ready for flashing, the memory
274 * allocated for the block list will be freed upon the release of the
275 * proc file
276 */
277 if (uf->flist == NULL) {
278 uf->flist = (struct flash_block_list *) get_zeroed_page(GFP_KERNEL);
279 if (!uf->flist)
280 return -ENOMEM;
281 }
282
283 fl = uf->flist;
284 while (fl->next)
285 fl = fl->next; /* seek to last block_list for append */
286 next_free = fl->num_blocks;
287 if (next_free == FLASH_BLOCKS_PER_NODE) {
288 /* Need to allocate another block_list */
289 fl->next = (struct flash_block_list *)get_zeroed_page(GFP_KERNEL);
290 if (!fl->next)
291 return -ENOMEM;
292 fl = fl->next;
293 next_free = 0;
294 }
295
296 if (count > PAGE_SIZE)
297 count = PAGE_SIZE;
298 p = (char *)get_zeroed_page(GFP_KERNEL);
299 if (!p)
300 return -ENOMEM;
301
302 if(copy_from_user(p, buffer, count)) {
303 free_page((unsigned long)p);
304 return -EFAULT;
305 }
306 fl->blocks[next_free].data = p;
307 fl->blocks[next_free].length = count;
308 fl->num_blocks++;
309
310 return count;
311}
312
313static int rtas_excl_open(struct inode *inode, struct file *file)
314{
315 struct proc_dir_entry *dp = PDE(inode);
316
317 /* Enforce exclusive open with use count of PDE */
318 spin_lock(&flash_file_open_lock);
319 if (atomic_read(&dp->count) > 1) {
320 spin_unlock(&flash_file_open_lock);
321 return -EBUSY;
322 }
323
324 atomic_inc(&dp->count);
325 spin_unlock(&flash_file_open_lock);
326
327 return 0;
328}
329
330static int rtas_excl_release(struct inode *inode, struct file *file)
331{
332 struct proc_dir_entry *dp = PDE(inode);
333
334 atomic_dec(&dp->count);
335
336 return 0;
337}
338
339static void manage_flash(struct rtas_manage_flash_t *args_buf)
340{
341 unsigned int wait_time;
342 s32 rc;
343
344 while (1) {
345 rc = rtas_call(rtas_token("ibm,manage-flash-image"), 1,
346 1, NULL, args_buf->op);
347 if (rc == RTAS_RC_BUSY)
348 udelay(1);
349 else if (rtas_is_extended_busy(rc)) {
350 wait_time = rtas_extended_busy_delay_time(rc);
351 udelay(wait_time * 1000);
352 } else
353 break;
354 }
355
356 args_buf->status = rc;
357}
358
359static ssize_t manage_flash_read(struct file *file, char *buf,
360 size_t count, loff_t *ppos)
361{
362 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
363 struct rtas_manage_flash_t *args_buf;
364 char msg[RTAS_MSG_MAXLEN];
365 int msglen;
366
367 args_buf = (struct rtas_manage_flash_t *) dp->data;
368 if (args_buf == NULL)
369 return 0;
370
371 msglen = sprintf(msg, "%d\n", args_buf->status);
372 if (msglen > count)
373 msglen = count;
374
375 if (ppos && *ppos != 0)
376 return 0; /* be cheap */
377
378 if (!access_ok(VERIFY_WRITE, buf, msglen))
379 return -EINVAL;
380
381 if (copy_to_user(buf, msg, msglen))
382 return -EFAULT;
383
384 if (ppos)
385 *ppos = msglen;
386 return msglen;
387}
388
389static ssize_t manage_flash_write(struct file *file, const char *buf,
390 size_t count, loff_t *off)
391{
392 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
393 struct rtas_manage_flash_t *args_buf;
394 const char reject_str[] = "0";
395 const char commit_str[] = "1";
396 char stkbuf[10];
397 int op;
398
399 args_buf = (struct rtas_manage_flash_t *) dp->data;
400 if ((args_buf->status == MANAGE_AUTH) || (count == 0))
401 return count;
402
403 op = -1;
404 if (buf) {
405 if (count > 9) count = 9;
406 if (copy_from_user (stkbuf, buf, count)) {
407 return -EFAULT;
408 }
409 if (strncmp(stkbuf, reject_str, strlen(reject_str)) == 0)
410 op = RTAS_REJECT_TMP_IMG;
411 else if (strncmp(stkbuf, commit_str, strlen(commit_str)) == 0)
412 op = RTAS_COMMIT_TMP_IMG;
413 }
414
415 if (op == -1) /* buf is empty, or contains invalid string */
416 return -EINVAL;
417
418 args_buf->op = op;
419 manage_flash(args_buf);
420
421 return count;
422}
423
424static void validate_flash(struct rtas_validate_flash_t *args_buf)
425{
426 int token = rtas_token("ibm,validate-flash-image");
427 unsigned int wait_time;
428 int update_results;
429 s32 rc;
430
431 rc = 0;
432 while(1) {
433 spin_lock(&rtas_data_buf_lock);
434 memcpy(rtas_data_buf, args_buf->buf, VALIDATE_BUF_SIZE);
435 rc = rtas_call(token, 2, 2, &update_results,
436 (u32) __pa(rtas_data_buf), args_buf->buf_size);
437 memcpy(args_buf->buf, rtas_data_buf, VALIDATE_BUF_SIZE);
438 spin_unlock(&rtas_data_buf_lock);
439
440 if (rc == RTAS_RC_BUSY)
441 udelay(1);
442 else if (rtas_is_extended_busy(rc)) {
443 wait_time = rtas_extended_busy_delay_time(rc);
444 udelay(wait_time * 1000);
445 } else
446 break;
447 }
448
449 args_buf->status = rc;
450 args_buf->update_results = update_results;
451}
452
453static int get_validate_flash_msg(struct rtas_validate_flash_t *args_buf,
454 char *msg)
455{
456 int n;
457
458 if (args_buf->status >= VALIDATE_TMP_UPDATE) {
459 n = sprintf(msg, "%d\n", args_buf->update_results);
460 if ((args_buf->update_results >= VALIDATE_CUR_UNKNOWN) ||
461 (args_buf->update_results == VALIDATE_TMP_UPDATE))
462 n += sprintf(msg + n, "%s\n", args_buf->buf);
463 } else {
464 n = sprintf(msg, "%d\n", args_buf->status);
465 }
466 return n;
467}
468
469static ssize_t validate_flash_read(struct file *file, char *buf,
470 size_t count, loff_t *ppos)
471{
472 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
473 struct rtas_validate_flash_t *args_buf;
474 char msg[RTAS_MSG_MAXLEN];
475 int msglen;
476
477 args_buf = (struct rtas_validate_flash_t *) dp->data;
478
479 if (ppos && *ppos != 0)
480 return 0; /* be cheap */
481
482 msglen = get_validate_flash_msg(args_buf, msg);
483 if (msglen > count)
484 msglen = count;
485
486 if (!access_ok(VERIFY_WRITE, buf, msglen))
487 return -EINVAL;
488
489 if (copy_to_user(buf, msg, msglen))
490 return -EFAULT;
491
492 if (ppos)
493 *ppos = msglen;
494 return msglen;
495}
496
497static ssize_t validate_flash_write(struct file *file, const char *buf,
498 size_t count, loff_t *off)
499{
500 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
501 struct rtas_validate_flash_t *args_buf;
502 int rc;
503
504 args_buf = (struct rtas_validate_flash_t *) dp->data;
505
506 if (dp->data == NULL) {
507 dp->data = kmalloc(sizeof(struct rtas_validate_flash_t),
508 GFP_KERNEL);
509 if (dp->data == NULL)
510 return -ENOMEM;
511 }
512
513 /* We are only interested in the first 4K of the
514 * candidate image */
515 if ((*off >= VALIDATE_BUF_SIZE) ||
516 (args_buf->status == VALIDATE_AUTH)) {
517 *off += count;
518 return count;
519 }
520
521 if (*off + count >= VALIDATE_BUF_SIZE) {
522 count = VALIDATE_BUF_SIZE - *off;
523 args_buf->status = VALIDATE_READY;
524 } else {
525 args_buf->status = VALIDATE_INCOMPLETE;
526 }
527
528 if (!access_ok(VERIFY_READ, buf, count)) {
529 rc = -EFAULT;
530 goto done;
531 }
532 if (copy_from_user(args_buf->buf + *off, buf, count)) {
533 rc = -EFAULT;
534 goto done;
535 }
536
537 *off += count;
538 rc = count;
539done:
540 if (rc < 0) {
541 kfree(dp->data);
542 dp->data = NULL;
543 }
544 return rc;
545}
546
547static int validate_flash_release(struct inode *inode, struct file *file)
548{
549 struct proc_dir_entry *dp = PDE(file->f_dentry->d_inode);
550 struct rtas_validate_flash_t *args_buf;
551
552 args_buf = (struct rtas_validate_flash_t *) dp->data;
553
554 if (args_buf->status == VALIDATE_READY) {
555 args_buf->buf_size = VALIDATE_BUF_SIZE;
556 validate_flash(args_buf);
557 }
558
559 /* The matching atomic_inc was in rtas_excl_open() */
560 atomic_dec(&dp->count);
561
562 return 0;
563}
564
565static void remove_flash_pde(struct proc_dir_entry *dp)
566{
567 if (dp) {
568 if (dp->data != NULL)
569 kfree(dp->data);
570 dp->owner = NULL;
571 remove_proc_entry(dp->name, dp->parent);
572 }
573}
574
575static int initialize_flash_pde_data(const char *rtas_call_name,
576 size_t buf_size,
577 struct proc_dir_entry *dp)
578{
579 int *status;
580 int token;
581
582 dp->data = kmalloc(buf_size, GFP_KERNEL);
583 if (dp->data == NULL) {
584 remove_flash_pde(dp);
585 return -ENOMEM;
586 }
587
588 memset(dp->data, 0, buf_size);
589
590 /*
591 * This code assumes that the status int is the first member of the
592 * struct
593 */
594 status = (int *) dp->data;
595 token = rtas_token(rtas_call_name);
596 if (token == RTAS_UNKNOWN_SERVICE)
597 *status = FLASH_AUTH;
598 else
599 *status = FLASH_NO_OP;
600
601 return 0;
602}
603
604static struct proc_dir_entry *create_flash_pde(const char *filename,
605 struct file_operations *fops)
606{
607 struct proc_dir_entry *ent = NULL;
608
609 ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL);
610 if (ent != NULL) {
611 ent->nlink = 1;
612 ent->proc_fops = fops;
613 ent->owner = THIS_MODULE;
614 }
615
616 return ent;
617}
618
619static struct file_operations rtas_flash_operations = {
620 .read = rtas_flash_read,
621 .write = rtas_flash_write,
622 .open = rtas_excl_open,
623 .release = rtas_flash_release,
624};
625
626static struct file_operations manage_flash_operations = {
627 .read = manage_flash_read,
628 .write = manage_flash_write,
629 .open = rtas_excl_open,
630 .release = rtas_excl_release,
631};
632
633static struct file_operations validate_flash_operations = {
634 .read = validate_flash_read,
635 .write = validate_flash_write,
636 .open = rtas_excl_open,
637 .release = validate_flash_release,
638};
639
640int __init rtas_flash_init(void)
641{
642 int rc;
643
644 if (rtas_token("ibm,update-flash-64-and-reboot") ==
645 RTAS_UNKNOWN_SERVICE) {
646 printk(KERN_ERR "rtas_flash: no firmware flash support\n");
647 return 1;
648 }
649
650 firmware_flash_pde = create_flash_pde("ppc64/rtas/"
651 FIRMWARE_FLASH_NAME,
652 &rtas_flash_operations);
653 if (firmware_flash_pde == NULL) {
654 rc = -ENOMEM;
655 goto cleanup;
656 }
657
658 rc = initialize_flash_pde_data("ibm,update-flash-64-and-reboot",
659 sizeof(struct rtas_update_flash_t),
660 firmware_flash_pde);
661 if (rc != 0)
662 goto cleanup;
663
664 firmware_update_pde = create_flash_pde("ppc64/rtas/"
665 FIRMWARE_UPDATE_NAME,
666 &rtas_flash_operations);
667 if (firmware_update_pde == NULL) {
668 rc = -ENOMEM;
669 goto cleanup;
670 }
671
672 rc = initialize_flash_pde_data("ibm,update-flash-64-and-reboot",
673 sizeof(struct rtas_update_flash_t),
674 firmware_update_pde);
675 if (rc != 0)
676 goto cleanup;
677
678 validate_pde = create_flash_pde("ppc64/rtas/" VALIDATE_FLASH_NAME,
679 &validate_flash_operations);
680 if (validate_pde == NULL) {
681 rc = -ENOMEM;
682 goto cleanup;
683 }
684
685 rc = initialize_flash_pde_data("ibm,validate-flash-image",
686 sizeof(struct rtas_validate_flash_t),
687 validate_pde);
688 if (rc != 0)
689 goto cleanup;
690
691 manage_pde = create_flash_pde("ppc64/rtas/" MANAGE_FLASH_NAME,
692 &manage_flash_operations);
693 if (manage_pde == NULL) {
694 rc = -ENOMEM;
695 goto cleanup;
696 }
697
698 rc = initialize_flash_pde_data("ibm,manage-flash-image",
699 sizeof(struct rtas_manage_flash_t),
700 manage_pde);
701 if (rc != 0)
702 goto cleanup;
703
704 return 0;
705
706cleanup:
707 remove_flash_pde(firmware_flash_pde);
708 remove_flash_pde(firmware_update_pde);
709 remove_flash_pde(validate_pde);
710 remove_flash_pde(manage_pde);
711
712 return rc;
713}
714
715void __exit rtas_flash_cleanup(void)
716{
717 remove_flash_pde(firmware_flash_pde);
718 remove_flash_pde(firmware_update_pde);
719 remove_flash_pde(validate_pde);
720 remove_flash_pde(manage_pde);
721}
722
723module_init(rtas_flash_init);
724module_exit(rtas_flash_cleanup);
725MODULE_LICENSE("GPL");