[MTD] return error code from get_mtd_device()

get_mtd_device() returns NULL in case of any failure. Teach it to return an
error code instead. Fix all users as well.

Signed-off-by: Artem Bityutskiy <dedekind@infradead.org>
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 7c4adc6..3013d08 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -7,6 +7,7 @@
 
 #include <linux/device.h>
 #include <linux/fs.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -100,8 +101,8 @@
 
 	mtd = get_mtd_device(NULL, devnum);
 
-	if (!mtd)
-		return -ENODEV;
+	if (IS_ERR(mtd))
+		return PTR_ERR(mtd);
 
 	if (MTD_ABSENT == mtd->type) {
 		put_mtd_device(mtd);