From patchwork Sun Jul 27 19:27:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 4631211 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B51F6C0338 for ; Sun, 27 Jul 2014 19:27:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3747200C6 for ; Sun, 27 Jul 2014 19:27:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CAFE720148 for ; Sun, 27 Jul 2014 19:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752521AbaG0T1l (ORCPT ); Sun, 27 Jul 2014 15:27:41 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:54593 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149AbaG0T1j (ORCPT ); Sun, 27 Jul 2014 15:27:39 -0400 Received: from [191.255.125.116] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1XBU6b-0005k4-Fw; Sun, 27 Jul 2014 19:27:37 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.80.1) (envelope-from ) id 1XBU6X-000800-Ml; Sun, 27 Jul 2014 16:27:33 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH v3 6/6] cx231xx: return an error if it can't read PCB config Date: Sun, 27 Jul 2014 16:27:32 -0300 Message-Id: <1406489252-30636-7-git-send-email-m.chehab@samsung.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406489252-30636-1-git-send-email-m.chehab@samsung.com> References: <1406489252-30636-1-git-send-email-m.chehab@samsung.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Instead of using some random value, return an error if the PCB config is not available or doesn't match a know profile Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/cx231xx/cx231xx-cards.c | 6 +++++- drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c | 10 +++++++--- drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 338417fee8b6..8039b769f258 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -1144,7 +1144,11 @@ static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; /* Query cx231xx to find what pcb config it is related to */ - initialize_cx231xx(dev); + retval = initialize_cx231xx(dev); + if (retval < 0) { + cx231xx_errdev("Failed to read PCB config\n"); + return retval; + } /*To workaround error number=-71 on EP0 for VideoGrabber, need set alt here.*/ diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c index 2a34ceee4802..3052c4c20229 100644 --- a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c +++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c @@ -654,8 +654,9 @@ static struct pcb_config cx231xx_Scenario[] = { /*****************************************************************/ -u32 initialize_cx231xx(struct cx231xx *dev) +int initialize_cx231xx(struct cx231xx *dev) { + int retval; u32 config_info = 0; struct pcb_config *p_pcb_info; u8 usb_speed = 1; /* from register,1--HS, 0--FS */ @@ -670,7 +671,10 @@ u32 initialize_cx231xx(struct cx231xx *dev) /* read board config register to find out which pcb config it is related to */ - cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, data, 4); + retval = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, + data, 4); + if (retval < 0) + return retval; config_info = le32_to_cpu(*((__le32 *)data)); usb_speed = (u8) (config_info & 0x1); @@ -767,7 +771,7 @@ u32 initialize_cx231xx(struct cx231xx *dev) cx231xx_info("bad senario!!!!!\n"); cx231xx_info("config_info=%x\n", (config_info & SELFPOWER_MASK)); - return 1; + return -ENODEV; } } diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h index b3c6190e0c69..4511dc5d199c 100644 --- a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h +++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h @@ -221,6 +221,6 @@ enum INDEX_PCB_CONFIG{ /***************************************************************************/ struct cx231xx; -u32 initialize_cx231xx(struct cx231xx *p_dev); +int initialize_cx231xx(struct cx231xx *p_dev); #endif