Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

+36 -9
+36 -9
drivers/mtd/mtdcore.c
··· 23 23 24 24 #include "mtdcore.h" 25 25 26 + static int mtd_cls_suspend(struct device *dev, pm_message_t state); 27 + static int mtd_cls_resume(struct device *dev); 26 28 27 - static struct class *mtd_class; 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 36 /* These are exported solely for the purpose of mtd_blkdevs.c. You 30 37 should not use them for _anything_ else */ ··· 59 52 60 53 /* remove /dev/mtdXro node if needed */ 61 54 if (index) 62 - device_destroy(mtd_class, index + 1); 55 + device_destroy(&mtd_class, index + 1); 56 + } 57 + 58 + static int mtd_cls_suspend(struct device *dev, pm_message_t state) 59 + { 60 + struct mtd_info *mtd = dev_to_mtd(dev); 61 + 62 + if (mtd->suspend) 63 + return mtd->suspend(mtd); 64 + else 65 + return 0; 66 + } 67 + 68 + static int mtd_cls_resume(struct device *dev) 69 + { 70 + struct mtd_info *mtd = dev_to_mtd(dev); 71 + 72 + if (mtd->resume) 73 + mtd->resume(mtd); 74 + return 0; 63 75 } 64 76 65 77 static ssize_t mtd_type_show(struct device *dev, ··· 295 269 * physical device. 296 270 */ 297 271 mtd->dev.type = &mtd_devtype; 298 - mtd->dev.class = mtd_class; 272 + mtd->dev.class = &mtd_class; 299 273 mtd->dev.devt = MTD_DEVT(i); 300 274 dev_set_name(&mtd->dev, "mtd%d", i); 301 275 if (device_register(&mtd->dev) != 0) { ··· 304 278 } 305 279 306 280 if (MTD_DEVT(i)) 307 - device_create(mtd_class, mtd->dev.parent, 281 + device_create(&mtd_class, mtd->dev.parent, 308 282 MTD_DEVT(i) + 1, 309 283 NULL, "mtd%dro", i); 310 284 ··· 630 604 631 605 static int __init init_mtd(void) 632 606 { 633 - mtd_class = class_create(THIS_MODULE, "mtd"); 607 + int ret; 608 + ret = class_register(&mtd_class); 634 609 635 - if (IS_ERR(mtd_class)) { 636 - pr_err("Error creating mtd class.\n"); 637 - return PTR_ERR(mtd_class); 610 + if (ret) { 611 + pr_err("Error registering mtd class: %d\n", ret); 612 + return ret; 638 613 } 639 614 #ifdef CONFIG_PROC_FS 640 615 if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) ··· 650 623 if (proc_mtd) 651 624 remove_proc_entry( "mtd", NULL); 652 625 #endif /* CONFIG_PROC_FS */ 653 - class_destroy(mtd_class); 626 + class_unregister(&mtd_class); 654 627 } 655 628 656 629 module_init(init_mtd);