From patchwork Mon Nov 27 20:34:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 841864 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lC4I+sAz"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ylz7C5jC4z9s4s for ; Tue, 28 Nov 2017 07:34:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752626AbdK0Ueq (ORCPT ); Mon, 27 Nov 2017 15:34:46 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:41652 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752779AbdK0Ueq (ORCPT ); Mon, 27 Nov 2017 15:34:46 -0500 Received: by mail-wm0-f68.google.com with SMTP id b189so36667806wmd.0 for ; Mon, 27 Nov 2017 12:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=dM72aO05ZRKb/rVgUTvXskCuSfa8eCRgbW/mPDpBIPU=; b=lC4I+sAzPmwH0f37AC1fQpzK2pweagnFvxwATSb2mY3S5WZLZphJ4wATOCSYTRgkWz nD8zn1f9n6/i47E0VCOU1HdNIfpC3mgwNWXfd9gwKPOT2FxnZlgoE40B14L8FwKIC2Sa KRzLuRvEnS9JYoPRRyhjcc/IKy8UvYsMWEE4D/O0hw5Cxry5naH7gRlSbxkzVhNS8S1d J3zIZEM5vs7iRniXQ4/eM77Cno8F9VkdCxJevNGC40brJkA65WzcnbIZvelAq29ekIpQ uhOvPqcMp6FnqfXKjJ6wmzAURcnX64onJuAfK5V5HLiXyqz9jp9NzImRSPv5wJMSRgtR mLTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=dM72aO05ZRKb/rVgUTvXskCuSfa8eCRgbW/mPDpBIPU=; b=ioTW/iGLpKI2devhhYRhGuE38I2FQvDkdP0K5NHe9/Lr8s180KZVqzumKYToA7Jlby fqn79ZVri7OMv3/fYyBrBIOdQJ+6oJXV18TA+yi93nAgVau63Cac12mEWvcDOGXRMqrY bwgBIKmXLuHp4So6BWvjM23/o0/OsP3W00iEUqurZbRGbvcFrGMh4B3xc8rOVP57RJj0 RFawhkjYYnHNFIP0DZVudgZZDE1Kj+sJ7kdardJuvyM8q6bILEE4LDJLMRFxveQ4rq0b 5f7cAvhy9MFUpZuS/b7bjNwKNouAFkLEbqeXnNREaGRyqt8zyEsK9fXP3AYB/iefgQko n9SQ== X-Gm-Message-State: AJaThX7rEpNgql/A1lo8vh/p59PL+w/TLgwbEtdBEDqIuBrgt7m72B28 9Me/KvGcoUebO5CsoxAHk4PNTg== X-Google-Smtp-Source: AGs4zMY4mdXtJuxx9vCH6mOpDHVzFPZOtRA8OTn6xf8vNqsMNwxaDIuwWHIBm8aoLEEdkpdTk367/Q== X-Received: by 10.28.88.65 with SMTP id m62mr17571359wmb.111.1511814884744; Mon, 27 Nov 2017 12:34:44 -0800 (PST) Received: from ?IPv6:2003:ea:8bc0:e400:cdd0:4154:8262:d8bc? (p200300EA8BC0E400CDD041548262D8BC.dip0.t-ipconnect.de. [2003:ea:8bc0:e400:cdd0:4154:8262:d8bc]) by smtp.googlemail.com with ESMTPSA id t200sm15434016wmd.45.2017.11.27.12.34.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Nov 2017 12:34:44 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v5 2/7] eeprom: at24: change at24_translate_offset return type To: Bartosz Golaszewski Cc: "linux-i2c@vger.kernel.org" References: <2c379f45-d5e3-71af-eb20-ca51e09d9257@gmail.com> Message-ID: Date: Mon, 27 Nov 2017 21:34:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <2c379f45-d5e3-71af-eb20-ca51e09d9257@gmail.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Change return type of at24_translate_offset to *at24_client to make member regmap accessible for subsequent patches of this series. Signed-off-by: Heiner Kallweit --- v2: - rebased v3: - improve readability v4: - no changes v5: - no changes --- drivers/misc/eeprom/at24.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 3700b0383..e4bace389 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -267,8 +267,8 @@ MODULE_DEVICE_TABLE(acpi, at24_acpi_ids); * one "eeprom" file not four, but larger reads would fail when * they crossed certain pages. */ -static struct i2c_client *at24_translate_offset(struct at24_data *at24, - unsigned int *offset) +static struct at24_client *at24_translate_offset(struct at24_data *at24, + unsigned int *offset) { unsigned i; @@ -280,17 +280,19 @@ static struct i2c_client *at24_translate_offset(struct at24_data *at24, *offset &= 0xff; } - return at24->client[i].client; + return &at24->client[i]; } static ssize_t at24_eeprom_read_smbus(struct at24_data *at24, char *buf, unsigned int offset, size_t count) { unsigned long timeout, read_time; + struct at24_client *at24_client; struct i2c_client *client; int status; - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; if (count > io_limit) count = io_limit; @@ -318,13 +320,15 @@ static ssize_t at24_eeprom_read_i2c(struct at24_data *at24, char *buf, unsigned int offset, size_t count) { unsigned long timeout, read_time; + struct at24_client *at24_client; struct i2c_client *client; struct i2c_msg msg[2]; int status, i; u8 msgbuf[2]; memset(msg, 0, sizeof(msg)); - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; if (count > io_limit) count = io_limit; @@ -368,12 +372,14 @@ static ssize_t at24_eeprom_read_serial(struct at24_data *at24, char *buf, unsigned int offset, size_t count) { unsigned long timeout, read_time; + struct at24_client *at24_client; struct i2c_client *client; struct i2c_msg msg[2]; u8 addrbuf[2]; int status; - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; @@ -421,12 +427,14 @@ static ssize_t at24_eeprom_read_mac(struct at24_data *at24, char *buf, unsigned int offset, size_t count) { unsigned long timeout, read_time; + struct at24_client *at24_client; struct i2c_client *client; struct i2c_msg msg[2]; u8 addrbuf[2]; int status; - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; memset(msg, 0, sizeof(msg)); msg[0].addr = client->addr; @@ -478,10 +486,12 @@ static ssize_t at24_eeprom_write_smbus_block(struct at24_data *at24, unsigned int offset, size_t count) { unsigned long timeout, write_time; + struct at24_client *at24_client; struct i2c_client *client; ssize_t status = 0; - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; count = at24_adjust_write_count(at24, offset, count); loop_until_timeout(timeout, write_time) { @@ -505,10 +515,12 @@ static ssize_t at24_eeprom_write_smbus_byte(struct at24_data *at24, unsigned int offset, size_t count) { unsigned long timeout, write_time; + struct at24_client *at24_client; struct i2c_client *client; ssize_t status = 0; - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; loop_until_timeout(timeout, write_time) { status = i2c_smbus_write_byte_data(client, offset, buf[0]); @@ -529,12 +541,14 @@ static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf, unsigned int offset, size_t count) { unsigned long timeout, write_time; + struct at24_client *at24_client; struct i2c_client *client; struct i2c_msg msg; ssize_t status = 0; int i = 0; - client = at24_translate_offset(at24, &offset); + at24_client = at24_translate_offset(at24, &offset); + client = at24_client->client; count = at24_adjust_write_count(at24, offset, count); msg.addr = client->addr; @@ -567,6 +581,7 @@ static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf, static int at24_read(void *priv, unsigned int off, void *val, size_t count) { struct at24_data *at24 = priv; + struct at24_client *at24_client; struct i2c_client *client; char *buf = val; int ret; @@ -577,7 +592,8 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) if (off + count > at24->chip.byte_len) return -EINVAL; - client = at24_translate_offset(at24, &off); + at24_client = at24_translate_offset(at24, &off); + client = at24_client->client; ret = pm_runtime_get_sync(&client->dev); if (ret < 0) { @@ -615,6 +631,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) static int at24_write(void *priv, unsigned int off, void *val, size_t count) { struct at24_data *at24 = priv; + struct at24_client *at24_client; struct i2c_client *client; char *buf = val; int ret; @@ -625,7 +642,8 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) if (off + count > at24->chip.byte_len) return -EINVAL; - client = at24_translate_offset(at24, &off); + at24_client = at24_translate_offset(at24, &off); + client = at24_client->client; ret = pm_runtime_get_sync(&client->dev); if (ret < 0) {