Skip to contentSkip to conversation

Fix ISDB-T tuning on PV SBTVD Hybrid

PATCH New Mauro Carvalho Chehab 1 participant 13 messages Sep 5, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix ISDB-T tuning on PV SBTVD Hybrid

This patch series fix a series of bugs and issues related to PV SBTVD device while tuning to ISDB-T channels found in Brazil.

Mauro Carvalho Chehab (12):
[media] cx231xx: don't return error on success [media] cx231xx: fix GPIOs for Pixelview SBTVD hybrid [media] cx231xx: prints error code if can't switch TV mode [media] mb86a20s: fix the locking logic
[media] cx231xx: fix PV SBTVD Hybrid AGC GPIO pin [media] mb86a20s: fix demod settings
[media] cx231xx-core: fix GPIO comments
[media] cx231xx-i2c: handle errors with cx231xx_get_i2c_adap() [media] cx231xx: can't proceed if I2C bus register fails [media] cx231xx-cards: unregister IR earlier
[media] tda18271: use prefix on all printk messages [media] tea5767: use module prefix on printed messages

 drivers/media/dvb-frontends/mb86a20s.c     | 104 +++++++++++++++--------------
 drivers/media/tuners/tda18271-fe.c         |  11 +--
 drivers/media/tuners/tda18271-priv.h       |   2 +
 drivers/media/tuners/tea5767.c             |   9 ++-
 drivers/media/usb/cx231xx/cx231xx-avcore.c |   5 +-
 drivers/media/usb/cx231xx/cx231xx-cards.c  |   6 +-
 drivers/media/usb/cx231xx/cx231xx-core.c   |  44 +++++++++---
 drivers/media/usb/cx231xx/cx231xx-i2c.c    |   2 +-
 8 files changed, 108 insertions(+), 75 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/12 cx231xx: don't return error on success

From: Mauro Carvalho Chehab <[email protected]>

The cx231xx_set_agc_analog_digital_mux_select() callers expect it to return 0 or an error. That makes the first attempt to switch between analog/digital to fail.

---
 drivers/media/usb/cx231xx/cx231xx-avcore.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-avcore.c +4 -1
index 491913778bcc..2f52d66b4dae 100644
@@ -1264,7 +1264,10 @@ int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev,
 				   dev->board.agc_analog_digital_select_gpio,
 				   analog_or_digital);
 
-	return status;
+	if (status < 0)
+		return status;
+
+	return 0;
 }
 
 int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/12 cx231xx: fix GPIOs for Pixelview SBTVD hybrid

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

This device uses GPIOs: 28 to switch between analog and digital modes: on digital mode, it should be set to 1.

The code that sets it on analog mode is OK, but it misses the logic that sets it on digital mode.

---
 drivers/media/usb/cx231xx/cx231xx-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-core.c +2 -1
index 630f4fc5155f..6c8f825452dd 100644
@@ -712,6 +712,7 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode)
 			break;
 		case CX231XX_BOARD_CNXT_RDE_253S:
 		case CX231XX_BOARD_CNXT_RDU_253S:
+		case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID:
 			errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1);
 			break;
 		case CX231XX_BOARD_HAUPPAUGE_EXETER:
@@ -738,7 +739,7 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode)
 		case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID:
 		case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL:
 		case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC:
-		errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0);
+			errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0);
 			break;
 		default:
 			break;
Signature · 1 line
2.7.4
#3 lore raw

PATCH v2 3/12 cx231xx: prints error code if can't switch TV mode

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

If something bad happens when switching between digital and analog mode, prints an error and outputs the returned code.

---
 drivers/media/usb/cx231xx/cx231xx-core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-core.c +8 -1
index 6c8f825452dd..4b3acbd1d7f0 100644
@@ -746,7 +746,14 @@ int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode)
 		}
 	}
 
