From patchwork Fri Mar 21 21:04:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 3876341 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C0A949F334 for ; Fri, 21 Mar 2014 21:05:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8F6C20225 for ; Fri, 21 Mar 2014 21:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 379FA20212 for ; Fri, 21 Mar 2014 21:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751297AbaCUVFG (ORCPT ); Fri, 21 Mar 2014 17:05:06 -0400 Received: from qmta13.emeryville.ca.mail.comcast.net ([76.96.27.243]:37441 "EHLO qmta13.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbaCUVFF (ORCPT ); Fri, 21 Mar 2014 17:05:05 -0400 Received: from omta24.emeryville.ca.mail.comcast.net ([76.96.30.92]) by qmta13.emeryville.ca.mail.comcast.net with comcast id gM2Y1n0041zF43QADM54oU; Fri, 21 Mar 2014 21:05:04 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta24.emeryville.ca.mail.comcast.net with comcast id gM521n00L0MU7Qa8kM52GC; Fri, 21 Mar 2014 21:05:03 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 9AB433FD4B; Fri, 21 Mar 2014 15:05:01 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, shuahkhan@gmail.com Subject: [PATCH] media: em28xx-video - change em28xx_scaler_set() to use em28xx_reg_len() Date: Fri, 21 Mar 2014 15:04:50 -0600 Message-Id: <1395435890-15100-1-git-send-email-shuah.kh@samsung.com> X-Mailer: git-send-email 1.8.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1395435904; bh=jXPHHn05wKNHdZ5LqdP3UkYq2DaWXNHN7/x0/YH4m5k=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=dYY/UZxroVuEpXBkhIsx7rJeHL+d76ONPWxFDwFO9USsltJ55d6dbeuN28NERVLLA Bx6CTTz8TXGcxK9ogdwm51lrKsCjO3iIZeXJAsC/KvUYp5ztxk/59cySE3M8L4g/Oq GaZKbTer7MqSs3pwzsdehX63+wNXblTy3vl3Hh1cVtZrb8opiPCjXbUV7TzD/Ulq5F ZuCR57mhsNdbCp06ABDLq8ukYuqRUqIrzwDFc0sl+B+317jlxoG6gdcvsmMqt2tb8X eWdNJTTqonexPVzS/O202y4y47z9AWESCkM6NLPx0drKrQodmAMkdaC66N/4WT819R izGbRGiE+JaiQ== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change em28xx_scaler_set() to use em28xx_reg_len() to get register lengths for EM28XX_R30_HSCALELOW and EM28XX_R32_VSCALELOW registers, instead of hard-coding the length. Moved em28xx_reg_len() definition for it to be visible to em28xx_scaler_set(). Signed-off-by: Shuah Khan --- drivers/media/usb/em28xx/em28xx-video.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 19af6b3..f8a91de 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -272,6 +272,18 @@ static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, } } +static int em28xx_reg_len(int reg) +{ + switch (reg) { + case EM28XX_R40_AC97LSB: + case EM28XX_R30_HSCALELOW: + case EM28XX_R32_VSCALELOW: + return 2; + default: + return 1; + } +} + static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) { u8 mode; @@ -284,11 +296,13 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) buf[0] = h; buf[1] = h >> 8; - em28xx_write_regs(dev, EM28XX_R30_HSCALELOW, (char *)buf, 2); + em28xx_write_regs(dev, EM28XX_R30_HSCALELOW, (char *)buf, + em28xx_reg_len(EM28XX_R30_HSCALELOW)); buf[0] = v; buf[1] = v >> 8; - em28xx_write_regs(dev, EM28XX_R32_VSCALELOW, (char *)buf, 2); + em28xx_write_regs(dev, EM28XX_R32_VSCALELOW, (char *)buf, + em28xx_reg_len(EM28XX_R32_VSCALELOW)); /* it seems that both H and V scalers must be active to work correctly */ mode = (h || v) ? 0x30 : 0x00; @@ -1583,17 +1597,6 @@ static int vidioc_g_chip_info(struct file *file, void *priv, return 0; } -static int em28xx_reg_len(int reg) -{ - switch (reg) { - case EM28XX_R40_AC97LSB: - case EM28XX_R30_HSCALELOW: - case EM28XX_R32_VSCALELOW: - return 2; - default: - return 1; - } -} static int vidioc_g_register(struct file *file, void *priv, struct v4l2_dbg_register *reg)