From: Heiner Kallweit <hkallweit1@gmail.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: [PATCH RFC 3/7] eeprom: at24: add regmap-based write function
Date: Thu, 17 Aug 2017 07:59:11 +0200 [thread overview]
Message-ID: <f0410125-4b65-3ce6-8ac4-8210fb961344@gmail.com> (raw)
In-Reply-To: <2e264f77-2316-b6b6-e66c-b162f77d81de@gmail.com>
Add a regmap-based write function.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/misc/eeprom/at24.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 7cd746de..4e4225b2 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -465,6 +465,22 @@ static ssize_t at24_eeprom_write_smbus_byte(struct at24_data *at24,
return -ETIMEDOUT;
}
+static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf,
+ unsigned int offset, size_t count)
+{
+ unsigned long timeout, write_time;
+ struct regmap *regmap;
+
+ regmap = at24_translate_offset(at24, &offset)->regmap;
+ count = at24_adjust_write_count(at24, offset, count);
+
+ loop_until_timeout(timeout, write_time)
+ if (!regmap_bulk_write(regmap, offset, buf, count))
+ return count;
+
+ return -ETIMEDOUT;
+}
+
static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf,
unsigned int offset, size_t count)
{
@@ -553,7 +569,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
while (count) {
int status;
- status = at24->write_func(at24, buf, off, count);
+ status = at24_regmap_write(at24, buf, off, count);
if (status < 0) {
mutex_unlock(&at24->lock);
return status;
--
2.14.1
next prev parent reply other threads:[~2017-08-17 5:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 5:45 [PATCH RFC 0/7] eeprom: at24: switch driver to regmap_i2c Heiner Kallweit
2017-08-17 5:59 ` [PATCH RFC 1/7] eeprom: at24: add basic regmap_i2c support Heiner Kallweit
2017-08-17 5:59 ` [PATCH RFC 2/7] eeprom: at24: change at24_translate_offset return type Heiner Kallweit
2017-08-17 5:59 ` Heiner Kallweit [this message]
2017-08-17 5:59 ` [PATCH RFC 4/7] eeprom: at24: remove old write functions Heiner Kallweit
2017-08-17 5:59 ` [PATCH RFC 5/7] eeprom: at24: add regmap-based read functions Heiner Kallweit
2017-08-17 5:59 ` [PATCH RFC 6/7] eeprom: at24: remove old " Heiner Kallweit
2017-08-17 5:59 ` [PATCH RFC 7/7] eeprom: at24: remove now unneeded smbus-related code Heiner Kallweit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0410125-4b65-3ce6-8ac4-8210fb961344@gmail.com \
--to=hkallweit1@gmail.com \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).