From patchwork Sun Jan 16 11:22:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bunk X-Patchwork-Id: 80019 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1n93jn-00BrS0-8U; Sun, 16 Jan 2022 11:30:20 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234880AbiAPLaR (ORCPT + 1 other); Sun, 16 Jan 2022 06:30:17 -0500 Received: from mcv99outg.rz.uni-leipzig.de ([139.18.1.195]:59315 "EHLO mcv99outg.rz.uni-leipzig.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbiAPLaP (ORCPT ); Sun, 16 Jan 2022 06:30:15 -0500 Received: from mcv2outg.rz.uni-leipzig.de (mcv2outg.rz.uni-leipzig.de [139.18.1.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mcv99outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCMm3tNgz11Hb for ; Sun, 16 Jan 2022 12:23:32 +0100 (CET) Received: from v1.rz.uni-leipzig.de (v1.rz.uni-leipzig.de [139.18.1.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mcv2outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCMl3WpYz11Q9; Sun, 16 Jan 2022 12:23:31 +0100 (CET) Received: from server1.rz.uni-leipzig.de (server1.rz.uni-leipzig.de [139.18.1.1]) by v1.rz.uni-leipzig.de (Postfix) with ESMTPS id 60964205F2; Sun, 16 Jan 2022 12:23:31 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (gg1.iat.uni-leipzig.de [141.39.226.97]) by server1.rz.uni-leipzig.de (Postfix) with ESMTPS id 7148194004; Sun, 16 Jan 2022 12:23:29 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (localhost [127.0.0.1]) by gg1.iat.uni-leipzig.de (Postfix) with ESMTP id 5347C840798; Sun, 16 Jan 2022 12:23:29 +0100 (CET) Received: (from localhost) by gg1.iat.uni-leipzig.de (MSCAN) id 6/gg1.iat.uni-leipzig.de/smtp-gw/mscan; Sun Jan 16 12:23:29 2022 From: Michael Bunk To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: vasilyev@ispras.ru, crope@iki.fi, Michael Bunk Subject: [PATCH 1/4] media: m88ds3103: Fix lock led support Date: Sun, 16 Jan 2022 12:22:35 +0100 Message-Id: <20220116112238.74171-1-micha@freedict.org> MIME-Version: 1.0 X-Rspamd-Score: 0.00 X-ExSBR-Direction: Incoming X-Rspamd-UID: 1f0b6b Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.4 (-------) X-LSpam-Report: No, score=-7.4 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no The new m88ds3101b demodulator version requires the highest bit of register 0x11 be cleared after tuning to a new frequency to make the lock output pin go high when a signal is found. This pin is normally connected to an indicator led. Signed-off-by: Michael Bunk --- drivers/media/dvb-frontends/m88ds3103.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c index bce0f42f3d19..b5e3b4b81350 100644 --- a/drivers/media/dvb-frontends/m88ds3103.c +++ b/drivers/media/dvb-frontends/m88ds3103.c @@ -1000,6 +1000,13 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) if (ret) goto err; + if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { + /* to light up the LOCK led */ + ret = m88ds3103_update_bits(dev, 0x11, 0x80, 0x00); + if (ret) + goto err; + } + dev->delivery_system = c->delivery_system; return 0; From patchwork Sun Jan 16 11:22:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bunk X-Patchwork-Id: 80020 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1n93js-00BrSI-Fz; Sun, 16 Jan 2022 11:30:25 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234882AbiAPLaW (ORCPT + 1 other); Sun, 16 Jan 2022 06:30:22 -0500 Received: from mcv99outg.rz.uni-leipzig.de ([139.18.1.195]:37371 "EHLO mcv99outg.rz.uni-leipzig.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbiAPLaV (ORCPT ); Sun, 16 Jan 2022 06:30:21 -0500 Received: from mcv2outg.rz.uni-leipzig.de (mcv2outg.rz.uni-leipzig.de [139.18.1.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mcv99outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCMq0t7Tz11Hw for ; Sun, 16 Jan 2022 12:23:35 +0100 (CET) Received: from v1.rz.uni-leipzig.de (v1.rz.uni-leipzig.de [139.18.1.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mcv2outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCMl3WvBz11QQ; Sun, 16 Jan 2022 12:23:31 +0100 (CET) Received: from server1.rz.uni-leipzig.de (server1.rz.uni-leipzig.de [139.18.1.1]) by v1.rz.uni-leipzig.de (Postfix) with ESMTPS id 6BAC121385; Sun, 16 Jan 2022 12:23:31 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (gg1.iat.uni-leipzig.de [141.39.226.97]) by server1.rz.uni-leipzig.de (Postfix) with ESMTPS id 6EDA294003; Sun, 16 Jan 2022 12:23:29 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (localhost [127.0.0.1]) by gg1.iat.uni-leipzig.de (Postfix) with ESMTP id 5645B840799; Sun, 16 Jan 2022 12:23:29 +0100 (CET) Received: (from localhost) by gg1.iat.uni-leipzig.de (MSCAN) id 6/gg1.iat.uni-leipzig.de/smtp-gw/mscan; Sun Jan 16 12:23:29 2022 From: Michael Bunk To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: vasilyev@ispras.ru, crope@iki.fi, Michael Bunk Subject: [PATCH 2/4] media: dw2102: Don't translate i2c read into write Date: Sun, 16 Jan 2022 12:22:36 +0100 Message-Id: <20220116112238.74171-2-micha@freedict.org> In-Reply-To: <20220116112238.74171-1-micha@freedict.org> References: <20220116112238.74171-1-micha@freedict.org> MIME-Version: 1.0 X-Rspamd-Score: 0.00 X-ExSBR-Direction: Incoming X-Rspamd-UID: da8653 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.4 (-------) X-LSpam-Report: No, score=-7.4 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no The code ignored the I2C_M_RD flag on I2C messages. Instead it assumed an i2c transaction with a single message must be a write operation and a transaction with two messages would be a read operation. Though this works for the driver code, it leads to problems once the i2c device is exposed to code not knowing this convention. For example, I did "insmod i2c-dev" and issued read requests from userspace, which were translated into write requests and destroyed the EEPROM of my device. So, just check and respect the I2C_M_READ flag, which indicates a read when set on a message. If it is absent, it is a write message. Incidentally, changing from the case statement to a while loop allows the code to lift the limitation to two i2c messages per transaction. There are 4 more *_i2c_transfer functions affected by the same behaviour and limitation that should be fixed in the same way. Signed-off-by: Michael Bunk --- drivers/media/usb/dvb-usb/dw2102.c | 120 ++++++++++++++++++----------- 1 file changed, 73 insertions(+), 47 deletions(-) diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c index ca75ebdc10b3..60dd82f9dedc 100644 --- a/drivers/media/usb/dvb-usb/dw2102.c +++ b/drivers/media/usb/dvb-usb/dw2102.c @@ -692,6 +692,7 @@ static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], { struct dvb_usb_device *d = i2c_get_adapdata(adap); struct dw2102_state *state; + int j; if (!d) return -ENODEV; @@ -705,11 +706,11 @@ static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], return -EAGAIN; } - switch (num) { - case 1: - switch (msg[0].addr) { + j = 0; + while (j < num) { + switch (msg[j].addr) { case SU3000_STREAM_CTRL: - state->data[0] = msg[0].buf[0] + 0x36; + state->data[0] = msg[j].buf[0] + 0x36; state->data[1] = 3; state->data[2] = 0; if (dvb_usb_generic_rw(d, state->data, 3, @@ -721,61 +722,86 @@ static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], if (dvb_usb_generic_rw(d, state->data, 1, state->data, 2, 0) < 0) err("i2c transfer failed."); - msg[0].buf[1] = state->data[0]; - msg[0].buf[0] = state->data[1]; + msg[j].buf[1] = state->data[0]; + msg[j].buf[0] = state->data[1]; break; default: - if (3 + msg[0].len > sizeof(state->data)) { - warn("i2c wr: len=%d is too big!\n", - msg[0].len); + /* if the current write msg is followed by a another + * read msg to/from the same address + */ + if ((j+1 < num) && (msg[j+1].flags & I2C_M_RD) && + (msg[j].addr == msg[j+1].addr)) { + /* join both i2c msgs to one usb read command */ + if (4 + msg[j].len > sizeof(state->data)) { + warn("i2c combined wr/rd: write len=%d is too big!\n", + msg[j].len); + num = -EOPNOTSUPP; + break; + } + if (1 + msg[j+1].len > sizeof(state->data)) { + warn("i2c combined wr/rd: read len=%d is too big!\n", + msg[j+1].len); + num = -EOPNOTSUPP; + break; + } + + state->data[0] = 0x09; + state->data[1] = msg[j].len; + state->data[2] = msg[j+1].len; + state->data[3] = msg[j].addr; + memcpy(&state->data[4], msg[j].buf, msg[j].len); + + if (dvb_usb_generic_rw(d, state->data, msg[j].len + 4, + state->data, msg[j+1].len + 1, 0) < 0) + err("i2c transfer failed."); + + memcpy(msg[j+1].buf, &state->data[1], msg[j+1].len); + j++; + break; + } + + if (msg[j].flags & I2C_M_RD) { + /* single read */ + if (1 + msg[j].len > sizeof(state->data)) { + warn("i2c rd: len=%d is too big!\n", msg[j].len); + num = -EOPNOTSUPP; + break; + } + + state->data[0] = 0x09; + state->data[1] = 0; + state->data[2] = msg[j].len; + state->data[3] = msg[j].addr; + memcpy(&state->data[4], msg[j].buf, msg[j].len); + + if (dvb_usb_generic_rw(d, state->data, 4, + state->data, msg[j].len + 1, 0) < 0) + err("i2c transfer failed."); + + memcpy(msg[j].buf, &state->data[1], msg[j].len); + break; + } + + /* single write */ + if (3 + msg[j].len > sizeof(state->data)) { + warn("i2c wr: len=%d is too big!\n", msg[j].len); num = -EOPNOTSUPP; break; } - /* always i2c write*/ state->data[0] = 0x08; - state->data[1] = msg[0].addr; - state->data[2] = msg[0].len; + state->data[1] = msg[j].addr; + state->data[2] = msg[j].len; - memcpy(&state->data[3], msg[0].buf, msg[0].len); + memcpy(&state->data[3], msg[j].buf, msg[j].len); - if (dvb_usb_generic_rw(d, state->data, msg[0].len + 3, + if (dvb_usb_generic_rw(d, state->data, msg[j].len + 3, state->data, 1, 0) < 0) err("i2c transfer failed."); + } // switch + j++; - } - break; - case 2: - /* always i2c read */ - if (4 + msg[0].len > sizeof(state->data)) { - warn("i2c rd: len=%d is too big!\n", - msg[0].len); - num = -EOPNOTSUPP; - break; - } - if (1 + msg[1].len > sizeof(state->data)) { - warn("i2c rd: len=%d is too big!\n", - msg[1].len); - num = -EOPNOTSUPP; - break; - } - - state->data[0] = 0x09; - state->data[1] = msg[0].len; - state->data[2] = msg[1].len; - state->data[3] = msg[0].addr; - memcpy(&state->data[4], msg[0].buf, msg[0].len); - - if (dvb_usb_generic_rw(d, state->data, msg[0].len + 4, - state->data, msg[1].len + 1, 0) < 0) - err("i2c transfer failed."); - - memcpy(msg[1].buf, &state->data[1], msg[1].len); - break; - default: - warn("more than 2 i2c messages at a time is not handled yet."); - break; - } + } // while mutex_unlock(&d->data_mutex); mutex_unlock(&d->i2c_mutex); return num; From patchwork Sun Jan 16 11:22:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bunk X-Patchwork-Id: 80018 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1n93ji-00BrRi-Qd; Sun, 16 Jan 2022 11:30:15 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234878AbiAPLaK (ORCPT + 1 other); Sun, 16 Jan 2022 06:30:10 -0500 Received: from mcv99outg.rz.uni-leipzig.de ([139.18.1.195]:50335 "EHLO mcv99outg.rz.uni-leipzig.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbiAPLaK (ORCPT ); Sun, 16 Jan 2022 06:30:10 -0500 X-Greylist: delayed 398 seconds by postgrey-1.27 at vger.kernel.org; Sun, 16 Jan 2022 06:30:10 EST Received: from mcv1outg.rz.uni-leipzig.de (mcv1outg.rz.uni-leipzig.de [139.18.1.193]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mcv99outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCN323LHz11JJ for ; Sun, 16 Jan 2022 12:23:47 +0100 (CET) Received: from v1.rz.uni-leipzig.de (v1.rz.uni-leipzig.de [139.18.1.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mcv1outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCN21Dk5z11J9; Sun, 16 Jan 2022 12:23:46 +0100 (CET) Received: from server1.rz.uni-leipzig.de (server1.rz.uni-leipzig.de [139.18.1.1]) by v1.rz.uni-leipzig.de (Postfix) with ESMTPS id 28DD1205F2; Sun, 16 Jan 2022 12:23:46 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (gg1.iat.uni-leipzig.de [141.39.226.97]) by server1.rz.uni-leipzig.de (Postfix) with ESMTPS id 5C03F94002; Sun, 16 Jan 2022 12:23:44 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (localhost [127.0.0.1]) by gg1.iat.uni-leipzig.de (Postfix) with ESMTP id 54F76840798; Sun, 16 Jan 2022 12:23:44 +0100 (CET) Received: (from localhost) by gg1.iat.uni-leipzig.de (MSCAN) id 6/gg1.iat.uni-leipzig.de/smtp-gw/mscan; Sun Jan 16 12:23:44 2022 From: Michael Bunk To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: vasilyev@ispras.ru, crope@iki.fi, Michael Bunk Subject: [PATCH 3/4] media: dw2102: Dont't list TT Cinergy S2 R4 twice Date: Sun, 16 Jan 2022 12:22:37 +0100 Message-Id: <20220116112238.74171-3-micha@freedict.org> In-Reply-To: <20220116112238.74171-1-micha@freedict.org> References: <20220116112238.74171-1-micha@freedict.org> MIME-Version: 1.0 X-Rspamd-Score: 0.00 X-ExSBR-Direction: Incoming X-Rspamd-UID: be3120 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.4 (-------) X-LSpam-Report: No, score=-7.4 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no "modinfo dvb-usb-dw2102|grep 0105" returns two lines, because the module reports this usb alias twice. Remove one of them. Signed-off-by: Michael Bunk --- drivers/media/usb/dvb-usb/dw2102.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c index 60dd82f9dedc..165d72d6d712 100644 --- a/drivers/media/usb/dvb-usb/dw2102.c +++ b/drivers/media/usb/dvb-usb/dw2102.c @@ -1813,7 +1813,6 @@ enum dw2102_table_entry { TECHNOTREND_S2_4600, TEVII_S482_1, TEVII_S482_2, - TERRATEC_CINERGY_S2_BOX, TEVII_S662 }; @@ -1852,7 +1851,6 @@ static struct usb_device_id dw2102_table[] = { USB_PID_TECHNOTREND_CONNECT_S2_4600)}, [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)}, [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)}, - [TERRATEC_CINERGY_S2_BOX] = {USB_DEVICE(USB_VID_TERRATEC, 0x0105)}, [TEVII_S662] = {USB_DEVICE(0x9022, USB_PID_TEVII_S662)}, { } }; @@ -2563,7 +2561,7 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = { { NULL }, }, { "Terratec Cinergy S2 USB BOX", - { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL }, + { &dw2102_table[TERRATEC_CINERGY_S2_R4], NULL }, { NULL }, }, { "TeVii S662", From patchwork Sun Jan 16 11:22:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Bunk X-Patchwork-Id: 80021 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1n93jx-00BrSI-GB; Sun, 16 Jan 2022 11:30:30 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234902AbiAPLa2 (ORCPT + 1 other); Sun, 16 Jan 2022 06:30:28 -0500 Received: from mcv99outg.rz.uni-leipzig.de ([139.18.1.195]:35939 "EHLO mcv99outg.rz.uni-leipzig.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234901AbiAPLa1 (ORCPT ); Sun, 16 Jan 2022 06:30:27 -0500 Received: from mcv2outg.rz.uni-leipzig.de (mcv2outg.rz.uni-leipzig.de [139.18.1.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mcv99outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCN32ZSMz11JT for ; Sun, 16 Jan 2022 12:23:47 +0100 (CET) Received: from v1.rz.uni-leipzig.de (v1.rz.uni-leipzig.de [139.18.1.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mcv2outg.rz.uni-leipzig.de (Postfix) with ESMTPS id 4JcCN22Pc4z11Q9; Sun, 16 Jan 2022 12:23:46 +0100 (CET) Received: from server1.rz.uni-leipzig.de (server1.rz.uni-leipzig.de [139.18.1.1]) by v1.rz.uni-leipzig.de (Postfix) with ESMTPS id 5112D205F2; Sun, 16 Jan 2022 12:23:46 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (gg1.iat.uni-leipzig.de [141.39.226.97]) by server1.rz.uni-leipzig.de (Postfix) with ESMTPS id 5D1D394003; Sun, 16 Jan 2022 12:23:44 +0100 (CET) Received: from gg1.iat.uni-leipzig.de (localhost [127.0.0.1]) by gg1.iat.uni-leipzig.de (Postfix) with ESMTP id 5608284079B; Sun, 16 Jan 2022 12:23:44 +0100 (CET) Received: (from localhost) by gg1.iat.uni-leipzig.de (MSCAN) id 6/gg1.iat.uni-leipzig.de/smtp-gw/mscan; Sun Jan 16 12:23:44 2022 From: Michael Bunk To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: vasilyev@ispras.ru, crope@iki.fi, Michael Bunk Subject: [PATCH 4/4] media: dw2102: Fix minor issues Date: Sun, 16 Jan 2022 12:22:38 +0100 Message-Id: <20220116112238.74171-4-micha@freedict.org> In-Reply-To: <20220116112238.74171-1-micha@freedict.org> References: <20220116112238.74171-1-micha@freedict.org> MIME-Version: 1.0 X-Rspamd-Score: 0.00 X-ExSBR-Direction: Incoming X-Rspamd-UID: 3b06fc Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -7.4 (-------) X-LSpam-Report: No, score=-7.4 required=5.0 tests=BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_HI=-5,UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no Found by checkpatch. Signed-off-by: Michael Bunk --- drivers/media/usb/dvb-usb/dw2102.c | 106 +++++++++++++++-------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c index 165d72d6d712..79a6675877a2 100644 --- a/drivers/media/usb/dvb-usb/dw2102.c +++ b/drivers/media/usb/dvb-usb/dw2102.c @@ -53,10 +53,10 @@ #define DW2102_FIRMWARE "dvb-usb-dw2102.fw" #define DW2104_FIRMWARE "dvb-usb-dw2104.fw" #define DW3101_FIRMWARE "dvb-usb-dw3101.fw" -#define S630_FIRMWARE "dvb-usb-s630.fw" -#define S660_FIRMWARE "dvb-usb-s660.fw" -#define P1100_FIRMWARE "dvb-usb-p1100.fw" -#define P7500_FIRMWARE "dvb-usb-p7500.fw" +#define S630_FIRMWARE "dvb-usb-s630.fw" +#define S660_FIRMWARE "dvb-usb-s660.fw" +#define P1100_FIRMWARE "dvb-usb-p1100.fw" +#define P7500_FIRMWARE "dvb-usb-p7500.fw" #define err_str "did not find the firmware file '%s'. You can use /scripts/get_dvb_firmware to get the firmware" @@ -87,7 +87,7 @@ MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+s DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, - u16 index, u8 * data, u16 len, int flags) + u16 index, u8 *data, u16 len, int flags) { int ret; u8 *u8buf; @@ -103,7 +103,7 @@ static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value, if (flags == DW210X_WRITE_MSG) memcpy(u8buf, data, len); ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR, - value, index , u8buf, len, 2000); + value, index, u8buf, len, 2000); if (flags == DW210X_READ_MSG) memcpy(data, u8buf, len); @@ -298,7 +298,7 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms dw210x_op_rw(d->udev, 0xc2, 0, 0, obuf, msg[0].len + 2, DW210X_WRITE_MSG); /* second read registers */ - dw210x_op_rw(d->udev, 0xc3, 0xd1 , 0, + dw210x_op_rw(d->udev, 0xc3, 0xd1, 0, ibuf, msg[1].len + 2, DW210X_READ_MSG); memcpy(msg[1].buf, ibuf + 2, msg[1].len); @@ -344,13 +344,15 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms } case(DW2102_RC_QUERY): { u8 ibuf[2]; + dw210x_op_rw(d->udev, 0xb8, 0, 0, ibuf, 2, DW210X_READ_MSG); - memcpy(msg[0].buf, ibuf , 2); + memcpy(msg[0].buf, ibuf, 2); break; } case(DW2102_VOLTAGE_CTRL): { u8 obuf[2]; + obuf[0] = 0x30; obuf[1] = msg[0].buf[0]; dw210x_op_rw(d->udev, 0xb2, 0, 0, @@ -382,23 +384,26 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i switch (msg[j].addr) { case(DW2102_RC_QUERY): { u8 ibuf[2]; + dw210x_op_rw(d->udev, 0xb8, 0, 0, ibuf, 2, DW210X_READ_MSG); - memcpy(msg[j].buf, ibuf , 2); + memcpy(msg[j].buf, ibuf, 2); break; } case(DW2102_VOLTAGE_CTRL): { u8 obuf[2]; + obuf[0] = 0x30; obuf[1] = msg[j].buf[0]; dw210x_op_rw(d->udev, 0xb2, 0, 0, obuf, 2, DW210X_WRITE_MSG); break; } - /*case 0x55: cx24116 - case 0x6a: stv0903 - case 0x68: ds3000, stv0903 - case 0x60: ts2020, stv6110, stb6100 */ + /* case 0x55: cx24116 + * case 0x6a: stv0903 + * case 0x68: ds3000, stv0903 + * case 0x60: ts2020, stv6110, stb6100 + */ default: { if (msg[j].flags == I2C_M_RD) { /* read registers */ @@ -423,6 +428,7 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i (msg[j].addr == 0x55))) { /* write firmware */ u8 obuf[19]; + obuf[0] = msg[j].addr << 1; obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len); obuf[2] = msg[j].buf[0]; @@ -503,7 +509,7 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], dw210x_op_rw(d->udev, 0xc2, 0, 0, obuf, msg[0].len + 2, DW210X_WRITE_MSG); /* second read registers */ - dw210x_op_rw(d->udev, 0xc3, 0x19 , 0, + dw210x_op_rw(d->udev, 0xc3, 0x19, 0, ibuf, msg[1].len + 2, DW210X_READ_MSG); memcpy(msg[1].buf, ibuf + 2, msg[1].len); @@ -531,9 +537,10 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], } case(DW2102_RC_QUERY): { u8 ibuf[2]; + dw210x_op_rw(d->udev, 0xb8, 0, 0, ibuf, 2, DW210X_READ_MSG); - memcpy(msg[0].buf, ibuf , 2); + memcpy(msg[0].buf, ibuf, 2); break; } } @@ -570,6 +577,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], switch (msg[j].addr) { case (DW2102_RC_QUERY): { u8 ibuf[5]; + dw210x_op_rw(d->udev, 0xb8, 0, 0, ibuf, 5, DW210X_READ_MSG); memcpy(msg[j].buf, ibuf + 3, 2); @@ -597,11 +605,12 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], obuf, 2, DW210X_WRITE_MSG); break; } - /*case 0x55: cx24116 - case 0x6a: stv0903 - case 0x68: ds3000, stv0903, rs2000 - case 0x60: ts2020, stv6110, stb6100 - case 0xa0: eeprom */ + /* case 0x55: cx24116 + * case 0x6a: stv0903 + * case 0x68: ds3000, stv0903, rs2000 + * case 0x60: ts2020, stv6110, stb6100 + * case 0xa0: eeprom + */ default: { if (msg[j].flags == I2C_M_RD) { /* read registers */ @@ -623,6 +632,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], (msg[j].addr == 0x68)) { /* write firmware */ u8 obuf[19]; + obuf[0] = (msg[j].len > 16 ? 18 : msg[j].len + 1); obuf[1] = msg[j].addr << 1; @@ -854,13 +864,13 @@ static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) u8 eeprom[256], eepromline[16]; for (i = 0; i < 256; i++) { - if (dw210x_op_rw(d->udev, 0xb6, 0xa0 , i, ibuf, 2, DW210X_READ_MSG) < 0) { + if (dw210x_op_rw(d->udev, 0xb6, 0xa0, i, ibuf, 2, DW210X_READ_MSG) < 0) { err("read eeprom failed."); return -1; - } else { - eepromline[i%16] = ibuf[0]; - eeprom[i] = ibuf[0]; } + eepromline[i%16] = ibuf[0]; + eeprom[i] = ibuf[0]; + if ((i % 16) == 15) { deb_xfer("%02x: ", i - 15); debug_dump(eepromline, 16, deb_xfer); @@ -896,11 +906,11 @@ static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) if (ret != 2) { err("read eeprom failed."); return -1; - } else { - eepromline[i % 16] = ibuf[0]; - eeprom[i] = ibuf[0]; } + eepromline[i % 16] = ibuf[0]; + eeprom[i] = ibuf[0]; + if ((i % 16) == 15) { deb_xfer("%02x: ", i - 15); debug_dump(eepromline, 16, deb_xfer); @@ -973,8 +983,7 @@ static int su3000_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) obuf[1] = 0xf0 + i; if (i2c_transfer(&d->i2c_adap, msg, 2) != 2) break; - else - mac[i] = ibuf[0]; + mac[i] = ibuf[0]; } return 0; @@ -985,8 +994,6 @@ static int su3000_identify_state(struct usb_device *udev, const struct dvb_usb_device_description **desc, int *cold) { - info("%s", __func__); - *cold = 0; return 0; } @@ -1346,7 +1353,7 @@ static int stv0288_frontend_attach(struct dvb_usb_adapter *d) if (d->fe_adap[0].fe == NULL) return -EIO; - if (NULL == dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap)) + if (dvb_attach(stb6000_attach, d->fe_adap[0].fe, 0x61, &d->dev->i2c_adap) == NULL) return -EIO; d->fe_adap[0].fe->ops.set_voltage = dw210x_set_voltage; @@ -1889,7 +1896,7 @@ static int dw2102_load_firmware(struct usb_device *dev, memcpy(p, fw->data, fw->size); for (i = 0; i < fw->size; i += 0x40) { b = (u8 *) p + i; - if (dw210x_op_rw(dev, 0xa0, i, 0, b , 0x40, + if (dw210x_op_rw(dev, 0xa0, i, 0, b, 0x40, DW210X_WRITE_MSG) != 0x40) { err("error while transferring firmware"); ret = -EINVAL; @@ -1936,19 +1943,18 @@ static int dw2102_load_firmware(struct usb_device *dev, dw2102_properties.i2c_algo = &dw2102_i2c_algo; dw2102_properties.adapter->fe[0].tuner_attach = &dw2102_tuner_attach; break; - } else { - /* check STV0288 frontend */ - reset16[0] = 0xd0; - reset16[1] = 1; - reset16[2] = 0; - dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, - DW210X_WRITE_MSG); - dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, - DW210X_READ_MSG); - if (reset16[2] == 0x11) { - dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; - break; - } + } + /* check STV0288 frontend */ + reset16[0] = 0xd0; + reset16[1] = 1; + reset16[2] = 0; + dw210x_op_rw(dev, 0xc2, 0, 0, &reset16[0], 3, + DW210X_WRITE_MSG); + dw210x_op_rw(dev, 0xc3, 0xd1, 0, &reset16[0], 3, + DW210X_READ_MSG); + if (reset16[2] == 0x11) { + dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo; + break; } fallthrough; case 0x2101: @@ -2575,15 +2581,15 @@ static int dw2102_probe(struct usb_interface *intf, const struct usb_device_id *id) { if (!(dvb_usb_device_init(intf, &dw2102_properties, - THIS_MODULE, NULL, adapter_nr) && + THIS_MODULE, NULL, adapter_nr) && dvb_usb_device_init(intf, &dw2104_properties, THIS_MODULE, NULL, adapter_nr) && dvb_usb_device_init(intf, &dw3101_properties, - THIS_MODULE, NULL, adapter_nr) && + THIS_MODULE, NULL, adapter_nr) && dvb_usb_device_init(intf, &s6x0_properties, - THIS_MODULE, NULL, adapter_nr) && + THIS_MODULE, NULL, adapter_nr) && dvb_usb_device_init(intf, &p1100_properties, - THIS_MODULE, NULL, adapter_nr) && + THIS_MODULE, NULL, adapter_nr) && dvb_usb_device_init(intf, &s660_properties, THIS_MODULE, NULL, adapter_nr) && dvb_usb_device_init(intf, &p7500_properties,