summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/hid.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-03-27 12:45:49 +0100
committerGreg Kroah-Hartman <greg@kroah.com>2015-03-30 15:20:34 +0200
commit973ccfd62686a2331f43b0053de052d958f50d31 (patch)
tree64bac22afe54717e27c9dcd738421713db87b193 /drivers/staging/greybus/hid.c
parentd0eb755aeef092f27b3dd2a4c90616f613541f56 (diff)
downloadop-kernel-dev-973ccfd62686a2331f43b0053de052d958f50d31.zip
op-kernel-dev-973ccfd62686a2331f43b0053de052d958f50d31.tar.gz
greybus: operation: refactor response handling
Send response to incoming requests from the operation request handler rather than in every protocol request_recv callback. This simplifies request_recv error handling and allows for further code reuse. Note that if we ever get protocols that need to hold off sending responses we could implement this by letting them return a special value (after acquiring the necessary operation references) to suppress the response from being sent by greybus core. 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/hid.c')
-rw-r--r--drivers/staging/greybus/hid.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/staging/greybus/hid.c b/drivers/staging/greybus/hid.c
index cc5708d..5935aa6 100644
--- a/drivers/staging/greybus/hid.c
+++ b/drivers/staging/greybus/hid.c
@@ -150,25 +150,22 @@ static int gb_hid_set_report(struct gb_hid *ghid, u8 report_type, u8 report_id,
return ret;
}
-static void gb_hid_irq_handler(u8 type, struct gb_operation *op)
+static int gb_hid_irq_handler(u8 type, struct gb_operation *op)
{
struct gb_connection *connection = op->connection;
struct gb_hid *ghid = connection->private;
struct gb_hid_input_report_request *request = op->request->payload;
- int status;
- int ret, size;
+ int size;
if (type != GB_HID_TYPE_IRQ_EVENT) {
dev_err(&connection->dev,
"unsupported unsolicited request\n");
- status = -EINVAL;
- goto send_response;
+ return -EINVAL;
}
if (op->request->payload_size < 2) {
dev_err(&connection->dev, "short report received\n");
- status = -EINVAL;
- goto send_response;
+ return -EINVAL;
}
/*
@@ -178,22 +175,14 @@ static void gb_hid_irq_handler(u8 type, struct gb_operation *op)
size = request->report[0] | request->report[1] << 8;
if (size < 2 || size > op->request->payload_size - 2) {
dev_err(&connection->dev, "bad report size: %d\n", size);
- status = -EINVAL;
- goto send_response;
+ return -EINVAL;
}
if (test_bit(GB_HID_STARTED, &ghid->flags))
hid_input_report(ghid->hid, HID_INPUT_REPORT,
request->report + 2, size - 2, 1);
- status = 0;
-send_response:
- ret = gb_operation_response_send(op, status);
- if (ret) {
- dev_err(&connection->dev,
- "failed to send response status %d: %d\n",
- status, ret);
- }
+ return 0;
}
OpenPOWER on IntegriCloud