Commit 0c2d1875 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Archit Taneja

drm/bridge/sii8620: add continuations to messages

Due to asynchronous nature of MHL flow of execution is dispersed.
Logical continuation of some actions happens after response of peer,
i.e in interrupt handler. To simplify coding continuation mechanism
has been added - it is now possible to provide continuation callback,
which will be called after peer responds to given action.
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1485935272-17337-5-git-send-email-a.hajda@samsung.com
parent e9c6da27
...@@ -78,12 +78,15 @@ struct sii8620_mt_msg; ...@@ -78,12 +78,15 @@ struct sii8620_mt_msg;
typedef void (*sii8620_mt_msg_cb)(struct sii8620 *ctx, typedef void (*sii8620_mt_msg_cb)(struct sii8620 *ctx,
struct sii8620_mt_msg *msg); struct sii8620_mt_msg *msg);
typedef void (*sii8620_cb)(struct sii8620 *ctx, int ret);
struct sii8620_mt_msg { struct sii8620_mt_msg {
struct list_head node; struct list_head node;
u8 reg[4]; u8 reg[4];
u8 ret; u8 ret;
sii8620_mt_msg_cb send; sii8620_mt_msg_cb send;
sii8620_mt_msg_cb recv; sii8620_mt_msg_cb recv;
sii8620_cb continuation;
}; };
static const u8 sii8620_i2c_page[] = { static const u8 sii8620_i2c_page[] = {
...@@ -258,6 +261,8 @@ static void sii8620_mt_work(struct sii8620 *ctx) ...@@ -258,6 +261,8 @@ static void sii8620_mt_work(struct sii8620 *ctx)
node); node);
if (msg->recv) if (msg->recv)
msg->recv(ctx, msg); msg->recv(ctx, msg);
if (msg->continuation)
msg->continuation(ctx, msg->ret);
list_del(&msg->node); list_del(&msg->node);
kfree(msg); kfree(msg);
} }
...@@ -310,6 +315,21 @@ static struct sii8620_mt_msg *sii8620_mt_msg_new(struct sii8620 *ctx) ...@@ -310,6 +315,21 @@ static struct sii8620_mt_msg *sii8620_mt_msg_new(struct sii8620 *ctx)
return msg; return msg;
} }
static void sii8620_mt_set_cont(struct sii8620 *ctx, sii8620_cb cont)
{
struct sii8620_mt_msg *msg;
if (ctx->error)
return;
if (list_empty(&ctx->mt_queue)) {
ctx->error = -EINVAL;
return;
}
msg = list_last_entry(&ctx->mt_queue, struct sii8620_mt_msg, node);
msg->continuation = cont;
}
static void sii8620_mt_msc_cmd(struct sii8620 *ctx, u8 cmd, u8 arg1, u8 arg2) static void sii8620_mt_msc_cmd(struct sii8620 *ctx, u8 cmd, u8 arg1, u8 arg2)
{ {
struct sii8620_mt_msg *msg = sii8620_mt_msg_new(ctx); struct sii8620_mt_msg *msg = sii8620_mt_msg_new(ctx);
......
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