-	return errCode ? -EINVAL : 0;
+	if (errCode < 0) {
+		dev_err(dev->dev, "Failed to set devmode to %s: error: %i",
+			dev->mode == CX231XX_DIGITAL_MODE ? "digital" : "analog",
+			errCode);
+		return errCode;
+	}
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(cx231xx_set_mode);
 
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 4/12 mb86a20s: fix the locking logic

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

On this frontend, it takes a while to start output normal TS data. That only happens on state S9. On S8, the TS output is enabled, but it is not reliable enough.

However, the zigzag loop is too fast to let it sync.

As, on practical tests, the zigzag software loop doesn't seem to be helping, but just slowing down the tuning, let's switch to hardware algorithm, as the tuners used on such devices are capable of work with frequency drifts without any help from software.

---
 drivers/media/dvb-frontends/mb86a20s.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/mb86a20s.c +11 -1
index fb88dddaf3a3..66939eca445b 100644
@@ -317,7 +317,11 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, enum fe_status *status)
 	if (val >= 7)
 		*status |= FE_HAS_SYNC;
 
-	if (val >= 8)				/* Maybe 9? */
+	/*
+	 * Actually, on state S8, it starts receiving TS, but the TS
+	 * output is only on normal state after the transition to S9.
+	 */
+	if (val >= 9)
 		*status |= FE_HAS_LOCK;
 
 	dev_dbg(&state->i2c->dev, "%s: Status = 0x%02x (state = %d)\n",
@@ -2057,6 +2061,11 @@ static void mb86a20s_release(struct dvb_frontend *fe)
 	kfree(state);
 }
 
+static int mb86a20s_get_frontend_algo(struct dvb_frontend *fe)
+{
+        return DVBFE_ALGO_HW;
+}
+
 static struct dvb_frontend_ops mb86a20s_ops;
 
 struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
@@ -2129,6 +2138,7 @@ static struct dvb_frontend_ops mb86a20s_ops = {
 	.read_status = mb86a20s_read_status_and_stats,
 	.read_signal_strength = mb86a20s_read_signal_strength_from_cache,
 	.tune = mb86a20s_tune,
+	.get_frontend_algo = mb86a20s_get_frontend_algo,
 };
 
 MODULE_DESCRIPTION("DVB Frontend module for Fujitsu mb86A20s hardware");
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 5/12 cx231xx: fix PV SBTVD Hybrid AGC GPIO pin

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

The AGC GPIO pin for this board is wrong. it should be GPIO 28 (0x1c).

---
 drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-cards.c +1 -1
