From patchwork Wed Dec 30 16:43:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7934301 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B873E9F387 for ; Wed, 30 Dec 2015 16:47:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA3E6202EB for ; Wed, 30 Dec 2015 16:47:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11337202F0 for ; Wed, 30 Dec 2015 16:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755016AbbL3QrA (ORCPT ); Wed, 30 Dec 2015 11:47:00 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:34463 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754961AbbL3Qqy (ORCPT ); Wed, 30 Dec 2015 11:46:54 -0500 Received: by mail-wm0-f52.google.com with SMTP id u188so44570139wmu.1 for ; Wed, 30 Dec 2015 08:46:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=XY5784XuhH+cWWs4ffmK1534FTNYQ5bOV1HWS7EyfF8=; b=R2ZEJaRaYUOVQcT9HLuTUku1e/HagVBPnaR+hTPINft3FncE/GAKGPldQMsPXTnDNq oeoZGzgXhYbky459qyV6yOlG/O8R0WRmfPeq1/LWV0tfwBY8NFp2aYmFJKJh1+JTfMNo RgG1RuEz75D+AgU8cbwOnjMNWPmkDkncyxxwHqKgF1IycWykEKpVJaeXrAK3e7nZ1PwY ngHCOjdW3ifN1nC3sxiE+2mh2+w1u6rqkw6nKI0CLP/vFzgVOk7Fdg815FD1yngK9tGN f5DTC7AvNpdq53BK/aWeBjfX23+rWRu0e9p7BjoC6IyettLDjgjcCGGPG+YfJwUFoEOg sfUA== X-Received: by 10.194.203.99 with SMTP id kp3mr71634068wjc.3.1451494013264; Wed, 30 Dec 2015 08:46:53 -0800 (PST) Received: from ?IPv6:2003:62:5f55:ba00:84bb:b7f:fe67:66b9? (p200300625F55BA0084BB0B7FFE6766B9.dip0.t-ipconnect.de. [2003:62:5f55:ba00:84bb:b7f:fe67:66b9]) by smtp.googlemail.com with ESMTPSA id qs1sm5381816wjc.2.2015.12.30.08.46.52 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 30 Dec 2015 08:46:52 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 10/16] media: rc: nuvoton-cir: improve nvt_hw_detect To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: <568409B1.2060109@gmail.com> Date: Wed, 30 Dec 2015 17:43:29 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Check for the case that no Nuvoton chip is found on either EFM port. Also move the position of nvt_efm_disable to reduce the time the EFM ports are locked. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 17 +++++++++++++---- drivers/media/rc/nuvoton-cir.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 91f8fda..cf6ccb3 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -291,7 +291,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id) /* detect hardware features */ -static void nvt_hw_detect(struct nvt_dev *nvt) +static int nvt_hw_detect(struct nvt_dev *nvt) { const char *chip_name; int chip_id; @@ -306,10 +306,17 @@ static void nvt_hw_detect(struct nvt_dev *nvt) nvt_efm_enable(nvt); nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI); } - nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO); + nvt_efm_disable(nvt); + chip_id = nvt->chip_major << 8 | nvt->chip_minor; + if (chip_id == NVT_INVALID) { + dev_err(&nvt->pdev->dev, + "No device found on either EFM port\n"); + return -ENODEV; + } + chip_name = nvt_find_chip(nvt, chip_id); /* warn, but still let the driver load, if we don't know this chip */ @@ -322,7 +329,7 @@ static void nvt_hw_detect(struct nvt_dev *nvt) "found %s or compatible: chip id: 0x%02x 0x%02x", chip_name, nvt->chip_major, nvt->chip_minor); - nvt_efm_disable(nvt); + return 0; } static void nvt_cir_ldev_init(struct nvt_dev *nvt) @@ -1053,7 +1060,9 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) init_waitqueue_head(&nvt->tx.queue); - nvt_hw_detect(nvt); + ret = nvt_hw_detect(nvt); + if (ret) + goto exit_free_dev_rdev; /* Initialize CIR & CIR Wake Logical Devices */ nvt_efm_enable(nvt); diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h index 6a3de08..48c09c7 100644 --- a/drivers/media/rc/nuvoton-cir.h +++ b/drivers/media/rc/nuvoton-cir.h @@ -68,7 +68,8 @@ enum nvt_chip_ver { NVT_W83667HG = 0xa510, NVT_6775F = 0xb470, NVT_6776F = 0xc330, - NVT_6779D = 0xc560 + NVT_6779D = 0xc560, + NVT_INVALID = 0xffff, }; struct nvt_chip {