Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 153766
b: refs/heads/master
c: 15bce40
h: refs/heads/master
v: v3
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 26, 2009
1 parent 02f8e19 commit 6cefbd5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d694846b6b1c92bcc946b6ffb0a5ea25d5df1014
refs/heads/master: 15bce40cb3133bcc07d548013df97e4653d363c1
47 changes: 37 additions & 10 deletions trunk/drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@

#include "mtdcore.h"


static struct class *mtd_class;
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 = {
.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
should not use them for _anything_ else */
Expand Down Expand Up @@ -52,7 +59,26 @@ static void mtd_release(struct device *dev)

/* remove /dev/mtdXro node if needed */
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,
Expand Down Expand Up @@ -269,7 +295,7 @@ int add_mtd_device(struct mtd_info *mtd)
* physical device.
*/
mtd->dev.type = &mtd_devtype;
mtd->dev.class = mtd_class;
mtd->dev.class = &mtd_class;
mtd->dev.devt = MTD_DEVT(i);
dev_set_name(&mtd->dev, "mtd%d", i);
if (device_register(&mtd->dev) != 0) {
Expand All @@ -278,7 +304,7 @@ int add_mtd_device(struct mtd_info *mtd)
}

if (MTD_DEVT(i))
device_create(mtd_class, mtd->dev.parent,
device_create(&mtd_class, mtd->dev.parent,
MTD_DEVT(i) + 1,
NULL, "mtd%dro", i);

Expand Down Expand Up @@ -604,11 +630,12 @@ static int mtd_read_proc (char *page, char **start, off_t off, int count,

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)) {
pr_err("Error creating mtd class.\n");
return PTR_ERR(mtd_class);
if (ret) {
pr_err("Error registering mtd class: %d\n", ret);
return ret;
}
#ifdef CONFIG_PROC_FS
if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
Expand All @@ -623,7 +650,7 @@ static void __exit cleanup_mtd(void)
if (proc_mtd)
remove_proc_entry( "mtd", NULL);
#endif /* CONFIG_PROC_FS */
class_destroy(mtd_class);
class_unregister(&mtd_class);
}

module_init(init_mtd);
Expand Down

0 comments on commit 6cefbd5

Please sign in to comment.