From patchwork Mon Apr 25 14:33:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 614504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qtphM5FX6z9t60 for ; Tue, 26 Apr 2016 00:36:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932565AbcDYOgs (ORCPT ); Mon, 25 Apr 2016 10:36:48 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36195 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754898AbcDYOeG (ORCPT ); Mon, 25 Apr 2016 10:34:06 -0400 Received: by mail-wm0-f68.google.com with SMTP id w143so21446483wmw.3; Mon, 25 Apr 2016 07:34:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F7R7iwzI2kMKeWZFvrWPRABa659eaGkn886U2qrXm7o=; b=RUH8AimIwgnNvy2A3rz9BF/chex/WEtlTt69Bphao8Wx1F7ISrnoxi3G9xwlmmucSs 5j3cg9sDmxn1zoiqGa7BQeluEf32RXEH2iGDhiDXlaHFEdC2E4RGBmPPAKzdTey14u/D MbIOkxFzTzxiW6wBWAYs5ke2qzH20YHSLHN9wOWkPDKGIVRcMmdPSUB63uNCGJYouXF4 7ftBF0EL42SupATDx0P+4N0WLU5ZSFuNZT9H/9dFPzBsIMUnrcQMwc7inddJgqKpyjUv b0wGkrS1/HK0N3khBIEgZN75g74l/ph384i47KIOtfU4zU2DtBy2tNAiJL9w2SYfkYmd Wzug== X-Gm-Message-State: AOPr4FWcwiLLgJu0qnlBaZtQJ8061bf6FE4Y6Xs0A5pRWNgLvgcJm/HWD6hSt42cpHTVHQ== X-Received: by 10.28.24.195 with SMTP id 186mr12558879wmy.30.1461594844890; Mon, 25 Apr 2016 07:34:04 -0700 (PDT) Received: from wintermute.fritz.box (HSI-KBW-46-223-170-19.hsi.kabel-badenwuerttemberg.de. [46.223.170.19]) by smtp.gmail.com with ESMTPSA id o73sm19084272wme.16.2016.04.25.07.34.03 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Apr 2016 07:34:04 -0700 (PDT) From: Jan Glauber To: Wolfram Sang Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, David Daney , Jan Glauber Subject: [PATCH v7 10/15] i2c: octeon: Move read function before write Date: Mon, 25 Apr 2016 16:33:39 +0200 Message-Id: <1461594824-7215-11-git-send-email-jglauber@cavium.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461594824-7215-1-git-send-email-jglauber@cavium.com> References: <1461594824-7215-1-git-send-email-jglauber@cavium.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Just sorting the functions to be consistent with the other read/write variants. Signed-off-by: Jan Glauber --- drivers/i2c/busses/i2c-octeon.c | 78 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index 009cc33..2bc32b9 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c @@ -864,45 +864,6 @@ static void octeon_i2c_stop(struct octeon_i2c *i2c) } /** - * octeon_i2c_write - send data to the bus via low-level controller - * @i2c: The struct octeon_i2c - * @target: Target address - * @data: Pointer to the data to be sent - * @length: Length of the data - * - * The address is sent over the bus, then the data. - * - * Returns 0 on success, otherwise a negative errno. - */ -static int octeon_i2c_write(struct octeon_i2c *i2c, int target, - const u8 *data, int length) -{ - int i, result; - - octeon_i2c_data_write(i2c, target << 1); - octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB); - - result = octeon_i2c_wait(i2c); - if (result) - return result; - - for (i = 0; i < length; i++) { - result = octeon_i2c_check_status(i2c, false); - if (result) - return result; - - octeon_i2c_data_write(i2c, data[i]); - octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB); - - result = octeon_i2c_wait(i2c); - if (result) - return result; - } - - return 0; -} - -/** * octeon_i2c_read - receive data from the bus via low-level controller * @i2c: The struct octeon_i2c * @target: Target address @@ -967,6 +928,45 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target, } /** + * octeon_i2c_write - send data to the bus via low-level controller + * @i2c: The struct octeon_i2c + * @target: Target address + * @data: Pointer to the data to be sent + * @length: Length of the data + * + * The address is sent over the bus, then the data. + * + * Returns 0 on success, otherwise a negative errno. + */ +static int octeon_i2c_write(struct octeon_i2c *i2c, int target, + const u8 *data, int length) +{ + int i, result; + + octeon_i2c_data_write(i2c, target << 1); + octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB); + + result = octeon_i2c_wait(i2c); + if (result) + return result; + + for (i = 0; i < length; i++) { + result = octeon_i2c_check_status(i2c, false); + if (result) + return result; + + octeon_i2c_data_write(i2c, data[i]); + octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB); + + result = octeon_i2c_wait(i2c); + if (result) + return result; + } + + return 0; +} + +/** * octeon_i2c_xfer - The driver's master_xfer function * @adap: Pointer to the i2c_adapter structure * @msgs: Pointer to the messages to be processed