diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2015-03-27 12:45:43 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <greg@kroah.com> | 2015-03-30 15:17:37 +0200 |
commit | fef96a226eca4eae4aea1657ebcf5b013d6e48b6 (patch) | |
tree | 556cdd2d4ab9dfeb99ee99db9018789e84af5095 /drivers/staging/greybus/gpio.c | |
parent | 244b5a2344bce5d9675e02da65b24e026926348c (diff) | |
download | op-kernel-dev-fef96a226eca4eae4aea1657ebcf5b013d6e48b6.zip op-kernel-dev-fef96a226eca4eae4aea1657ebcf5b013d6e48b6.tar.gz |
greybus: gpio: fix missing response on request errors
Send response also to incoming requests that cannot be fulfilled.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/gpio.c')
-rw-r--r-- | drivers/staging/greybus/gpio.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index 0500a6f..9a34fc5 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -396,43 +396,47 @@ static int gb_gpio_irq_set_type(struct irq_data *d, unsigned int type) static void gb_gpio_request_recv(u8 type, struct gb_operation *op) { - struct gb_gpio_controller *ggc; struct gb_connection *connection = op->connection; + struct gb_gpio_controller *ggc = connection->private; struct gb_message *request; struct gb_gpio_irq_event_request *event; int irq; struct irq_desc *desc; int ret; + int status; if (type != GB_GPIO_TYPE_IRQ_EVENT) { dev_err(&connection->dev, "unsupported unsolicited request: %u\n", type); - return; + status = -EINVAL; + goto send_response; } - ggc = connection->private; - request = op->request; if (request->payload_size < sizeof(*event)) { dev_err(ggc->chip.dev, "short event received\n"); - return; + status = -EINVAL; + goto send_response; } event = request->payload; if (event->which > ggc->line_max) { dev_err(ggc->chip.dev, "invalid hw irq: %d\n", event->which); - return; + status = -EINVAL; + goto send_response; } irq = gpio_to_irq(ggc->chip.base + event->which); if (irq < 0) { dev_err(ggc->chip.dev, "failed to map irq\n"); - return; + status = -EINVAL; + goto send_response; } desc = irq_to_desc(irq); if (!desc) { dev_err(ggc->chip.dev, "failed to look up irq\n"); - return; + status = -EINVAL; + goto send_response; } /* Dispatch interrupt */ @@ -440,10 +444,13 @@ static void gb_gpio_request_recv(u8 type, struct gb_operation *op) handle_simple_irq(irq, desc); local_irq_enable(); - ret = gb_operation_response_send(op, 0); + status = 0; +send_response: + ret = gb_operation_response_send(op, status); if (ret) { dev_err(ggc->chip.dev, - "failed to send response status %d: %d\n", 0, ret); + "failed to send response status %d: %d\n", + status, ret); } } |