Commit 7106a976 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/uverbs: Make write() handlers return 0 on success

Currently they return the command length, while all other handlers return
0. This makes the write path closer to the write_ex and ioctl path.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent 8313c10f
...@@ -245,13 +245,11 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj, ...@@ -245,13 +245,11 @@ struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
} }
/* /*
* Does both uobj_get_destroy() and uobj_put_destroy(). Returns success_res * Does both uobj_get_destroy() and uobj_put_destroy(). Returns 0 on success
* on success (negative errno on failure). For use by callers that do not need * (negative errno on failure). For use by callers that do not need the uobj.
* the uobj.
*/ */
int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id, int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
const struct uverbs_attr_bundle *attrs, const struct uverbs_attr_bundle *attrs)
int success_res)
{ {
struct ib_uobject *uobj; struct ib_uobject *uobj;
...@@ -260,7 +258,7 @@ int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id, ...@@ -260,7 +258,7 @@ int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
return PTR_ERR(uobj); return PTR_ERR(uobj);
rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE);
return success_res; return 0;
} }
/* alloc_uobj must be undone by uverbs_destroy_uobject() */ /* alloc_uobj must be undone by uverbs_destroy_uobject() */
......
...@@ -137,8 +137,8 @@ struct uverbs_api_ioctl_method { ...@@ -137,8 +137,8 @@ struct uverbs_api_ioctl_method {
}; };
struct uverbs_api_write_method { struct uverbs_api_write_method {
ssize_t (*handler)(struct uverbs_attr_bundle *attrs, int (*handler)(struct uverbs_attr_bundle *attrs, const char __user *buf,
const char __user *buf, int in_len, int out_len); int in_len, int out_len);
int (*handler_ex)(struct uverbs_attr_bundle *attrs, int (*handler_ex)(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *uhw); struct ib_udata *ucore, struct ib_udata *uhw);
u8 disabled:1; u8 disabled:1;
......
This diff is collapsed.
...@@ -688,11 +688,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, ...@@ -688,11 +688,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
ex_hdr.provider_out_words * 8); ex_hdr.provider_out_words * 8);
ret = method_elm->handler_ex(&bundle, &ucore, &uhw); ret = method_elm->handler_ex(&bundle, &ucore, &uhw);
ret = (ret) ? : count;
} }
srcu_read_unlock(&file->device->disassociate_srcu, srcu_key); srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
return ret; return (ret) ? : count;
} }
static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma) static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
......
...@@ -8,9 +8,8 @@ ...@@ -8,9 +8,8 @@
#include "rdma_core.h" #include "rdma_core.h"
#include "uverbs.h" #include "uverbs.h"
static ssize_t ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs, static int ib_uverbs_notsupp(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len, int out_len)
int out_len)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
......
...@@ -368,9 +368,9 @@ struct uapi_definition { ...@@ -368,9 +368,9 @@ struct uapi_definition {
union { union {
bool (*func_is_supported)(struct ib_device *device); bool (*func_is_supported)(struct ib_device *device);
ssize_t (*func_write)(struct uverbs_attr_bundle *attrs, int (*func_write)(struct uverbs_attr_bundle *attrs,
const char __user *buf, int in_len, const char __user *buf, int in_len,
int out_len); int out_len);
int (*func_write_ex)(struct uverbs_attr_bundle *attrs, int (*func_write_ex)(struct uverbs_attr_bundle *attrs,
struct ib_udata *ucore, struct ib_udata *ucore,
struct ib_udata *uhw); struct ib_udata *uhw);
......
...@@ -72,11 +72,10 @@ static inline void *_uobj_get_obj_read(struct ib_uobject *uobj) ...@@ -72,11 +72,10 @@ static inline void *_uobj_get_obj_read(struct ib_uobject *uobj)
_uobj_check_id(_id), UVERBS_LOOKUP_WRITE) _uobj_check_id(_id), UVERBS_LOOKUP_WRITE)
int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id, int __uobj_perform_destroy(const struct uverbs_api_object *obj, u32 id,
const struct uverbs_attr_bundle *attrs, const struct uverbs_attr_bundle *attrs);
int success_res); #define uobj_perform_destroy(_type, _id, _attrs) \
#define uobj_perform_destroy(_type, _id, _attrs, _success_res) \
__uobj_perform_destroy(uobj_get_type(_attrs, _type), \ __uobj_perform_destroy(uobj_get_type(_attrs, _type), \
_uobj_check_id(_id), _attrs, _success_res) _uobj_check_id(_id), _attrs)
struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj, struct ib_uobject *__uobj_get_destroy(const struct uverbs_api_object *obj,
u32 id, u32 id,
...@@ -104,14 +103,13 @@ static inline void uobj_put_write(struct ib_uobject *uobj) ...@@ -104,14 +103,13 @@ static inline void uobj_put_write(struct ib_uobject *uobj)
rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE); rdma_lookup_put_uobject(uobj, UVERBS_LOOKUP_WRITE);
} }
static inline int __must_check uobj_alloc_commit(struct ib_uobject *uobj, static inline int __must_check uobj_alloc_commit(struct ib_uobject *uobj)
int success_res)
{ {
int ret = rdma_alloc_commit_uobject(uobj); int ret = rdma_alloc_commit_uobject(uobj);
if (ret) if (ret)
return ret; return ret;
return success_res; return 0;
} }
static inline void uobj_alloc_abort(struct ib_uobject *uobj) static inline void uobj_alloc_abort(struct ib_uobject *uobj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment