From patchwork Sun May 29 21:53:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 68797 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1113155qge; Sun, 29 May 2016 14:54:24 -0700 (PDT) X-Received: by 10.98.19.5 with SMTP id b5mr40971078pfj.153.1464558863725; Sun, 29 May 2016 14:54:23 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si45729726pac.212.2016.05.29.14.54.23; Sun, 29 May 2016 14:54:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753310AbcE2VyS (ORCPT + 30 others); Sun, 29 May 2016 17:54:18 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:36382 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753239AbcE2VyP (ORCPT ); Sun, 29 May 2016 17:54:15 -0400 Received: by mail-wm0-f44.google.com with SMTP id n129so61528155wmn.1 for ; Sun, 29 May 2016 14:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nwt3tJCXs7v/i0NLdH1lKb288CYiSPgWgxc6PMwdk+8=; b=K3qugt7754IGZlY7h+JZYH3ozd78qTRMQ5rpgHSnNMcWb+z+WlOwK+OpSuIdXvWt/7 uxfnK5mRJf0mNgAuc8i6vrssfmofFkkaqCuQEFKtSBKtz1qg4G2U+KZYFg98VQkNOVm4 kukLA3IPYixcp7jgn3qIZL6iEy30Pi4pZ9Tce9JAuEhUN3blOlkqMcIITC7gB1UcLk3m yjJx/kEjXZWQF98efsIIdoVwS9OnoPuT0jO1imstM2R+WXvTEQYBsypbmp6tOptQpCl3 aSGtVsxzyPAJPf8pJM6fC1lVbw6jqF7KyjLfXwdrO5TDY7nuIeFeAdG/+wYTF7bALQ/I QsFQ== 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=nwt3tJCXs7v/i0NLdH1lKb288CYiSPgWgxc6PMwdk+8=; b=UOVX5guVj1LDBGiWaKJA7psmkGqXT7zxVrOjPFpAawl1nsSANmmzOqrrawglwEaC2S +7UsKm/4du0FkcFzqJbyLk8qBQ4OY/NfXrfLf7AO0reM0EEh0ywEk8RAs90Eqee3I1hN f+7P65xFO1CkSxx/DXGLnmZlfs4C1TZUpOAZSI6pNWS5GsOyPdIHmUXlvZh/1I7v46nN 0vJ5ciZjB9Nl+uoFh/oy8V4OwJ7XO0LgJykD91/3B6Z0BSTBez1Ll+rPGIfhJvoemDsc Xf6sHwwkBvLauR6eVmV/mmaT5SmYbKWqX+CDPEspuzrsFSzMhLZeppPGtPhHVNNezTnp Wa4Q== X-Gm-Message-State: ALyK8tL+wVpKQHZSIaTiX48UKzEDG3Hfhn9m3L4RTqJoeS+eiKHsliM903fQQzXRKAM0UAf4 X-Received: by 10.28.54.204 with SMTP id y73mr7458384wmh.59.1464558853281; Sun, 29 May 2016 14:54:13 -0700 (PDT) Received: from bgdev-debian.lan (jua06-1-82-242-157-225.fbx.proxad.net. [82.242.157.225]) by smtp.gmail.com with ESMTPSA id a128sm20490367wme.16.2016.05.29.14.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 May 2016 14:54:12 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang , linux-i2c , LKML , Andrew Lunn , Srinivas Kandagatla , Maxime Ripard , GregKH Cc: Bartosz Golaszewski Subject: [PATCH 02/14] eeprom: at24: move at24_read() below at24_eeprom_write() Date: Sun, 29 May 2016 23:53:40 +0200 Message-Id: <1464558832-2262-3-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464558832-2262-1-git-send-email-bgolaszewski@baylibre.com> References: <1464558832-2262-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for splitting at24_eeprom_write() & at24_eeprom_read() into smaller, specialized routines move at24_read() below, so that it won't be intertwined with the low-level EEPROM accessors. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 64 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) -- 2.7.4 diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 411600d..e12d76f 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -249,38 +249,6 @@ static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf, return -ETIMEDOUT; } -static int at24_read(void *priv, unsigned int off, void *val, size_t count) -{ - struct at24_data *at24 = priv; - char *buf = val; - - if (unlikely(!count)) - return count; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&at24->lock); - - while (count) { - int status; - - status = at24_eeprom_read(at24, buf, off, count); - if (status < 0) { - mutex_unlock(&at24->lock); - return status; - } - buf += status; - off += status; - count -= status; - } - - mutex_unlock(&at24->lock); - - return 0; -} - /* * Note that if the hardware write-protect pin is pulled high, the whole * chip is normally write protected. But there are plenty of product @@ -366,6 +334,38 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf, return -ETIMEDOUT; } +static int at24_read(void *priv, unsigned int off, void *val, size_t count) +{ + struct at24_data *at24 = priv; + char *buf = val; + + if (unlikely(!count)) + return count; + + /* + * Read data from chip, protecting against concurrent updates + * from this host, but not from other I2C masters. + */ + mutex_lock(&at24->lock); + + while (count) { + int status; + + status = at24_eeprom_read(at24, buf, off, count); + if (status < 0) { + mutex_unlock(&at24->lock); + return status; + } + buf += status; + off += status; + count -= status; + } + + mutex_unlock(&at24->lock); + + return 0; +} + static int at24_write(void *priv, unsigned int off, void *val, size_t count) { struct at24_data *at24 = priv;