index c63248a18823..72c246bfaa1c 100644
@@ -486,7 +486,7 @@ struct cx231xx_board cx231xx_boards[] = {
 		.output_mode = OUT_MODE_VIP11,
 		.demod_xfer_mode = 0,
 		.ctl_pin_status_mask = 0xFFFFFFC4,
-		.agc_analog_digital_select_gpio = 0x00,	/* According with PV cxPolaris.inf file */
+		.agc_analog_digital_select_gpio = 0x1c,
 		.tuner_sif_gpio = -1,
 		.tuner_scl_gpio = -1,
 		.tuner_sda_gpio = -1,
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 6/12 mb86a20s: fix demod settings

In reply to Mauro Carvalho Chehab

From: Mauro Carvalho Chehab <[email protected]>

With the current settings, only one channel locks properly. That's likely because, when this driver was written, Brazil were still using experimental transmissions.

Change it to reproduce the settings used by the newer drivers. That makes it lock on other channels.

---
 drivers/media/dvb-frontends/mb86a20s.c | 92 ++++++++++++++++------------------
 1 file changed, 42 insertions(+), 50 deletions(-)
drivers/media/dvb-frontends/mb86a20s.c +42 -50
index 66939eca445b..6e38df68c310 100644
@@ -71,25 +71,27 @@ static struct regdata mb86a20s_init1[] = {
 };
 
 static struct regdata mb86a20s_init2[] = {
-	{ 0x28, 0x22 }, { 0x29, 0x00 }, { 0x2a, 0x1f }, { 0x2b, 0xf0 },
+	{ 0x50, 0xd1 }, { 0x51, 0x22 },
+	{ 0x39, 0x01 },
+	{ 0x71, 0x00 },
 	{ 0x3b, 0x21 },
-	{ 0x3c, 0x38 },
+	{ 0x3c, 0x3a },
 	{ 0x01, 0x0d },
-	{ 0x04, 0x08 }, { 0x05, 0x03 },
+	{ 0x04, 0x08 }, { 0x05, 0x05 },
 	{ 0x04, 0x0e }, { 0x05, 0x00 },
-	{ 0x04, 0x0f }, { 0x05, 0x37 },
-	{ 0x04, 0x0b }, { 0x05, 0x78 },
+	{ 0x04, 0x0f }, { 0x05, 0x14 },
+	{ 0x04, 0x0b }, { 0x05, 0x8c },
 	{ 0x04, 0x00 }, { 0x05, 0x00 },
-	{ 0x04, 0x01 }, { 0x05, 0x1e },
-	{ 0x04, 0x02 }, { 0x05, 0x07 },
-	{ 0x04, 0x03 }, { 0x05, 0xd0 },
+	{ 0x04, 0x01 }, { 0x05, 0x07 },
+	{ 0x04, 0x02 }, { 0x05, 0x0f },
+	{ 0x04, 0x03 }, { 0x05, 0xa0 },
 	{ 0x04, 0x09 }, { 0x05, 0x00 },
 	{ 0x04, 0x0a }, { 0x05, 0xff },
-	{ 0x04, 0x27 }, { 0x05, 0x00 },
+	{ 0x04, 0x27 }, { 0x05, 0x64 },
 	{ 0x04, 0x28 }, { 0x05, 0x00 },
-	{ 0x04, 0x1e }, { 0x05, 0x00 },
-	{ 0x04, 0x29 }, { 0x05, 0x64 },
-	{ 0x04, 0x32 }, { 0x05, 0x02 },
+	{ 0x04, 0x1e }, { 0x05, 0xff },
+	{ 0x04, 0x29 }, { 0x05, 0x0a },
+	{ 0x04, 0x32 }, { 0x05, 0x0a },
 	{ 0x04, 0x14 }, { 0x05, 0x02 },
 	{ 0x04, 0x04 }, { 0x05, 0x00 },
 	{ 0x04, 0x05 }, { 0x05, 0x22 },
@@ -97,8 +99,6 @@ static struct regdata mb86a20s_init2[] = {
 	{ 0x04, 0x07 }, { 0x05, 0xd8 },
 	{ 0x04, 0x12 }, { 0x05, 0x00 },
 	{ 0x04, 0x13 }, { 0x05, 0xff },
-	{ 0x04, 0x15 }, { 0x05, 0x4e },
-	{ 0x04, 0x16 }, { 0x05, 0x20 },
 
 	/*
 	 * On this demod, when the bit count reaches the count below,
@@ -152,42 +152,36 @@ static struct regdata mb86a20s_init2[] = {
 	{ 0x50, 0x51 }, { 0x51, 0x04 },		/* MER symbol 4 */
 	{ 0x45, 0x04 },				/* CN symbol 4 */
 	{ 0x48, 0x04 },				/* CN manual mode */
-
+	{ 0x50, 0xd5 }, { 0x51, 0x01 },
 	{ 0x50, 0xd6 }, { 0x51, 0x1f },
 	{ 0x50, 0xd2 }, { 0x51, 0x03 },
-	{ 0x50, 0xd7 }, { 0x51, 0xbf },
-	{ 0x28, 0x74 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0xff },
-	{ 0x28, 0x46 }, { 0x29, 0x00 }, { 0x2a, 0x1a }, { 0x2b, 0x0c },
-
-	{ 0x04, 0x40 }, { 0x05, 0x00 },
-	{ 0x28, 0x00 }, { 0x2b, 0x08 },
-	{ 0x28, 0x05 }, { 0x2b, 0x00 },
+	{ 0x50, 0xd7 }, { 0x51, 0x3f },
 	{ 0x1c, 0x01 },
-	{ 0x28, 0x06 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x1f },
-	{ 0x28, 0x07 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x18 },
-	{ 0x28, 0x08 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x12 },
-	{ 0x28, 0x09 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x30 },
-	{ 0x28, 0x0a }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x37 },
-	{ 0x28, 0x0b }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x02 },
-	{ 0x28, 0x0c }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x09 },
-	{ 0x28, 0x0d }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x06 },
-	{ 0x28, 0x0e }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x7b },
-	{ 0x28, 0x0f }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x76 },
-	{ 0x28, 0x10 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x7d },
-	{ 0x28, 0x11 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x08 },
-	{ 0x28, 0x12 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0b },
-	{ 0x28, 0x13 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x00 },
-	{ 0x28, 0x14 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xf2 },
-	{ 0x28, 0x15 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xf3 },
-	{ 0x28, 0x16 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x05 },
-	{ 0x28, 0x17 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x16 },
-	{ 0x28, 0x18 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0f },
-	{ 0x28, 0x19 }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xef },
-	{ 0x28, 0x1a }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xd8 },
-	{ 0x28, 0x1b }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xf1 },
-	{ 0x28, 0x1c }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x3d },
-	{ 0x28, 0x1d }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x94 },
-	{ 0x28, 0x1e }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0xba },
+	{ 0x28, 0x06 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x03 },
+	{ 0x28, 0x07 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0d },
+	{ 0x28, 0x08 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x02 },
+	{ 0x28, 0x09 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x01 },
+	{ 0x28, 0x0a }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x21 },
+	{ 0x28, 0x0b }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x29 },
+	{ 0x28, 0x0c }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x16 },
+	{ 0x28, 0x0d }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x31 },
+	{ 0x28, 0x0e }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0e },
+	{ 0x28, 0x0f }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x4e },
+	{ 0x28, 0x10 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x46 },
+	{ 0x28, 0x11 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x0f },
+	{ 0x28, 0x12 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x56 },
+	{ 0x28, 0x13 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x35 },
+	{ 0x28, 0x14 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xbe },
+	{ 0x28, 0x15 }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0x84 },
+	{ 0x28, 0x16 }, { 0x29, 0x00 }, { 0x2a, 0x03 }, { 0x2b, 0xee },
+	{ 0x28, 0x17 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x98 },
+	{ 0x28, 0x18 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x9f },
+	{ 0x28, 0x19 }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0xb2 },
+	{ 0x28, 0x1a }, { 0x29, 0x00 }, { 0x2a, 0x06 }, { 0x2b, 0xc2 },
+	{ 0x28, 0x1b }, { 0x29, 0x00 }, { 0x2a, 0x07 }, { 0x2b, 0x4a },
+	{ 0x28, 0x1c }, { 0x29, 0x00 }, { 0x2a, 0x01 }, { 0x2b, 0xbc },
+	{ 0x28, 0x1d }, { 0x29, 0x00 }, { 0x2a, 0x04 }, { 0x2b, 0xba },
+	{ 0x28, 0x1e }, { 0x29, 0x00 }, { 0x2a, 0x06 }, { 0x2b, 0x14 },
 	{ 0x50, 0x1e }, { 0x51, 0x5d },
 	{ 0x50, 0x22 }, { 0x51, 0x00 },
 	{ 0x50, 0x23 }, { 0x51, 0xc8 },
