diff options
author | Aya Mahfouz <mahfouz.saif.elyazal@gmail.com> | 2015-04-02 19:59:15 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-04-03 11:18:13 +0200 |
commit | 4ca1b8fbe609b7c52aeaa78a5f4678efcc9b8d73 (patch) | |
tree | 47c1be0b85d865bc37f2210a5640d5cce11459ad /drivers/staging/lustre | |
parent | a18dd4702c923167e98acbb0c9d94463ce19546f (diff) | |
download | op-kernel-dev-4ca1b8fbe609b7c52aeaa78a5f4678efcc9b8d73.zip op-kernel-dev-4ca1b8fbe609b7c52aeaa78a5f4678efcc9b8d73.tar.gz |
staging: lustre: include: replace OBD_CHECK_DEV by obd_check_dev
Static inline functions are preferred over macros. Hence, the function
obd_check_dev was introduced. obd_check_dev replaces the macro
OBD_CHECK_DEV. All functions that call obd_check_dev store the return
values and return them if they represent an error code.
Some of the changes were carried out manually while others were done
using coccinelle.
Signed-off-by: Aya Mahfouz <mahfouz.saif.elyazal@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre')
-rw-r--r-- | drivers/staging/lustre/lustre/include/obd_class.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 5314f6f..9167164 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -341,6 +341,15 @@ do { \ } \ } while (0) +static inline int obd_check_dev(struct obd_device *obd) +{ + if (!obd) { + CERROR("NULL device\n"); + return -ENODEV; + } + return 0; +} + /* ensure obd_setup and !obd_stopping */ #define OBD_CHECK_DEV_ACTIVE(obd) \ do { \ @@ -594,7 +603,9 @@ static inline int obd_precleanup(struct obd_device *obd, int rc; DECLARE_LU_VARS(ldt, d); - OBD_CHECK_DEV(obd); + rc = obd_check_dev(obd); + if (rc) + return rc; ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; if (ldt != NULL && d != NULL) { @@ -620,7 +631,9 @@ static inline int obd_cleanup(struct obd_device *obd) int rc; DECLARE_LU_VARS(ldt, d); - OBD_CHECK_DEV(obd); + rc = obd_check_dev(obd); + if (rc) + return rc; ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; @@ -668,7 +681,9 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) int rc; DECLARE_LU_VARS(ldt, d); - OBD_CHECK_DEV(obd); + rc = obd_check_dev(obd); + if (rc) + return rc; obd->obd_process_conf = 1; ldt = obd->obd_type->typ_lu; @@ -1280,7 +1295,9 @@ static inline int obd_notify(struct obd_device *obd, { int rc; - OBD_CHECK_DEV(obd); + rc = obd_check_dev(obd); + if (rc) + return rc; /* the check for async_recov is a complete hack - I'm hereby overloading the meaning to also mean "this was called from @@ -1381,7 +1398,11 @@ static inline int obd_health_check(const struct lu_env *env, static inline int obd_register_observer(struct obd_device *obd, struct obd_device *observer) { - OBD_CHECK_DEV(obd); + int rc; + + rc = obd_check_dev(obd); + if (rc) + return rc; down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { up_write(&obd->obd_observer_link_sem); |