From patchwork Tue Dec 26 23:37:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10133287 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 910516023A for ; Tue, 26 Dec 2017 23:38:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 832F72DA7F for ; Tue, 26 Dec 2017 23:38:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7847A2DA82; Tue, 26 Dec 2017 23:38:11 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 03D2D2DA7F for ; Tue, 26 Dec 2017 23:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751357AbdLZXiI (ORCPT ); Tue, 26 Dec 2017 18:38:08 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38398 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751122AbdLZXiF (ORCPT ); Tue, 26 Dec 2017 18:38:05 -0500 Received: by mail-wm0-f66.google.com with SMTP id 64so36828826wme.3 for ; Tue, 26 Dec 2017 15:38:05 -0800 (PST) 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=mw4SqzgMUg6OihjTNGzTOL6QuRDYUjjPKas0xiBacYw=; b=py8UgDJ+Zk4Q5LPg78VfXBi+7I5wpaf/pYayimfcEp75gHZTjc15XpTU1HEK/fIbrT npWr31Gv1HnFIQ5QeMbNIOeqnv3pjYoZsmdixaS9Pah/5BF6KJlr4CCMPt6Sgjp4XoPb +74en5lrnPQ+xX9HD/ta8dzjSjFz2UwXlvrT4Bui8il0KsmeeyICOmxyzC3WFKxZuKEj vCd7ThHuphIKnz9r8dW3Tsw9aQ/bl7hVKTZgsMLGODc5sMCrQOiY/Qok58zc/lJchGbe YPwLrxPqRTpK71Eq9WxEcwHyQ/drWA/Ep97BdiFx4dWI4lJPsTsHEDDrIDID7Z/5VbVo 1XHQ== 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=mw4SqzgMUg6OihjTNGzTOL6QuRDYUjjPKas0xiBacYw=; b=KQ+OEzzUrAYZ2kaXCXNaoh6LP6Ca343h2+c2rIG06McadbT7cYgl1iQSx1mI1oLTc3 q5G/zUaOGjQuuSendBfjuMkW/d7HC/8ClteyemB0M7iISIlZaAsxZSNlZbk7Y3RcKoS9 geIXpVsU588sC7nPv3iycPr1bNBB0X1AwHqgoflTWqitDs7deR1zOECFUPwc6lHLBzKV rIKsS3g/4BjwZMLJB/Z8p1dFSifJL/VKc6iyj+XMF8i4ZyaAyezlAEY+iBDeXsE4g6MH uaIlkv4LDyN3xTbjUrVf2fJPcVpOC2hpTY4AuvBysgFcWTrGP279rwkaby7gwV93L/j+ 6BhQ== X-Gm-Message-State: AKGB3mKRx5f2rMc2719q8s3Z+Gx0AFOgbnt0MxfvaORfNwimC4lBBnCr kzA9tUOGszGU4XblqdC9jTqtZQ== X-Google-Smtp-Source: ACJfBovhn22koYuRrcB4AbQKPd/CotlfnKElZx4SPXkcTUzn2OZ6STGlDs4ZsbiIqVLKKOeCUdqqrg== X-Received: by 10.28.144.10 with SMTP id s10mr20231800wmd.103.1514331484231; Tue, 26 Dec 2017 15:38:04 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id o16sm21514092wmi.29.2017.12.26.15.38.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Dec 2017 15:38:03 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Cc: Ralph Metzler Subject: [PATCH 2/4] [media] dvb-frontends/stv0910: cleanup I2C access functions Date: Wed, 27 Dec 2017 00:37:57 +0100 Message-Id: <20171226233759.16116-3-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171226233759.16116-1-d.scheller.oss@gmail.com> References: <20171226233759.16116-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 write_reg() and i2c_write_reg16() only act as a proxy to i2c_write(), which isn't called from anywhere else throughout the driver. Clean this up by moving the message setup and the i2c_transfer() into write_reg() so it becomes the only I2C write function. While touching those parts, fix the error codes from EREMOTEIO to EIO. The I2C cleanup is picked from the upstream dddvb. Cc: Ralph Metzler Signed-off-by: Daniel Scheller --- drivers/media/dvb-frontends/stv0910.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c index a6c473f3647f..06d2587125dd 100644 --- a/drivers/media/dvb-frontends/stv0910.c +++ b/drivers/media/dvb-frontends/stv0910.c @@ -137,33 +137,21 @@ struct slookup { u32 reg_value; }; -static inline int i2c_write(struct i2c_adapter *adap, u8 adr, - u8 *data, int len) +static int write_reg(struct stv *state, u16 reg, u8 val) { - struct i2c_msg msg = {.addr = adr, .flags = 0, - .buf = data, .len = len}; + struct i2c_adapter *adap = state->base->i2c; + u8 data[3] = {reg >> 8, reg & 0xff, val}; + struct i2c_msg msg = {.addr = state->base->adr, .flags = 0, + .buf = data, .len = 3}; if (i2c_transfer(adap, &msg, 1) != 1) { dev_warn(&adap->dev, "i2c write error ([%02x] %04x: %02x)\n", - adr, (data[0] << 8) | data[1], - (len > 2 ? data[2] : 0)); - return -EREMOTEIO; + state->base->adr, reg, val); + return -EIO; } return 0; } -static int i2c_write_reg16(struct i2c_adapter *adap, u8 adr, u16 reg, u8 val) -{ - u8 msg[3] = {reg >> 8, reg & 0xff, val}; - - return i2c_write(adap, adr, msg, 3); -} - -static int write_reg(struct stv *state, u16 reg, u8 val) -{ - return i2c_write_reg16(state->base->i2c, state->base->adr, reg, val); -} - static inline int i2c_read_regs16(struct i2c_adapter *adapter, u8 adr, u16 reg, u8 *val, int count) { @@ -176,7 +164,7 @@ static inline int i2c_read_regs16(struct i2c_adapter *adapter, u8 adr, if (i2c_transfer(adapter, msgs, 2) != 2) { dev_warn(&adapter->dev, "i2c read error ([%02x] %04x)\n", adr, reg); - return -EREMOTEIO; + return -EIO; } return 0; }