@@ -196,9 +190,7 @@ static struct regdata mb86a20s_init2[] = {
 	{ 0x50, 0x26 }, { 0x51, 0x00 },
 	{ 0x50, 0x27 }, { 0x51, 0xc3 },
 	{ 0x50, 0x39 }, { 0x51, 0x02 },
-	{ 0xec, 0x0f },
-	{ 0xeb, 0x1f },
-	{ 0x28, 0x6a }, { 0x29, 0x00 }, { 0x2a, 0x00 }, { 0x2b, 0x00 },
+	{ 0x50, 0xd5 }, { 0x51, 0x01 },
 	{ 0xd0, 0x00 },
 };
 
Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 7/12 cx231xx-core: fix GPIO comments

In reply to Mauro Carvalho Chehab

The number of the cx231xx REQ for GPIO register set/get are wrong. They should follow what's there at cx231xx-pcb-cfg.h.

Noticed while checking the cx231xx parser at the v4l-utils.

---
 drivers/media/usb/cx231xx/cx231xx-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/usb/cx231xx/cx231xx-core.c +4 -4
index 4b3acbd1d7f0..68b0df2814cf 100644
@@ -1460,14 +1460,14 @@ int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val,
 	/* set request */
 	if (!request) {
 		if (direction)
-			ven_req.bRequest = VRT_GET_GPIO;	/* 0x8 gpio */
+			ven_req.bRequest = VRT_GET_GPIO;	/* 0x9 gpio */
 		else
-			ven_req.bRequest = VRT_SET_GPIO;	/* 0x9 gpio */
+			ven_req.bRequest = VRT_SET_GPIO;	/* 0x8 gpio */
 	} else {
 		if (direction)
-			ven_req.bRequest = VRT_GET_GPIE;	/* 0xa gpie */
+			ven_req.bRequest = VRT_GET_GPIE;	/* 0xb gpie */
 		else
-			ven_req.bRequest = VRT_SET_GPIE;	/* 0xb gpie */
+			ven_req.bRequest = VRT_SET_GPIE;	/* 0xa gpie */
 	}
 
 	/* set index value */
