From patchwork Fri Feb 12 23:18:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 8298471 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 49B2FC02AA for ; Fri, 12 Feb 2016 23:18:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3048A20460 for ; Fri, 12 Feb 2016 23:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BB4620454 for ; Fri, 12 Feb 2016 23:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751791AbcBLXSI (ORCPT ); Fri, 12 Feb 2016 18:18:08 -0500 Received: from mailout.easymail.ca ([64.68.201.169]:36719 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbcBLXSH (ORCPT ); Fri, 12 Feb 2016 18:18:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 6D22CF508; Fri, 12 Feb 2016 18:18:06 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Spam-Score: -3.687 X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (easymail-mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BEFppThNnuZZ; Fri, 12 Feb 2016 18:18:06 -0500 (EST) Received: from mail.gonehiking.org (c-73-181-52-62.hsd1.co.comcast.net [73.181.52.62]) by mailout.easymail.ca (Postfix) with ESMTPA id F32D0F4F9; Fri, 12 Feb 2016 18:18:05 -0500 (EST) Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 479289F371; Fri, 12 Feb 2016 16:18:05 -0700 (MST) From: Shuah Khan To: mchehab@osg.samsung.com Cc: Shuah Khan , hans.verkuil@cisco.com, inki.dae@samsung.com, nenggun.kim@samsung.com, jh1009.sung@samsung.com, elfring@users.sourceforge.net, chehabrafael@gmail.com, prabhakar.csengg@gmail.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: au0828 set ctrl_input in au0828_s_input() Date: Fri, 12 Feb 2016 16:18:03 -0700 Message-Id: <1455319083-7184-1-git-send-email-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dev->ctrl_input is set in vidioc_s_input() and doesn't get set in au0828_s_input(). As a result, dev->ctrl_input is left uninitialized until user space calls s_input. It works correctly because the default input value is 0 and which is what dev->ctrl_input gets initialized via kzalloc(). Change to set dev->ctrl_input in au0828_s_input(). Also optimize vidioc_s_input() to return if the new input value is same as the current. Signed-off-by: Shuah Khan --- drivers/media/usb/au0828/au0828-video.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 9304f96..20696a4 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -1345,9 +1345,11 @@ static void au0828_s_input(struct au0828_dev *dev, int index) default: dprintk(1, "unknown input type set [%d]\n", AUVI_INPUT(index).type); - break; + return; } + dev->ctrl_input = index; + v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_routing, AUVI_INPUT(index).vmux, 0, 0); @@ -1386,7 +1388,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int index) return -EINVAL; if (AUVI_INPUT(index).type == 0) return -EINVAL; - dev->ctrl_input = index; + + if (dev->ctrl_input == index) + return 0; + au0828_s_input(dev, index); return 0; } @@ -1901,6 +1906,7 @@ int au0828_analog_register(struct au0828_dev *dev, dev->ctrl_ainput = 0; dev->ctrl_freq = 960; dev->std = V4L2_STD_NTSC_M; + /* Default input is TV Tuner */ au0828_s_input(dev, 0); mutex_init(&dev->vb_queue_lock);