diff options
author | NeilBrown <neilb@suse.com> | 2018-03-29 15:26:48 +1100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-23 15:16:58 +0200 |
commit | 05e6557b8ed833546ee2b66ce6b58fecf09f439e (patch) | |
tree | a2cd87c97111677ec5a30d5f82260482c1d64f9f /drivers/staging/lustre/lustre/llite/vvp_internal.h | |
parent | 93aa2c2a5091bd47819a3ead4af70fb57fda5065 (diff) |
staging: lustre: add container_of_safe()
Luster has a container_of0() function which is similar to
container_of() but passes an IS_ERR_OR_NULL() pointer through
unchanged.
This could be generally useful: bcache at last has a similar function.
Naming is hard, but the precedent set by hlist_entry_safe() suggests
a _safe suffix might be most consistent.
So add container_of_safe() to kernel.h, and replace all occurrences of
container_of0() with one of
- list_first_entry, list_next_entry, when that is a better fit,
- container_of(), when the pointer is used as a validpointer in
surrounding code,
- container_of_safe() when there is no obviously better alternative.
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lustre/llite/vvp_internal.h')
-rw-r--r-- | drivers/staging/lustre/lustre/llite/vvp_internal.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index 02ea5161d635..7d3abb43584a 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -263,22 +263,22 @@ static inline struct lu_device *vvp2lu_dev(struct vvp_device *vdv) static inline struct vvp_device *lu2vvp_dev(const struct lu_device *d) { - return container_of0(d, struct vvp_device, vdv_cl.cd_lu_dev); + return container_of_safe(d, struct vvp_device, vdv_cl.cd_lu_dev); } static inline struct vvp_device *cl2vvp_dev(const struct cl_device *d) { - return container_of0(d, struct vvp_device, vdv_cl); + return container_of_safe(d, struct vvp_device, vdv_cl); } static inline struct vvp_object *cl2vvp(const struct cl_object *obj) { - return container_of0(obj, struct vvp_object, vob_cl); + return container_of_safe(obj, struct vvp_object, vob_cl); } static inline struct vvp_object *lu2vvp(const struct lu_object *obj) { - return container_of0(obj, struct vvp_object, vob_cl.co_lu); + return container_of_safe(obj, struct vvp_object, vob_cl.co_lu); } static inline struct inode *vvp_object_inode(const struct cl_object *obj) |