*/
 static void mtd_release(struct device *dev)
 {
-       dev_t index = MTD_DEVT(dev_to_mtd(dev)->index);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
+       dev_t index = MTD_DEVT(mtd->index);
 
        /* remove /dev/mtdXro node if needed */
        if (index)
 
 static int mtd_cls_suspend(struct device *dev, pm_message_t state)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        if (mtd && mtd->suspend)
                return mtd_suspend(mtd);
 
 static int mtd_cls_resume(struct device *dev)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
        
        if (mtd && mtd->resume)
                mtd_resume(mtd);
 static ssize_t mtd_type_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
        char *type;
 
        switch (mtd->type) {
 static ssize_t mtd_flags_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)mtd->flags);
 
 static ssize_t mtd_size_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "%llu\n",
                (unsigned long long)mtd->size);
 static ssize_t mtd_erasesize_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->erasesize);
 
 static ssize_t mtd_writesize_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->writesize);
 
 static ssize_t mtd_subpagesize_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
        unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
 
        return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
 static ssize_t mtd_oobsize_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "%lu\n", (unsigned long)mtd->oobsize);
 
 static ssize_t mtd_numeraseregions_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "%u\n", mtd->numeraseregions);
 
 static ssize_t mtd_name_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct mtd_info *mtd = dev_to_mtd(dev);
+       struct mtd_info *mtd = dev_get_drvdata(dev);
 
        return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name);