From patchwork Sat Jun 23 15:35:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10483741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7CAC860230 for ; Sat, 23 Jun 2018 15:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77BE2288EC for ; Sat, 23 Jun 2018 15:36:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C6F6289D1; Sat, 23 Jun 2018 15:36:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12CC928A34 for ; Sat, 23 Jun 2018 15:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbeFWPg4 (ORCPT ); Sat, 23 Jun 2018 11:36:56 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46354 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbeFWPgW (ORCPT ); Sat, 23 Jun 2018 11:36:22 -0400 Received: by mail-wr0-f194.google.com with SMTP id l14-v6so4347710wrq.13 for ; Sat, 23 Jun 2018 08:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rDbhd0aEGbcmzsG7IJZAYVCvuEFY8xXRJb8uuuinGPg=; b=kNmMeT+m9XI0h8Sge4pqA3x3YERh101SFd/Vtzi4jfFyurniYl3b4RRvFlBJiJvIZn DQT01b6cMQOFJghwEw6cSzwaC56XV0b6YTK24MDGN3oE3PJ39eRpHzkf/dFHiZPYB/g4 R2ybsCzciJkGcG3gclpejxi2/Bc2KudB6tp+yUZHUcRMDjJ/ByQA5ojcsjRrXLuvRyuY zPnuzhItYSlt2ZeVvuxboyQdodoTwdwNpb0385mqleZM4RqqstUsbzZbnPsten53aa1x B9PiVBY/YLi+NIyWYFiWKOosIT7BkZgPrraoW5R2L2UhqjkrEFM5mDw/vLwWgtigKyGF 6SLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rDbhd0aEGbcmzsG7IJZAYVCvuEFY8xXRJb8uuuinGPg=; b=eGLSZqTpOwN0btFK6VbnmUEgKTJAepLytvbUSWctZhey8+l1d9hXZi3CIIacGBrf27 x3BImp4f1HeIkbbqSFhBPtBjYNtmowrZYtZ3U8FPTBkcy8ym/tSK6OWdBwxmpzcH2Gj6 yEMvH3e3B8hpZa7JoeJbbhkXhuxCc0UwFdAOPFJSlOL+rP7BOPbZHFNHYHnssGWSZurj YK8+dUjuKxj1ZzD8CZmprwPzwFWWQhxf3loDl8tOyWkihcxpa7uz5rdpI+c7u+CHbiG2 0oTFPWAJbKBUtjmU/DnRa+/BKpnpfzSoIe9iRRloA8KnQJb4Pqmtyvof10MUh4eCvA4e mXCg== X-Gm-Message-State: APt69E3vysakL5SVtCDvqOoyh3hS/10LeUBq/3/PElDBciXsQvE85gWY VaH4bAvwdtRZQxp3QxQQG891dw== X-Google-Smtp-Source: AAOMgpdR9oDYNHj9ffRKFyd3Nb7SMxP9jGECVBdMSryUFnWvrA+uc+fmKSwIWTaNF+wDCmZ8tb/sYg== X-Received: by 2002:adf:d4c5:: with SMTP id w5-v6mr4797448wrk.185.1529768181483; Sat, 23 Jun 2018 08:36:21 -0700 (PDT) Received: from dvbdev.wuest.de (ip-176-199-71-134.hsi06.unitymediagroup.de. [176.199.71.134]) by smtp.gmail.com with ESMTPSA id o15-v6sm3443156wrm.38.2018.06.23.08.36.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Jun 2018 08:36:20 -0700 (PDT) From: Daniel Scheller To: mchehab@kernel.org, mchehab@s-opensource.com Cc: linux-media@vger.kernel.org Subject: [PATCH 03/19] [media] ddbridge: probe for LNBH25 chips before attaching Date: Sat, 23 Jun 2018 17:35:59 +0200 Message-Id: <20180623153615.27630-4-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180623153615.27630-1-d.scheller.oss@gmail.com> References: <20180623153615.27630-1-d.scheller.oss@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller In demod_attach_stv0910(), the LNBH25 IC is being blindly attached and, if the result is bad, blindly attached on another possible I2C address. The LNBH25 uses it's set_voltage function to test for the IC and will print an error to the kernel log on failure. Prevent this by probing the possible I2C address and use this (and only this) to attach the LNBH25 I2C driver. This also allows the stv0910 attach function to be a bit cleaner. Picked up from the upstream dddvb GIT and adapted for the LNBH25 driver variant from the kernel tree. Signed-off-by: Daniel Scheller --- drivers/media/pci/ddbridge/ddbridge-core.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index d5b0d1eaf3ad..3f83415b06c7 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1191,6 +1191,13 @@ static const struct lnbh25_config lnbh25_cfg = { .data2_config = LNBH25_TEN }; +static int has_lnbh25(struct i2c_adapter *i2c, u8 adr) +{ + u8 val; + + return i2c_read_reg(i2c, adr, 0, &val) ? 0 : 1; +} + static int demod_attach_stv0910(struct ddb_input *input, int type, int tsfast) { struct i2c_adapter *i2c = &input->port->i2c->adap; @@ -1224,14 +1231,15 @@ static int demod_attach_stv0910(struct ddb_input *input, int type, int tsfast) /* attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit * i2c addresses */ - lnbcfg.i2c_address = (((input->nr & 1) ? 0x0d : 0x0c) << 1); - if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) { + if (has_lnbh25(i2c, 0x0d)) + lnbcfg.i2c_address = (((input->nr & 1) ? 0x0d : 0x0c) << 1); + else lnbcfg.i2c_address = (((input->nr & 1) ? 0x09 : 0x08) << 1); - if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) { - dev_err(dev, "No LNBH25 found!\n"); - dvb_frontend_detach(dvb->fe); - return -ENODEV; - } + + if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) { + dev_err(dev, "No LNBH25 found!\n"); + dvb_frontend_detach(dvb->fe); + return -ENODEV; } return 0;