From patchwork Mon Jun 6 08:48:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 69382 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1377764qgf; Mon, 6 Jun 2016 01:57:39 -0700 (PDT) X-Received: by 10.66.249.234 with SMTP id yx10mr4462385pac.29.1465203459326; Mon, 06 Jun 2016 01:57:39 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1si21072411pfb.53.2016.06.06.01.57.39; Mon, 06 Jun 2016 01:57:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751130AbcFFI5h (ORCPT + 1 other); Mon, 6 Jun 2016 04:57:37 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:36636 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751342AbcFFItJ (ORCPT ); Mon, 6 Jun 2016 04:49:09 -0400 Received: by mail-wm0-f48.google.com with SMTP id n184so81002268wmn.1 for ; Mon, 06 Jun 2016 01:49:09 -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=PXHbJudDfJ0s8gfHdTd80oYtwOf3cCMBrhe1RPkddNbQEJQgM6h80tPQ4yLhLUsmS7 mldnwkDPoag/ewmVhSisZSDZa4rFZW0Q76RNFIwnG4OwtFV0SlQH+1Gp9ewTM7obvKsR tqh7PI4y7r1SHhhDfDkaxFrjhG9293IKjN5aDaqOfUqLWkCvirwMnEXob0npf7w1k0Zq AyGNcA6KocjqHh5jMtThZa2oqnao0J5Ci5jCa7azi9cMH9bT1ZLEgAEjYawFKdXxKTmk pA8pymicuNy6U7kahuFS/CytejM0dSMM6oNROTTgYgONWlyo2vcngBco6uBhuEKzCJIa m5Qg== 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=lfd29fPcs1IiY6b48oGKV5wBUk3UDUfyXF9qianJrMIzhlnd3cEqtqYrRLgKEFwDVa 6icqDzH5idUG6i7ZWbnLOJ+Goc7PlJLKgCtdNcgwTzBNbWy0Ur76Lz2J0BygdekdYKXv +5pnwSvm9fAmbF65i//FrVZXYZhCHsYv8mfGeoK57hP5QAFZynVq0043O5MDrSal27TZ HpHk5+19+kD+nDeUiZylPgYY8vELzeMIvWNmLPhHUEM9ZuZzjUlNbDmPOSOp+2RjuWPW O38T9taJYTbAnBQ63msPYTMRZwJYHzwTDPOanj4P+AYqYTZmsE/iclia5VR2goebIpBw W15w== X-Gm-Message-State: ALyK8tLv77bVRH7sZ9OUslRRHxgXQmDhxtT83OJGR04GZY3cyXYfoeC5vsXI3Cyfho7L4STr X-Received: by 10.28.144.203 with SMTP id s194mr1821356wmd.12.1465202948310; Mon, 06 Jun 2016 01:49:08 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id dd7sm19090384wjb.22.2016.06.06.01.49.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 01:49:07 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang , linux-i2c , LKML , Andrew Lunn , Srinivas Kandagatla , Maxime Ripard , GregKH Cc: Bartosz Golaszewski Subject: [RESEND PATCH 02/14] eeprom: at24: move at24_read() below at24_eeprom_write() Date: Mon, 6 Jun 2016 10:48:44 +0200 Message-Id: <1465202936-16832-3-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465202936-16832-1-git-send-email-bgolaszewski@baylibre.com> References: <1465202936-16832-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;