public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Scheller <d.scheller.oss@gmail.com>
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	[thread overview]
Message-ID: <20180623153615.27630-4-d.scheller.oss@gmail.com> (raw)
In-Reply-To: <20180623153615.27630-1-d.scheller.oss@gmail.com>

From: Daniel Scheller <d.scheller@gmx.net>

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 <d.scheller@gmx.net>
---
 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;
-- 
2.16.4

  parent reply	other threads:[~2018-06-23 15:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-23 15:35 [PATCH 00/19] dddvb/ddbridge updates as of 2018-06-23 Daniel Scheller
2018-06-23 15:35 ` [PATCH 01/19] [media] dvb-frontends/mxl5xx: add break to case DVBS2 in get_frontend() Daniel Scheller
2018-07-30 15:05   ` Mauro Carvalho Chehab
2018-06-23 15:35 ` [PATCH 02/19] [media] dvb-frontends/stv0910: cast the BER denominator shift exp to ULL Daniel Scheller
2018-06-23 15:35 ` Daniel Scheller [this message]
2018-06-23 15:36 ` [PATCH 04/19] [media] ddbridge: evaluate the actual link when setting up the dummy tuner Daniel Scheller
2018-06-23 15:36 ` [PATCH 05/19] [media] ddbridge: report I2C bus errors Daniel Scheller
2018-06-23 15:36 ` [PATCH 06/19] [media] ddbridge: remove unused MDIO defines and hwinfo member Daniel Scheller
2018-06-23 15:36 ` [PATCH 07/19] [media] ddbridge: link structure access cosmetics in ddb_port_probe() Daniel Scheller
2018-06-23 15:36 ` [PATCH 08/19] [media] ddbridge: change MCI base ID and define a SX8 ID Daniel Scheller
2018-06-23 15:36 ` [PATCH 09/19] [media] ddbridge/mci: update copyright year in headers Daniel Scheller
2018-06-23 15:36 ` [PATCH 10/19] [media] ddbridge/mci: read and report signal strength and SNR Daniel Scheller
2018-06-23 15:36 ` [PATCH 11/19] [media] ddbridge/mci: rename defines and fix i/q var types Daniel Scheller
2018-06-23 15:36 ` [PATCH 12/19] [media] ddbridge/mci: extend mci_command and mci_result structs Daniel Scheller
2018-06-23 15:36 ` [PATCH 13/19] [media] ddbridge/mci: store mci type and number of ports in the hwinfo Daniel Scheller
2018-06-23 15:36 ` [PATCH 14/19] [media] ddbridge/mci: make ddb_mci_cmd() and ddb_mci_config() public Daniel Scheller
2018-06-23 15:36 ` [PATCH 15/19] [media] ddbridge/mci: split MaxSX8 specific code off to ddbridge-sx8.c Daniel Scheller
2018-06-23 15:36 ` [PATCH 16/19] [media] ddbridge/mci: add more MCI status codes, improve MCI_SUCCESS macro Daniel Scheller
2018-06-23 15:36 ` [PATCH 17/19] [media] ddbridge/sx8: disable automatic PLS code search Daniel Scheller
2018-06-23 15:36 ` [PATCH 18/19] [media] ddbridge/sx8: enable modulation selection in set_parameters() Daniel Scheller
2018-06-23 15:36 ` [PATCH 19/19] [media] ddbridge/mci: add SX8 I/Q mode remark and remove DIAG CMD defines Daniel Scheller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180623153615.27630-4-d.scheller.oss@gmail.com \
    --to=d.scheller.oss@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mchehab@s-opensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox