From patchwork Tue Nov 28 20:51:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 842304 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="pUmQo83i"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ymbSk5fRXz9sNd for ; Wed, 29 Nov 2017 07:52:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752051AbdK1UwF (ORCPT ); Tue, 28 Nov 2017 15:52:05 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:41645 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751822AbdK1UwE (ORCPT ); Tue, 28 Nov 2017 15:52:04 -0500 Received: by mail-wm0-f67.google.com with SMTP id g75so2207233wme.0 for ; Tue, 28 Nov 2017 12:52:04 -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=CgwtMeenk69qjXIZrT6Pz9iqL2O1+o8nW0qhYrfe5n8=; b=pUmQo83iCp8dvXc/Mev4k6s8yzjdFdmnW93iMmg2KDPXH5iliXY1/69TbLTP04lOrF EUNUMcJ7MeLreQHsMW3rndrYnq2ZCjgNVFawjDCSM03TkeopNIoaZwEeyaW1EB7CWAxS E8C/yECl0Zjuzq+D3jl9oyNd8HY4gozrQBI0I+3hiVuxSgeY9z3JS5/+KAGJYbEU8WTE DCah0SuzCnDrthWgCebFvIuaDGj+d8ISabFGxXRFtcDuFhIcltab32hC8cPNmgkp2ddw xPwSTKiM2hz60YwO6thGzMylj0Aqq8Z1ZZ1LZlbSWHJW4CMfrKl5zFU8NKeb2yVrFxZy rH5A== 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=CgwtMeenk69qjXIZrT6Pz9iqL2O1+o8nW0qhYrfe5n8=; b=kRl4ClbJTGinc5km5Xo9I6LjSG/dJdYM2fOAKLC8UHZRLInsQvn2Wl2OfCx6XgcF4w z8jafmMv4+nCa9UIZsVSaZbiQFI/wP1j+ZsfTqZ8zIZj6uINzPA0AhT16GG10gDuRDek IIHLqXVZ5s9EDggFqtO9dZTvyoYjU8RgaZojUUQff7Vd6WuVPo066YROaclTApLJBTd7 Wq/hQfKGJlls232uVrZDmqNulez5bpkne4ZQ3Ld8j/ufA4QwSDCGk+mpPEWkVRpTQd0s RphOh1RrU6HhffshQX8VxhHjS0ZQWJT4YDEYfHuG4poWLhrpxnzXjhqLMq0ktgIJ8BY+ gv4w== X-Gm-Message-State: AJaThX4/jg6VNW8Y/XIgwfO4xmVJrHBozKBl9EiE72pVuk1M1vsmUIzf 4U84oUMmLOrRz1wo+MGBmpJmPQ== X-Google-Smtp-Source: AGs4zMbeGrSApsJy8pwNRXAqC7bz+fhn4Tb3uAduXD2lMcA4Qu36anKtbA36AEMU81FTYQ51qd1knQ== X-Received: by 10.80.151.215 with SMTP id f23mr4265161edb.141.1511902323177; Tue, 28 Nov 2017 12:52:03 -0800 (PST) Received: from ?IPv6:2003:ea:8bc0:e400:801a:35b6:3d85:3c9f? (p200300EA8BC0E400801A35B63D853C9F.dip0.t-ipconnect.de. [2003:ea:8bc0:e400:801a:35b6:3d85:3c9f]) by smtp.googlemail.com with ESMTPSA id l9sm180243edi.58.2017.11.28.12.52.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 12:52:02 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v6 2/7] eeprom: at24: change at24_translate_offset return type To: Bartosz Golaszewski Cc: "linux-i2c@vger.kernel.org" References: <328f770d-e79d-cbb5-1cd7-238862aa8e1c@gmail.com> Message-ID: Date: Tue, 28 Nov 2017 21:51:42 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <328f770d-e79d-cbb5-1cd7-238862aa8e1c@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 v6: - 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 ed930dfbb..a16e8ca12 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; @@ -479,10 +487,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) { @@ -506,10 +516,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]); @@ -530,12 +542,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; @@ -568,6 +582,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; @@ -578,7 +593,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) { @@ -616,6 +632,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; @@ -626,7 +643,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) {