diff mbox

[2/3] gbsim: i2c: Convert to using greybus i2c.h header

Message ID 1428372371-9927-2-git-send-email-john.stultz@linaro.org
State New
Headers show

Commit Message

John Stultz April 7, 2015, 2:06 a.m. UTC
Instead of duplicating the definitions, reuse the
definitions in the newly split out greybus i2c.h
header.

Cc: Alex Elder <alex.elder@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 gbsim.h |   27 ++++-----------------------
 i2c.c   |   14 +++++++-------
 2 files changed, 11 insertions(+), 30 deletions(-)
diff mbox

Patch

diff --git a/gbsim.h b/gbsim.h
index 032f003..cd54841 100644
--- a/gbsim.h
+++ b/gbsim.h
@@ -15,6 +15,7 @@ 
 #include <svc_msg.h>
 
 #include "gpio.h"
+#include "i2c.h"
 #include "i2s.h"
 
 extern int bbb_backend;
@@ -73,26 +74,6 @@  struct protocol_version_rsp {
 	__u8	version_minor;
 };
 
-/* I2C */
-struct i2c_functionality_rsp {
-	__le32	functionality;
-};
-
-struct i2c_transfer_desc {
-	__le16	addr;
-	__le16	flags;
-	__le16	size;
-};
-
-struct i2c_transfer_req {
-	__le16	op_count;
-	struct i2c_transfer_desc desc[0];
-};
-
-struct i2c_transfer_rsp {
-	__u8	data[0];
-};
-
 /* PWM */
 struct pwm_count_rsp {
 	__u8	count;
@@ -146,9 +127,9 @@  struct op_msg {
 		struct gb_gpio_irq_unmask_request	gpio_irq_unmask_req;
 		struct gb_gpio_irq_ack_request		gpio_irq_ack_req;
 		struct gb_gpio_irq_event_request	gpio_irq_event_req;
-		struct i2c_functionality_rsp		i2c_fcn_rsp;
-		struct i2c_transfer_req			i2c_xfer_req;
-		struct i2c_transfer_rsp			i2c_xfer_rsp;
+		struct gb_i2c_functionality_response	i2c_fcn_rsp;
+		struct gb_i2c_transfer_request		i2c_xfer_req;
+		struct gb_i2c_transfer_response		i2c_xfer_rsp;
 		struct pwm_count_rsp			pwm_cnt_rsp;
 		struct pwm_activate_req			pwm_act_req;
 		struct pwm_deactivate_req		pwm_deact_req;
diff --git a/i2c.c b/i2c.c
index aedf0ac..866c595 100644
--- a/i2c.c
+++ b/i2c.c
@@ -72,7 +72,7 @@  void i2c_handler(__u8 *rbuf, size_t size)
 		break;
 	case OP_I2C_PROTOCOL_FUNCTIONALITY:
 		sz = sizeof(struct op_header) +
-				   sizeof(struct i2c_functionality_rsp);
+				   sizeof(struct gb_i2c_functionality_response);
 		op_rsp->header.size = htole16((__u16)sz);
 		op_rsp->header.id = oph->id;
 		op_rsp->header.type = OP_RESPONSE | OP_I2C_PROTOCOL_FUNCTIONALITY;
@@ -110,18 +110,18 @@  void i2c_handler(__u8 *rbuf, size_t size)
 		break;
 	case OP_I2C_PROTOCOL_TRANSFER:
 		op_count = le16toh(op_req->i2c_xfer_req.op_count);
-		write_data = (__u8 *)&op_req->i2c_xfer_req.desc[op_count];
+		write_data = (__u8 *)&op_req->i2c_xfer_req.ops[op_count];
 		gbsim_debug("Number of transfer ops %d\n", op_count);
 		for (i = 0; i < op_count; i++) {
-			struct i2c_transfer_desc *desc;
+			struct gb_i2c_transfer_op *op;
 			__u16 addr;
 			__u16 flags;
 			__u16 size;
 
-			desc = &op_req->i2c_xfer_req.desc[i];
-			addr = le16toh(desc->addr);
-			flags = le16toh(desc->flags);
-			size = le16toh(desc->size);
+			op = &op_req->i2c_xfer_req.ops[i];
+			addr = le16toh(op->addr);
+			flags = le16toh(op->flags);
+			size = le16toh(op->size);
 			read_op = (flags & I2C_M_RD) ? true : false;
 			gbsim_debug("op %d: %s address %04x size %04x\n",
 				    i, (read_op ? "read" : "write"),