Commit 198dd267 authored by Julian Andres Klode's avatar Julian Andres Klode Committed by Greg Kroah-Hartman

staging: nvec: Export nvec_msg_free() to clients

Client code wishing to make use of nvec_write_sync() must
have a way to free the returned pointer, otherwise we run
out of poool memory fairly soon.
Signed-off-by: default avatarJulian Andres Klode <jak@jak-linux.org>
Acked-by: default avatarMarc Dietrich <marvin24@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 391d2fa9
...@@ -159,12 +159,13 @@ static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec) ...@@ -159,12 +159,13 @@ static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec)
* *
* Free the given message * Free the given message
*/ */
static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg) inline void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg)
{ {
if (msg != &nvec->tx_scratch) if (msg != &nvec->tx_scratch)
dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool); dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool);
atomic_set(&msg->used, 0); atomic_set(&msg->used, 0);
} }
EXPORT_SYMBOL_GPL(nvec_msg_free);
/** /**
* nvec_msg_is_event - Return %true if @msg is an event * nvec_msg_is_event - Return %true if @msg is an event
...@@ -259,7 +260,8 @@ EXPORT_SYMBOL(nvec_write_async); ...@@ -259,7 +260,8 @@ EXPORT_SYMBOL(nvec_write_async);
* interrupt handlers. * interrupt handlers.
* *
* Returns: A pointer to the response message on success, * Returns: A pointer to the response message on success,
* %NULL on failure. * %NULL on failure. Free with nvec_msg_free() once no longer
* used.
*/ */
struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec, struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
const unsigned char *data, short size) const unsigned char *data, short size)
......
...@@ -192,4 +192,7 @@ extern int nvec_register_notifier(struct nvec_chip *nvec, ...@@ -192,4 +192,7 @@ extern int nvec_register_notifier(struct nvec_chip *nvec,
extern int nvec_unregister_notifier(struct device *dev, extern int nvec_unregister_notifier(struct device *dev,
struct notifier_block *nb, struct notifier_block *nb,
unsigned int events); unsigned int events);
extern void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg);
#endif #endif
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