From b66ef4d7cea87a6c51efbae05c1ff8715ab3da35 Mon Sep 17 00:00:00 2001 From: Andrzej Hajda Date: Mon, 17 Oct 2016 14:43:47 +0200 Subject: [PATCH] drm/bridge/sii8620: abstract out common MSC command Four different functions share the same code, this patch abstracts out the common part. Change-Id: Ia2c7ccb59863be03bf47d61ec979c72bb3258df6 Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/bridge/sii8620.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii8620.c b/drivers/gpu/drm/bridge/sii8620.c index 384e592..c0c87e8 100644 --- a/drivers/gpu/drm/bridge/sii8620.c +++ b/drivers/gpu/drm/bridge/sii8620.c @@ -301,43 +301,32 @@ static struct sii8620_mt_msg *sii8620_mt_msg_new(struct sii8620 *ctx) return msg; } -static void sii8620_mt_write_stat(struct sii8620 *ctx, u8 reg, u8 val) +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); if (!msg) return; - msg->reg[0] = MHL_WRITE_STAT; - msg->reg[1] = reg; - msg->reg[2] = val; + msg->reg[0] = cmd; + msg->reg[1] = arg1; + msg->reg[2] = arg2; msg->send = sii8620_mt_msc_cmd_send; } -static inline void sii8620_mt_set_int(struct sii8620 *ctx, u8 irq, u8 mask) +static void sii8620_mt_write_stat(struct sii8620 *ctx, u8 reg, u8 val) { - struct sii8620_mt_msg *msg = sii8620_mt_msg_new(ctx); - - if (!msg) - return; + sii8620_mt_msc_cmd(ctx, MHL_WRITE_STAT, reg, val); +} - msg->reg[0] = MHL_SET_INT; - msg->reg[1] = irq; - msg->reg[2] = mask; - msg->send = sii8620_mt_msc_cmd_send; +static inline void sii8620_mt_set_int(struct sii8620 *ctx, u8 irq, u8 mask) +{ + sii8620_mt_msc_cmd(ctx, MHL_SET_INT, irq, mask); } static void sii8620_mt_msc_msg(struct sii8620 *ctx, u8 cmd, u8 data) { - struct sii8620_mt_msg *msg = sii8620_mt_msg_new(ctx); - - if (!msg) - return; - - msg->reg[0] = MHL_MSC_MSG; - msg->reg[1] = cmd; - msg->reg[2] = data; - msg->send = sii8620_mt_msc_cmd_send; + sii8620_mt_msc_cmd(ctx, MHL_MSC_MSG, cmd, data); } static void sii8620_mt_rap(struct sii8620 *ctx, u8 code) -- 2.7.4