[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>
This commit is contained in:
@@ -23,8 +23,15 @@
|
|||||||
|
|
||||||
#include "mtdcore.h"
|
#include "mtdcore.h"
|
||||||
|
|
||||||
|
static int mtd_cls_suspend(struct device *dev, pm_message_t state);
|
||||||
|
static int mtd_cls_resume(struct device *dev);
|
||||||
|
|
||||||
static struct class *mtd_class;
|
static struct class mtd_class = {
|
||||||
|
.name = "mtd",
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.suspend = mtd_cls_suspend,
|
||||||
|
.resume = mtd_cls_resume,
|
||||||
|
};
|
||||||
|
|
||||||
/* These are exported solely for the purpose of mtd_blkdevs.c. You
|
/* These are exported solely for the purpose of mtd_blkdevs.c. You
|
||||||
should not use them for _anything_ else */
|
should not use them for _anything_ else */
|
||||||
@@ -52,7 +59,26 @@ static void mtd_release(struct device *dev)
|
|||||||
|
|
||||||
/* remove /dev/mtdXro node if needed */
|
/* remove /dev/mtdXro node if needed */
|
||||||
if (index)
|
if (index)
|
||||||
device_destroy(mtd_class, index + 1);
|
device_destroy(&mtd_class, index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mtd_cls_suspend(struct device *dev, pm_message_t state)
|
||||||
|
{
|
||||||
|
struct mtd_info *mtd = dev_to_mtd(dev);
|
||||||
|
|
||||||
|
if (mtd->suspend)
|
||||||
|
return mtd->suspend(mtd);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mtd_cls_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
struct mtd_info *mtd = dev_to_mtd(dev);
|
||||||
|
|
||||||
|
if (mtd->resume)
|
||||||
|
mtd->resume(mtd);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t mtd_type_show(struct device *dev,
|
static ssize_t mtd_type_show(struct device *dev,
|
||||||
@@ -269,7 +295,7 @@ int add_mtd_device(struct mtd_info *mtd)
|
|||||||
* physical device.
|
* physical device.
|
||||||
*/
|
*/
|
||||||
mtd->dev.type = &mtd_devtype;
|
mtd->dev.type = &mtd_devtype;
|
||||||
mtd->dev.class = mtd_class;
|
mtd->dev.class = &mtd_class;
|
||||||
mtd->dev.devt = MTD_DEVT(i);
|
mtd->dev.devt = MTD_DEVT(i);
|
||||||
dev_set_name(&mtd->dev, "mtd%d", i);
|
dev_set_name(&mtd->dev, "mtd%d", i);
|
||||||
if (device_register(&mtd->dev) != 0) {
|
if (device_register(&mtd->dev) != 0) {
|
||||||
@@ -278,7 +304,7 @@ int add_mtd_device(struct mtd_info *mtd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (MTD_DEVT(i))
|
if (MTD_DEVT(i))
|
||||||
device_create(mtd_class, mtd->dev.parent,
|
device_create(&mtd_class, mtd->dev.parent,
|
||||||
MTD_DEVT(i) + 1,
|
MTD_DEVT(i) + 1,
|
||||||
NULL, "mtd%dro", i);
|
NULL, "mtd%dro", i);
|
||||||
|
|
||||||
@@ -604,11 +630,12 @@ done:
|
|||||||
|
|
||||||
static int __init init_mtd(void)
|
static int __init init_mtd(void)
|
||||||
{
|
{
|
||||||
mtd_class = class_create(THIS_MODULE, "mtd");
|
int ret;
|
||||||
|
ret = class_register(&mtd_class);
|
||||||
|
|
||||||
if (IS_ERR(mtd_class)) {
|
if (ret) {
|
||||||
pr_err("Error creating mtd class.\n");
|
pr_err("Error registering mtd class: %d\n", ret);
|
||||||
return PTR_ERR(mtd_class);
|
return ret;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
|
if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
|
||||||
@@ -623,7 +650,7 @@ static void __exit cleanup_mtd(void)
|
|||||||
if (proc_mtd)
|
if (proc_mtd)
|
||||||
remove_proc_entry( "mtd", NULL);
|
remove_proc_entry( "mtd", NULL);
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
class_destroy(mtd_class);
|
class_unregister(&mtd_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(init_mtd);
|
module_init(init_mtd);
|
||||||
|
Reference in New Issue
Block a user