mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 3/7] i2c: Port two utility functions from Linux kernel
Date: Sun,  6 Dec 2015 23:52:39 -0800	[thread overview]
Message-ID: <1449474763-14099-3-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1449474763-14099-1-git-send-email-andrew.smirnov@gmail.com>

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 include/i2c/i2c.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/i2c/i2c.h b/include/i2c/i2c.h
index 33a4791..cf784ca 100644
--- a/include/i2c/i2c.h
+++ b/include/i2c/i2c.h
@@ -194,6 +194,21 @@ extern s32 i2c_smbus_read_word_data(const struct i2c_client *client,
 extern s32 i2c_smbus_write_word_data(const struct i2c_client *client,
 				     u8 command, u16 value);

+static inline s32
+i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command)
+{
+	s32 value = i2c_smbus_read_word_data(client, command);
+
+	return (value < 0) ? value : swab16(value);
+}
+
+static inline s32
+i2c_smbus_write_word_swapped(const struct i2c_client *client,
+			     u8 command, u16 value)
+{
+	return i2c_smbus_write_word_data(client, command, swab16(value));
+}
+
 /* Returns the number of read bytes */
 extern s32 i2c_smbus_read_i2c_block_data(const struct i2c_client *client,
 					 u8 command, u8 length, u8 *values);
--
2.5.0

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-12-07  7:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07  7:52 [PATCH 1/7] imx: ocotp: Add code to initialize 'cdev->device_node' Andrey Smirnov
2015-12-07  7:52 ` [PATCH 2/7] drivers: bus: Match against id_table first Andrey Smirnov
2015-12-07  7:52 ` Andrey Smirnov [this message]
2015-12-07  7:52 ` [PATCH 4/7] drivers: Introduce hardware monitoring subsystem Andrey Smirnov
2015-12-07  7:52 ` [PATCH 5/7] commands: Add 'hwmon' command Andrey Smirnov
2015-12-10 11:20   ` Antony Pavlov
2015-12-07  7:52 ` [PATCH 6/7] hwmon: Port Linux driver for LM75 sensor Andrey Smirnov
2015-12-07  7:52 ` [PATCH 7/7] hwmon: Port TEMPMON sensor driver Andrey Smirnov
2015-12-07 19:05   ` Trent Piepho
2015-12-07 19:40     ` Andrey Smirnov
2015-12-07 19:52       ` Trent Piepho
2015-12-07 19:56         ` Andrey Smirnov
2015-12-07 10:23 ` [PATCH 1/7] imx: ocotp: Add code to initialize 'cdev->device_node' Sascha Hauer
2015-12-07 19:35   ` Andrey Smirnov

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=1449474763-14099-3-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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