X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmtd%2Fmtdcore.c;h=6c2645e2837191e57d539222c92d68b3debac806;hb=68fbda7de07e56eb90dd6e58a162527411b388b1;hp=f11f55f02413332dcb8aa31e02a00ab38a1e9603;hpb=9fe912cea32aec18f860c95e8574410b5892481b;p=linux-2.6 diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index f11f55f024..6c2645e283 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -23,6 +22,8 @@ #include +#include "mtdcore.h" + /* These are exported solely for the purpose of mtd_blkdevs.c. You should not use them for _anything_ else */ DEFINE_MUTEX(mtd_table_mutex); @@ -193,14 +194,14 @@ int unregister_mtd_user (struct mtd_notifier *old) * Given a number and NULL address, return the num'th entry in the device * table, if any. Given an address and num == -1, search the device table * for a device with that address and return if it's still present. Given - * both, return the num'th driver only if its address matches. Return NULL - * if not. + * both, return the num'th driver only if its address matches. Return + * error code if not. */ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) { struct mtd_info *ret = NULL; - int i; + int i, err = -ENODEV; mutex_lock(&mtd_table_mutex); @@ -217,22 +218,24 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) if (!ret) goto out_unlock; - if (!try_module_get(ret->owner)) { - ret = NULL; + if (!try_module_get(ret->owner)) goto out_unlock; - } - if (ret->get_device && ret->get_device(ret)) { - module_put(ret->owner); - ret = NULL; - goto out_unlock; + if (ret->get_device) { + err = ret->get_device(ret); + if (err) + goto out_put; } ret->usecount++; + mutex_unlock(&mtd_table_mutex); + return ret; +out_put: + module_put(ret->owner); out_unlock: mutex_unlock(&mtd_table_mutex); - return ret; + return ERR_PTR(err); } /** @@ -296,7 +299,7 @@ void put_mtd_device(struct mtd_info *mtd) } /* default_mtd_writev - default mtd writev method for MTD devices that - * dont implement their own + * don't implement their own */ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, @@ -324,14 +327,14 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, return ret; } -EXPORT_SYMBOL(add_mtd_device); -EXPORT_SYMBOL(del_mtd_device); -EXPORT_SYMBOL(get_mtd_device); -EXPORT_SYMBOL(get_mtd_device_nm); -EXPORT_SYMBOL(put_mtd_device); -EXPORT_SYMBOL(register_mtd_user); -EXPORT_SYMBOL(unregister_mtd_user); -EXPORT_SYMBOL(default_mtd_writev); +EXPORT_SYMBOL_GPL(add_mtd_device); +EXPORT_SYMBOL_GPL(del_mtd_device); +EXPORT_SYMBOL_GPL(get_mtd_device); +EXPORT_SYMBOL_GPL(get_mtd_device_nm); +EXPORT_SYMBOL_GPL(put_mtd_device); +EXPORT_SYMBOL_GPL(register_mtd_user); +EXPORT_SYMBOL_GPL(unregister_mtd_user); +EXPORT_SYMBOL_GPL(default_mtd_writev); #ifdef CONFIG_PROC_FS