From: Xubilv Date: Tue, 27 Dec 2016 07:34:55 +0000 (+0800) Subject: video: rockchip: mipi-dsi: Dynamic allocation command buf size X-Git-Tag: firefly_0821_release~965 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9824749a550f16d69df214cb4dd90514542d9eff;p=firefly-linux-kernel-4.4.55.git video: rockchip: mipi-dsi: Dynamic allocation command buf size Change-Id: Ieb2ce472dc137ecf83f588e68b5e747dcbca3a20 Signed-off-by: Xubilv --- diff --git a/drivers/video/rockchip/screen/lcd_mipi.c b/drivers/video/rockchip/screen/lcd_mipi.c index 371ccc2afa74..2514c71a960c 100644 --- a/drivers/video/rockchip/screen/lcd_mipi.c +++ b/drivers/video/rockchip/screen/lcd_mipi.c @@ -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; diff --git a/drivers/video/rockchip/transmitter/mipi_dsi.h b/drivers/video/rockchip/transmitter/mipi_dsi.h index baa340773d3e..0ce69bbf4a57 100644 --- a/drivers/video/rockchip/transmitter/mipi_dsi.h +++ b/drivers/video/rockchip/transmitter/mipi_dsi.h @@ -112,7 +112,6 @@ typedef unsigned long u64; //iomux #define OLD_RK_IOMUX 0 -#define CMD_LEN_MAX 0x100 struct spi_t { u32 cs;