drm/bridge/sii8620: abstract out common MSC command
authorAndrzej Hajda <a.hajda@samsung.com>
Mon, 17 Oct 2016 12:43:47 +0000 (14:43 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:53:53 +0000 (13:53 +0900)
Four different functions share the same code, this patch abstracts out
the common part.

Change-Id: Ia2c7ccb59863be03bf47d61ec979c72bb3258df6
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
drivers/gpu/drm/bridge/sii8620.c

index 384e592..c0c87e8 100644 (file)
@@ -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)