Signature · 1 line
2.7.4
#8 lore raw

PATCH v2 8/12 cx231xx-i2c: handle errors with cx231xx_get_i2c_adap()

In reply to Mauro Carvalho Chehab

The cx231xx_get_i2c_adap() function should return the I2C adapter that will be used to talk with a device. It should never be NULL, as otherwise the driver will try to dereference a null pointer.

We might instead fix the callers, but if this condition ever happens, it is really a driver bug, because i2c_port should always be a value from enum CX231XX_I2C_MASTER_PORT.

Found when checking the code due to this bug:

[   39.769021] BUG: unable to handle kernel NULL pointer dereference at 0000000000000002
[   39.769105] IP: [<ffffffff81638393>] i2c_master_send+0x13/0x70
---
 drivers/media/usb/cx231xx/cx231xx-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx-i2c.c +1 -1
index 473cd3433fe5..3e7982ef180a 100644
@@ -608,7 +608,7 @@ struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
 	case I2C_1_MUX_3:
 		return dev->muxc->adapter[1];
 	default:
-		return NULL;
+		BUG();
 	}
 }
 EXPORT_SYMBOL_GPL(cx231xx_get_i2c_adap);
Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 9/12 cx231xx: can't proceed if I2C bus register fails

In reply to Mauro Carvalho Chehab

The driver should not ignore errors while registering the I2C bus, as this device can't even minimally work without the buses, as it uses those buses internally to talk with the several IP blocks inside the chip.

---
 drivers/media/usb/cx231xx/cx231xx-core.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/media/usb/cx231xx/cx231xx-core.c +19 -5
index 68b0df2814cf..03754c75454b 100644
@@ -1309,15 +1309,29 @@ int cx231xx_dev_init(struct cx231xx *dev)
 	dev->i2c_bus[2].i2c_reserve = 0;
 
 	/* register I2C buses */
-	cx231xx_i2c_register(&dev->i2c_bus[0]);
-	cx231xx_i2c_register(&dev->i2c_bus[1]);
-	cx231xx_i2c_register(&dev->i2c_bus[2]);
+	errCode = cx231xx_i2c_register(&dev->i2c_bus[0]);
+	if (errCode < 0)
+		return errCode;
+	errCode = cx231xx_i2c_register(&dev->i2c_bus[1]);
+	if (errCode < 0)
+		return errCode;
+	errCode = cx231xx_i2c_register(&dev->i2c_bus[2]);
+	if (errCode < 0)
+		return errCode;
 
 	errCode = cx231xx_i2c_mux_create(dev);
