mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-16 15:45:45 +00:00
staging: nvec: Have nvec_write_async() return -ENOMEM on OOM
Change nvec_write_async() to return an integer, 0 by default, a negative error on failure. Change nvec_write_sync() to check the return value and abort if it is negative. Signed-off-by: Julian Andres Klode <jak@jak-linux.org> Acked-by: Marc Dietrich <marvin24@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
ff169c1487
commit
1b9bf629ea
2 changed files with 10 additions and 3 deletions
|
@ -154,13 +154,16 @@ static void nvec_gpio_set_value(struct nvec_chip *nvec, int value)
|
||||||
gpio_set_value(nvec->gpio, value);
|
gpio_set_value(nvec->gpio, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
|
int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
|
||||||
short size)
|
short size)
|
||||||
{
|
{
|
||||||
struct nvec_msg *msg;
|
struct nvec_msg *msg;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
msg = nvec_msg_alloc(nvec);
|
msg = nvec_msg_alloc(nvec);
|
||||||
|
if (msg == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
msg->data[0] = size;
|
msg->data[0] = size;
|
||||||
memcpy(msg->data + 1, data, size);
|
memcpy(msg->data + 1, data, size);
|
||||||
msg->size = size + 1;
|
msg->size = size + 1;
|
||||||
|
@ -170,6 +173,8 @@ void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
|
||||||
spin_unlock_irqrestore(&nvec->tx_lock, flags);
|
spin_unlock_irqrestore(&nvec->tx_lock, flags);
|
||||||
|
|
||||||
queue_work(nvec->wq, &nvec->tx_work);
|
queue_work(nvec->wq, &nvec->tx_work);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(nvec_write_async);
|
EXPORT_SYMBOL(nvec_write_async);
|
||||||
|
|
||||||
|
@ -181,7 +186,9 @@ struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
|
||||||
mutex_lock(&nvec->sync_write_mutex);
|
mutex_lock(&nvec->sync_write_mutex);
|
||||||
|
|
||||||
nvec->sync_write_pending = (data[1] << 8) + data[0];
|
nvec->sync_write_pending = (data[1] << 8) + data[0];
|
||||||
nvec_write_async(nvec, data, size);
|
|
||||||
|
if (nvec_write_async(nvec, data, size) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n",
|
dev_dbg(nvec->dev, "nvec_sync_write: 0x%04x\n",
|
||||||
nvec->sync_write_pending);
|
nvec->sync_write_pending);
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct nvec_chip {
|
||||||
int state;
|
int state;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
|
extern int nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
|
||||||
short size);
|
short size);
|
||||||
|
|
||||||
extern struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
|
extern struct nvec_msg *nvec_write_sync(struct nvec_chip *nvec,
|
||||||
|
|
Loading…
Reference in a new issue