diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2009-04-05 10:40:58 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-05-26 11:45:43 -0400 |
commit | 15bce40cb3133bcc07d548013df97e4653d363c1 (patch) | |
tree | ff37c3c3ee573d2d2d0e16d69b34055928dc1bcc /drivers | |
parent | d694846b6b1c92bcc946b6ffb0a5ea25d5df1014 (diff) |
[MTD] Restore suspend/resume support for mtd devices
This is intended to suspend/resume the _chip_, while we leave board
drivers to handle their own suspend/resume for the controller.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/mtdcore.c | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index bccb4b1ffc46..fac54a3fa3f1 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -23,8 +23,15 @@ | |||
23 | 23 | ||
24 | #include "mtdcore.h" | 24 | #include "mtdcore.h" |
25 | 25 | ||
26 | 26 | static int mtd_cls_suspend(struct device *dev, pm_message_t state); | |
27 | static struct class *mtd_class; | 27 | static int mtd_cls_resume(struct device *dev); |
28 | |||
29 | static struct class mtd_class = { | ||
30 | .name = "mtd", | ||
31 | .owner = THIS_MODULE, | ||
32 | .suspend = mtd_cls_suspend, | ||
33 | .resume = mtd_cls_resume, | ||
34 | }; | ||
28 | 35 | ||
29 | /* These are exported solely for the purpose of mtd_blkdevs.c. You | 36 | /* These are exported solely for the purpose of mtd_blkdevs.c. You |
30 | should not use them for _anything_ else */ | 37 | should not use them for _anything_ else */ |
@@ -52,7 +59,26 @@ static void mtd_release(struct device *dev) | |||
52 | 59 | ||
53 | /* remove /dev/mtdXro node if needed */ | 60 | /* remove /dev/mtdXro node if needed */ |
54 | if (index) | 61 | if (index) |
55 | device_destroy(mtd_class, index + 1); | 62 | device_destroy(&mtd_class, index + 1); |
63 | } | ||
64 | |||
65 | static int mtd_cls_suspend(struct device *dev, pm_message_t state) | ||
66 | { | ||
67 | struct mtd_info *mtd = dev_to_mtd(dev); | ||
68 | |||
69 | if (mtd->suspend) | ||
70 | return mtd->suspend(mtd); | ||
71 | else | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int mtd_cls_resume(struct device *dev) | ||
76 | { | ||
77 | struct mtd_info *mtd = dev_to_mtd(dev); | ||
78 | |||
79 | if (mtd->resume) | ||
80 | mtd->resume(mtd); | ||
81 | return 0; | ||
56 | } | 82 | } |
57 | 83 | ||
58 | static ssize_t mtd_type_show(struct device *dev, | 84 | static ssize_t mtd_type_show(struct device *dev, |
@@ -269,7 +295,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
269 | * physical device. | 295 | * physical device. |
270 | */ | 296 | */ |
271 | mtd->dev.type = &mtd_devtype; | 297 | mtd->dev.type = &mtd_devtype; |
272 | mtd->dev.class = mtd_class; | 298 | mtd->dev.class = &mtd_class; |
273 | mtd->dev.devt = MTD_DEVT(i); | 299 | mtd->dev.devt = MTD_DEVT(i); |
274 | dev_set_name(&mtd->dev, "mtd%d", i); | 300 | dev_set_name(&mtd->dev, "mtd%d", i); |
275 | if (device_register(&mtd->dev) != 0) { | 301 | if (device_register(&mtd->dev) != 0) { |
@@ -278,7 +304,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
278 | } | 304 | } |
279 | 305 | ||
280 | if (MTD_DEVT(i)) | 306 | if (MTD_DEVT(i)) |
281 | device_create(mtd_class, mtd->dev.parent, | 307 | device_create(&mtd_class, mtd->dev.parent, |
282 | MTD_DEVT(i) + 1, | 308 | MTD_DEVT(i) + 1, |
283 | NULL, "mtd%dro", i); | 309 | NULL, "mtd%dro", i); |
284 | 310 | ||
@@ -604,11 +630,12 @@ done: | |||
604 | 630 | ||
605 | static int __init init_mtd(void) | 631 | static int __init init_mtd(void) |
606 | { | 632 | { |
607 | mtd_class = class_create(THIS_MODULE, "mtd"); | 633 | int ret; |
634 | ret = class_register(&mtd_class); | ||
608 | 635 | ||
609 | if (IS_ERR(mtd_class)) { | 636 | if (ret) { |
610 | pr_err("Error creating mtd class.\n"); | 637 | pr_err("Error registering mtd class: %d\n", ret); |
611 | return PTR_ERR(mtd_class); | 638 | return ret; |
612 | } | 639 | } |
613 | #ifdef CONFIG_PROC_FS | 640 | #ifdef CONFIG_PROC_FS |
614 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) | 641 | if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) |
@@ -623,7 +650,7 @@ static void __exit cleanup_mtd(void) | |||
623 | if (proc_mtd) | 650 | if (proc_mtd) |
624 | remove_proc_entry( "mtd", NULL); | 651 | remove_proc_entry( "mtd", NULL); |
625 | #endif /* CONFIG_PROC_FS */ | 652 | #endif /* CONFIG_PROC_FS */ |
626 | class_destroy(mtd_class); | 653 | class_unregister(&mtd_class); |
627 | } | 654 | } |
628 | 655 | ||
629 | module_init(init_mtd); | 656 | module_init(init_mtd); |