+	if (errCode < 0) {
+		dev_err(dev->dev,
+			"%s: Failed to create I2C mux\n", __func__);
+		return errCode;
+	}
+	errCode = cx231xx_i2c_mux_register(dev, 0);
+	if (errCode < 0)
+		return errCode;
+
+	errCode = cx231xx_i2c_mux_register(dev, 1);
 	if (errCode < 0)
 		return errCode;
-	cx231xx_i2c_mux_register(dev, 0);
-	cx231xx_i2c_mux_register(dev, 1);
 
 	/* scan the real bus segments in the order of physical port numbers */
 	cx231xx_do_i2c_scan(dev, I2C_0);
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 10/12 cx231xx-cards: unregister IR earlier

In reply to Mauro Carvalho Chehab
[ 1417.425863] cx231xx 1-3.1.4:1.1: Cx231xx dvb Extension removed
[ 1417.571923] BUG: unable to handle kernel paging request at ffffffffc081a024
[ 1417.571962] IP: [<ffffffff813da854>] string+0x24/0x80
[ 1417.571987] PGD 1c09067 PUD 1c0b067 PMD 88e653067 PTE 0
[ 1417.572013] Oops: 0000 [#1] SMP
[ 1417.572026] Modules linked in: mb86a20s dvb_core cx231xx_alsa ir_kbd_i2c(-) tda18271 tea5767 tuner cx25840 cx231xx i2c_mux videobuf_vmalloc tveeprom cx2341x videobuf_core rc_core v4l2_common videodev media bnep usblp fuse xt_CHECKSUM iptable_mangle tun ebtable_filter ebtables ip6table_filter ip6_tables xt_physdev br_netfilter bridge nf_log_ipv4 nf_log_common xt_LOG xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack cpufreq_stats vfat fat snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel snd_hda_intel snd_hda_codec kvm snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm irqbypass crct10dif_pclmul iTCO_wdt crc32_pclmul nfsd hci_uart iTCO_vendor_support
[ 1417.572317]  snd_timer ghash_clmulni_intel btbcm intel_cstate btqca snd intel_uncore btintel intel_rapl_perf mei_me bluetooth mei shpchp soundcore pcspkr i2c_i801 auth_rpcgss wmi acpi_als kfifo_buf nfs_acl industrialio rfkill lockd pinctrl_sunrisepoint pinctrl_intel tpm_tis tpm intel_lpss_acpi intel_lpss acpi_pad grace sunrpc binfmt_misc hid_logitech_hidpp hid_logitech_dj 8021q garp stp llc mrp i915 i2c_algo_bit drm_kms_helper drm e1000e sdhci_pci sdhci mmc_core crc32c_intel ptp pps_core video i2c_hid fjes analog gameport joydev [last unloaded: rc_pixelview_002t]
[ 1417.572487] CPU: 4 PID: 24493 Comm: rmmod Tainted: G        W       4.7.0+ #2
[ 1417.572504] Hardware name:                  /NUC6i7KYB, BIOS KYSKLi70.86A.0041.2016.0817.1130 08/17/2016
[ 1417.572526] task: ffff880894b81e80 ti: ffff880896bdc000 task.ti: ffff880896bdc000
[ 1417.572544] RIP: 0010:[<ffffffff813da854>]  [<ffffffff813da854>] string+0x24/0x80
[ 1417.572564] RSP: 0018:ffff880896bdfbe8  EFLAGS: 00010286
[ 1417.572577] RAX: ffffffffc081a025 RBX: ffff8808935aa15c RCX: ffff0a00ffffff04
[ 1417.572594] RDX: ffffffffc081a024 RSI: ffffffffffffffff RDI: ffff8808935aa15c
[ 1417.572610] RBP: ffff880896bdfbe8 R08: fffffffffffffffe R09: ffff8808935aa91c
[ 1417.572628] R10: ffffffffc07b85d6 R11: 0000000000000000 R12: ffff8808935aa91c
[ 1417.572644] R13: 00000000000007c5 R14: ffffffffc07b85dd R15: ffffffffc07b85dd
[ 1417.572662] FS:  00007f5a5392d700(0000) GS:ffff8808bed00000(0000) knlGS:0000000000000000
[ 1417.572681] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1417.572705] CR2: ffffffffc081a024 CR3: 0000000897188000 CR4: 00000000003406e0
[ 1417.572735] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1417.572761] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 1417.572778] Stack:
[ 1417.572785]  ffff880896bdfc48 ffffffff813dcf77 0000000000000005 ffff8808935aa157
[ 1417.572806]  ffff880896bdfc58 ffff0a00ffffff04 000000009d27375e ffff8808935aa000
[ 1417.572829]  0000000000000800 ffff880896182800 0000000000000000 ffff88089e898ae0
[ 1417.572850] Call Trace:
[ 1417.572860]  [<ffffffff813dcf77>] vsnprintf+0x2d7/0x500
[ 1417.572873]  [<ffffffff813d3e12>] add_uevent_var+0x82/0x120
[ 1417.572890]  [<ffffffffc07b534d>] rc_dev_uevent+0x2d/0x60 [rc_core]
[ 1417.572907]  [<ffffffff81515969>] dev_uevent+0xd9/0x2d0
[ 1417.572921]  [<ffffffff813d4309>] kobject_uevent_env+0x2d9/0x4f0
[ 1417.572938]  [<ffffffff813d452b>] kobject_uevent+0xb/0x10
[ 1417.572954]  [<ffffffff81513a3f>] device_del+0x18f/0x260
[ 1417.572974]  [<ffffffff813d2db7>] ? kobject_put+0x27/0x50
[ 1417.572998]  [<ffffffffc07b5e25>] rc_unregister_device+0x75/0xb0 [rc_core]
[ 1417.573028]  [<ffffffffc07e6023>] ir_remove+0x23/0x30 [ir_kbd_i2c]
[ 1417.573055]  [<ffffffff8162bf88>] i2c_device_remove+0x58/0xb0
[ 1417.573078]  [<ffffffff81518191>] __device_release_driver+0xa1/0x160
[ 1417.573102]  [<ffffffff81518de6>] driver_detach+0xa6/0xb0
[ 1417.573122]  [<ffffffff81517b25>] bus_remove_driver+0x55/0xd0
[ 1417.573146]  [<ffffffff815195bc>] driver_unregister+0x2c/0x50
[ 1417.573168]  [<ffffffff8162cf62>] i2c_del_driver+0x22/0x50
[ 1417.573194]  [<ffffffffc07e6ba4>] ir_kbd_driver_exit+0x10/0x46c [ir_kbd_i2c]
[ 1417.573227]  [<ffffffff81126348>] SyS_delete_module+0x1b8/0x220
[ 1417.573254]  [<ffffffff817debf2>] entry_SYSCALL_64_fastpath+0x1a/0xa4
[ 1417.573279] Code: eb e9 76 ff ff ff 90 55 49 89 f1 48 89 ce 48 c1 fe 30 48 81 fa ff 0f 00 00 48 89 e5 4c 8d 46 ff 76 40 48 85 f6 74 4e 48 8d 42 01 <0f> b6 12 84 d2 74 43 49 01 c0 31 f6 eb 0c 48 83 c0 01 0f b6 50
[ 1417.573437] RIP  [<ffffffff813da854>] string+0x24/0x80
[ 1417.573455]  RSP <ffff880896bdfbe8>
[ 1417.573465] CR2: ffffffffc081a024
[ 1417.580053] ---[ end trace 4ca9e2eced326a62 ]---
---
 drivers/media/usb/cx231xx/cx231xx-cards.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/cx231xx/cx231xx-cards.c +2 -2
