diff options
Diffstat (limited to 'drivers/misc/mei/client.c')
-rw-r--r-- | drivers/misc/mei/client.c | 88 |
1 files changed, 43 insertions, 45 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c index e263c0713a6d..624bf0182a50 100644 --- a/drivers/misc/mei/client.c +++ b/drivers/misc/mei/client.c @@ -321,6 +321,47 @@ static inline bool mei_cl_cmp_id(const struct mei_cl *cl1, } /** + * mei_io_cb_free - free mei_cb_private related memory + * + * @cb: mei callback struct + */ +void mei_io_cb_free(struct mei_cl_cb *cb) +{ + if (cb == NULL) + return; + + list_del(&cb->list); + kfree(cb->buf.data); + kfree(cb); +} + +/** + * mei_io_cb_init - allocate and initialize io callback + * + * @cl: mei client + * @type: operation type + * @fp: pointer to file structure + * + * Return: mei_cl_cb pointer or NULL; + */ +struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, enum mei_cb_file_ops type, + struct file *fp) +{ + struct mei_cl_cb *cb; + + cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL); + if (!cb) + return NULL; + + INIT_LIST_HEAD(&cb->list); + cb->file_object = fp; + cb->cl = cl; + cb->buf_idx = 0; + cb->fop_type = type; + return cb; +} + +/** * __mei_io_list_flush - removes and frees cbs belonging to cl. * * @list: an instance of our list structure @@ -330,13 +371,12 @@ static inline bool mei_cl_cmp_id(const struct mei_cl *cl1, static void __mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl, bool free) { - struct mei_cl_cb *cb; - struct mei_cl_cb *next; + struct mei_cl_cb *cb, *next; /* enable removing everything if no cl is specified */ list_for_each_entry_safe(cb, next, &list->list, list) { if (!cl || mei_cl_cmp_id(cl, cb->cl)) { - list_del(&cb->list); + list_del_init(&cb->list); if (free) mei_io_cb_free(cb); } @@ -354,7 +394,6 @@ void mei_io_list_flush(struct mei_cl_cb *list, struct mei_cl *cl) __mei_io_list_flush(list, cl, false); } - /** * mei_io_list_free - removes cb belonging to cl and free them * @@ -367,47 +406,6 @@ static inline void mei_io_list_free(struct mei_cl_cb *list, struct mei_cl *cl) } /** - * mei_io_cb_free - free mei_cb_private related memory - * - * @cb: mei callback struct - */ -void mei_io_cb_free(struct mei_cl_cb *cb) -{ - if (cb == NULL) - return; - - kfree(cb->buf.data); - kfree(cb); -} - -/** - * mei_io_cb_init - allocate and initialize io callback - * - * @cl: mei client - * @type: operation type - * @fp: pointer to file structure - * - * Return: mei_cl_cb pointer or NULL; - */ -struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl, enum mei_cb_file_ops type, - struct file *fp) -{ - struct mei_cl_cb *cb; - - cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL); - if (!cb) - return NULL; - - mei_io_list_init(cb); - - cb->file_object = fp; - cb->cl = cl; - cb->buf_idx = 0; - cb->fop_type = type; - return cb; -} - -/** * mei_io_cb_alloc_buf - allocate callback buffer * * @cb: io callback structure |