video: rockchip: mipi-dsi: Dynamic allocation command buf size
authorXubilv <xbl@rock-chips.com>
Tue, 27 Dec 2016 07:34:55 +0000 (15:34 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 28 Dec 2016 01:51:34 +0000 (09:51 +0800)
Change-Id: Ieb2ce472dc137ecf83f588e68b5e747dcbca3a20
Signed-off-by: Xubilv <xbl@rock-chips.com>
drivers/video/rockchip/screen/lcd_mipi.c
drivers/video/rockchip/transmitter/mipi_dsi.h

index 371ccc2afa7471122c0c369687f67d8f8082cadb..2514c71a960c92c4b6a47312c820af54fc73a756 100644 (file)
@@ -397,29 +397,21 @@ static int rk_mipi_screen_init_dt(struct device *dev,
                        dcs_cmd = kmalloc(sizeof(struct mipi_dcs_cmd_ctr_list), GFP_KERNEL);
                        strcpy(dcs_cmd->dcs_cmd.name, childnode->name);
 
-                       dcs_cmd->dcs_cmd.cmds =
-                               devm_kzalloc(dev, CMD_LEN_MAX, GFP_KERNEL);
-                       if (!dcs_cmd->dcs_cmd.cmds) {
-                               pr_err("malloc cmds fail!\n");
-                               return -ENOMEM;
-                       }
-
                        prop = of_find_property(childnode, "rockchip,cmd", &length);
                        if (!prop) {
                                MIPI_SCREEN_DBG("Can not read property: cmds\n");
-                               kfree(dcs_cmd->dcs_cmd.cmds);
-                               dcs_cmd->dcs_cmd.cmds = NULL;
                                return -EINVAL;
                        }
 
-                       if ((length / sizeof(u32)) > CMD_LEN_MAX) {
-                               /* the length can not longer than the cmds arrary in struct dcs_cmds */
-                               MIPI_SCREEN_DBG("error: the dcs cmd length is %d, but the max length supported is %d\n",
-                                               length / sizeof(u32),
-                                               CMD_LEN_MAX);
-                       }
                        MIPI_SCREEN_DBG("\n childnode->name =%s:length=%d\n", childnode->name, (length / sizeof(u32)));
 
+                       dcs_cmd->dcs_cmd.cmds =
+                               devm_kzalloc(dev, length, GFP_KERNEL);
+                       if (!dcs_cmd->dcs_cmd.cmds) {
+                               pr_err("malloc cmds fail!\n");
+                               return -ENOMEM;
+                       }
+
                        ret = of_property_read_u32_array(childnode,
                                                         "rockchip,cmd",
                                                         dcs_cmd->dcs_cmd.cmds,
@@ -672,7 +664,7 @@ static int rk_mipi_screen_init_dt(struct mipi_screen *screen)
                        fdt_getprop(blob, noffset, "rockchip,cmd", &length);
                        dcs_cmd->dcs_cmd.cmd_len = length / sizeof(u32) ;
 
-                       dcs_cmd->dcs_cmd.cmds = calloc(1, CMD_LEN_MAX);
+                       dcs_cmd->dcs_cmd.cmds = calloc(1, length);
                        if (!dcs_cmd->dcs_cmd.cmds) {
                                pr_err("calloc cmds fail!\n");
                                return -1;
index baa340773d3e6a7b881c4aadffe81443cc414223..0ce69bbf4a5769fd71cf3513b88c85f39dd75165 100644 (file)
@@ -112,7 +112,6 @@ typedef unsigned long u64;
 
 //iomux
 #define OLD_RK_IOMUX 0
-#define CMD_LEN_MAX 0x100
 
 struct spi_t {
        u32 cs;