From patchwork Thu Mar 31 10:28:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 604058 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 3qbLPy1v5bz9sBf for ; Thu, 31 Mar 2016 21:30:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756317AbcCaKaB (ORCPT ); Thu, 31 Mar 2016 06:30:01 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35652 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756005AbcCaK2w (ORCPT ); Thu, 31 Mar 2016 06:28:52 -0400 Received: by mail-wm0-f67.google.com with SMTP id 139so22372227wmn.2; Thu, 31 Mar 2016 03:28:52 -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:in-reply-to:references; bh=4GHOvtQi+ygZgi1S+oFe+4rUcKhmQZXCBVSDS3b4no8=; b=eyMpWRS8GB9DNHRisuaMZN/8cCHJGpFBs/ceabhgXgLJw6ywgyNX+ebVHVccE5eOIt bJnpc5vDgwb5/M2nx5pEeVE/CIqqJxijYslSQ1BtDtu37oyS9P1u/ayF8rgvcT/ywYtd 5t/oT+iD3tc7zx7MsF5eIodMp2VEzMzOQuNW8qeGmhUrS0rUdt46wkJ1hP/PPN5lbrGK GrgDHHelU6v7wQziXNaRwxw++6FQTqHx1xjtKNzhaye5+7MrA4THRW2OwisjmVO0MYve ZSYoTCKjz1JopVQCw54gWlNZujxgfJCKnfWrPITtJWnXPA9EgoGOCgNFws/8FFz1Zgu0 RIdA== X-Gm-Message-State: AD7BkJKR43cosclUAi5r8j9TjlJvq8af8dRV0aT0B5EM0rwnsyg2XrBcZpiHDzBOwTg2Fg== X-Received: by 10.194.8.38 with SMTP id o6mr2507604wja.31.1459420131418; Thu, 31 Mar 2016 03:28:51 -0700 (PDT) Received: from localhost.localdomain (dslb-088-066-101-161.088.066.pools.vodafone-ip.de. [88.66.101.161]) by smtp.gmail.com with ESMTPSA id 138sm9075531wmf.13.2016.03.31.03.28.50 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2016 03:28:50 -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 v5 10/14] i2c: octeon: Move read function before write Date: Thu, 31 Mar 2016 12:28:23 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: 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 | 94 ++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index 9621b66..95cd301 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c @@ -928,53 +928,6 @@ static int octeon_i2c_start(struct octeon_i2c *i2c, int first) } /** - * 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 - * @last: is last msg in combined operation? - * - * 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 first, int last) -{ - int i, result; - - result = octeon_i2c_start(i2c, first); - if (result) - return result; - - octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, target << 1); - octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); - - result = octeon_i2c_wait(i2c); - if (result) - return result; - - for (i = 0; i < length; i++) { - result = check_arb(i2c, false); - if (result) - return result; - - octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, data[i]); - octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); - - result = octeon_i2c_wait(i2c); - if (result) - return result; - result = check_arb(i2c, false); - 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 @@ -1040,6 +993,53 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target, u8 *data, } /** + * 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 + * @last: is last msg in combined operation? + * + * 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 first, int last) +{ + int i, result; + + result = octeon_i2c_start(i2c, first); + if (result) + return result; + + octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, target << 1); + octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); + + result = octeon_i2c_wait(i2c); + if (result) + return result; + + for (i = 0; i < length; i++) { + result = check_arb(i2c, false); + if (result) + return result; + + octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, data[i]); + octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); + + result = octeon_i2c_wait(i2c); + if (result) + return result; + result = check_arb(i2c, false); + 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