index 72c246bfaa1c..36bc25494319 100644
@@ -1186,12 +1186,12 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev)
 */
 void cx231xx_release_resources(struct cx231xx *dev)
 {
+	cx231xx_ir_exit(dev);
+
 	cx231xx_release_analog_resources(dev);
 
 	cx231xx_remove_from_devlist(dev);
 
-	cx231xx_ir_exit(dev);
-
 	/* Release I2C buses */
 	cx231xx_dev_uninit(dev);
 
Signature · 1 line
2.7.4
#11 lore raw

PATCH v2 11/12 tda18271: use prefix on all printk messages

In reply to Mauro Carvalho Chehab

Some messages have a hardcoded prefix; others not. Use the pr_fmt() to ensure that all messages will use the same prefix.

---
 drivers/media/tuners/tda18271-fe.c   | 11 ++++++-----
 drivers/media/tuners/tda18271-priv.h |  2 ++
 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/media/tuners/tda18271-fe.c +6 -5
index f8620741bb5f..2d50e8b1dce1 100644
@@ -18,11 +18,12 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#include <linux/delay.h>
-#include <linux/videodev2.h>
 #include "tda18271-priv.h"
 #include "tda8290.h"
 
+#include <linux/delay.h>
+#include <linux/videodev2.h>
+
 int tda18271_debug;
 module_param_named(debug, tda18271_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debug level "
@@ -646,7 +647,7 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe)
 	unsigned int i;
 	int ret;
 
-	tda_info("tda18271: performing RF tracking filter calibration\n");
+	tda_info("performing RF tracking filter calibration\n");
 
 	/* wait for die temperature stabilization */
 	msleep(200);
@@ -692,12 +693,12 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe)
 	if (tda_fail(ret))
 		goto fail;
 
