From 1e970d8f70430f8f2f22ed99568776ca306b7574 Mon Sep 17 00:00:00 2001 From: "jinhyung.jo" Date: Tue, 27 Oct 2015 14:42:24 +0900 Subject: tablet: Bug fix for the kernel command breaking When getting the display resolution, some parameters are missing. Because the driver directly uses the address of the kernel command line. So it copies the kernel command line to temporary buffer and uses it. And added some modification for the logs. Change-Id: If8cffbed1cbb81200bf46ade862a5f38e0c3914c Signed-off-by: Jinhyung Jo (cherry picked from commit 9c4925034c0d3a474c51c7760e7fdd8f3637624c) --- drivers/maru/maru_virtio_tablet.c | 69 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/drivers/maru/maru_virtio_tablet.c b/drivers/maru/maru_virtio_tablet.c index ef22ebccb64c..ee8f258c1b2f 100644 --- a/drivers/maru/maru_virtio_tablet.c +++ b/drivers/maru/maru_virtio_tablet.c @@ -162,6 +162,8 @@ static int virtio_tablet_probe(struct virtio_device *vdev) { int ret = 0; char *cmdline = NULL; + char *str_param = NULL; + char *tmp = NULL; int width = 0; int height = 0; @@ -213,44 +215,59 @@ static int virtio_tablet_probe(struct virtio_device *vdev) | BIT_MASK(EV_ABS) | BIT_MASK(EV_MSC); - cmdline = strstr(saved_command_line, CMDLINE_VIDEO_PARAM); - if (cmdline != NULL) { - char *tmp; - cmdline += strlen(CMDLINE_VIDEO_PARAM); - tmp = strsep(&cmdline, "x"); + cmdline = kzalloc(strlen(saved_command_line) + 1, GFP_KERNEL); + if (cmdline == NULL) { + printk(KERN_WARNING "[%s] cannot fine the kernel command line\n", + DEVICE_NAME); + goto default_resolution; + } + + strcpy(cmdline, saved_command_line); + str_param = strstr(cmdline, CMDLINE_VIDEO_PARAM); + if (str_param == NULL) { + printk(KERN_WARNING "[%s] cannot find the video resolution(%s) " + "in the kernel command line\n", + DEVICE_NAME, CMDLINE_VIDEO_PARAM); + goto default_resolution; + } + + str_param += strlen(CMDLINE_VIDEO_PARAM); + tmp = strsep(&str_param, "x"); + if (tmp != NULL) { + ret = kstrtoint(tmp, 10, &width); + if (ret) { + printk(KERN_WARNING "[%s] cannot find the width value\n", + DEVICE_NAME); + width = 0; + goto default_resolution; + } + + tmp = strsep(&str_param, "-"); if (tmp != NULL) { - ret = kstrtoint(tmp, 10, &width); + ret = kstrtoint(tmp, 10, &height); if (ret) { - printk(KERN_WARNING "cannot find the width value\n"); - width = 0; - } - - tmp = strsep(&cmdline, "-"); - if (tmp != NULL) { - ret = kstrtoint(tmp, 10, &height); - if (ret) { - printk(KERN_WARNING "cannot find the height value\n"); - height = 0; - } - } else { - printk(KERN_WARNING "Invalid bpp separator:" - " cannot find the height value\n"); + printk(KERN_WARNING "[%s] cannot find the height value\n", + DEVICE_NAME); + height = width = 0; + goto default_resolution; } } else { - printk(KERN_WARNING "Invalid resolution separator: " - " cannot find the width value\n"); + printk(KERN_WARNING "[%s] Invalid bpp separator:" + " cannot find the height value\n", DEVICE_NAME); } } else { - printk(KERN_WARNING "cannot find the video parameter(%s) " - "in the kernel command line\n", CMDLINE_VIDEO_PARAM); + printk(KERN_WARNING "[%s] Invalid resolution separator: " + " cannot find the width value\n", DEVICE_NAME); } +default_resolution: + kfree(cmdline); if (!width || !height) { width = DEFAULT_WIDTH; height = DEFAULT_HEIGHT; - printk(KERN_WARNING "cannot find the width or height, " - "use default values %dx%d\n", width, height); + printk(KERN_WARNING "[%s] cannot find the width or height, " + "use default values %dx%d\n", DEVICE_NAME, width, height); } input_set_abs_params(vtb->idev, ABS_X, 0, width, 0, 0); -- cgit v1.2.3