-	tda_info("tda18271: RF tracking filter calibration complete\n");
+	tda_info("RF tracking filter calibration complete\n");
 
 	priv->cal_initialized = true;
 	goto end;
 fail:
-	tda_info("tda18271: RF tracking filter calibration failed!\n");
+	tda_info("RF tracking filter calibration failed!\n");
 end:
 	return ret;
 }
drivers/media/tuners/tda18271-priv.h +2 -0
index cc80f544af34..0bcc735a0427 100644
@@ -21,6 +21,8 @@
 #ifndef __TDA18271_PRIV_H__
 #define __TDA18271_PRIV_H__
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/mutex.h>
Signature · 1 line
2.7.4
#12 lore raw

PATCH v2 12/12 tea5767: use module prefix on printed messages

In reply to Mauro Carvalho Chehab

use pr_fmt() & friends for error messages to output like:

[    9.651721] tea5767: Chip ID is not zero. It is not a TEA5767
---
 drivers/media/tuners/tea5767.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/tuners/tea5767.c +6 -3
index 36e85d81acb2..cd535cd4c071 100644
@@ -10,6 +10,8 @@
  * from their contributions on DScaler.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
@@ -370,17 +372,18 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
 {
 	struct tuner_i2c_props i2c = { .adap = i2c_adap, .addr = i2c_addr };
 	unsigned char buffer[7] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
 	int rc;
 
 	if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) {
-		printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc);
+		pr_warn("It is not a TEA5767. Received %i bytes.\n", rc);
 		return -EINVAL;
 	}
 
 	/* If all bytes are the same then it's a TV tuner and not a tea5767 */
 	if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
 	    buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
-		printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n");
+		pr_warn("All bytes are equal. It is not a TEA5767\n");
 		return -EINVAL;
 	}
 
@@ -390,7 +393,7 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
 	 *  Byte 5: bit 7:0 : == 0
 	 */
 	if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) {
-		printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n");
+		pr_warn("Chip ID is not zero. It is not a TEA5767\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.7.4