i2c: Implement consistent i2c no msgs behaviour

The I2C drivers handle an empty list of I2C messages inconsistenty.
There are two different behaviours, one set of drivers dectects a
requests to transfer zero messages and return -EINVAL while the other
group simple transfer no data and return success.

Adopt the latter behaviour consistently across all drivers.  Update
the i2c.h API documentation to reflect this behaviour.

Change-Id: I427fc1b0e18ddc04b7b59c294e0240b3d6ca4073
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
diff --git a/drivers/i2c/i2c_atmel_sam3.c b/drivers/i2c/i2c_atmel_sam3.c
index 61f55ad..4ef3441 100644
--- a/drivers/i2c/i2c_atmel_sam3.c
+++ b/drivers/i2c/i2c_atmel_sam3.c
@@ -460,9 +460,9 @@
 	int ret = 0;
 	int xfr_ret;
 
-	/* Why bother processing no messages */
-	if (!msgs || !num_msgs) {
-		return -ENOTSUP;
+	__ASSERT_NO_MSG(msgs);
+	if (!num_msgs) {
+		return 0;
 	}
 
 	/* Device is busy servicing another transfer */
diff --git a/drivers/i2c/i2c_dw.c b/drivers/i2c/i2c_dw.c
index 0ad0919..1ac40dd 100644
--- a/drivers/i2c/i2c_dw.c
+++ b/drivers/i2c/i2c_dw.c
@@ -414,9 +414,9 @@
 	volatile struct i2c_dw_registers * const regs =
 		(struct i2c_dw_registers *)dw->base_address;
 
-	/* Why bother processing no messages */
-	if (!msgs || !num_msgs) {
-		return -ENOTSUP;
+	__ASSERT_NO_MSG(msgs);
+	if (!num_msgs) {
+		return 0;
 	}
 
 	/* First step, check if there is current activity */
diff --git a/drivers/i2c/i2c_qmsi.c b/drivers/i2c/i2c_qmsi.c
index 17114d4..31aa372 100644
--- a/drivers/i2c/i2c_qmsi.c
+++ b/drivers/i2c/i2c_qmsi.c
@@ -208,8 +208,9 @@
 	qm_i2c_t instance = GET_CONTROLLER_INSTANCE(dev);
 	int rc;
 
-	if  (msgs == NULL || num_msgs == 0) {
-		return -ENOTSUP;
+	__ASSERT_NO_MSG(msgs);
+	if (!num_msgs) {
+		return 0;
 	}
 
 	device_busy_set(dev);
diff --git a/drivers/i2c/i2c_qmsi_ss.c b/drivers/i2c/i2c_qmsi_ss.c
index 0c9de95..6c8feb9 100644
--- a/drivers/i2c/i2c_qmsi_ss.c
+++ b/drivers/i2c/i2c_qmsi_ss.c
@@ -305,8 +305,9 @@
 	qm_ss_i2c_t instance = GET_CONTROLLER_INSTANCE(dev);
 	int rc;
 
-	if  (msgs == NULL || num_msgs == 0) {
-		return -ENOTSUP;
+	__ASSERT_NO_MSG(msgs);
+	if (!num_msgs) {
+		return 0;
 	}
 
 	device_busy_set(dev);
diff --git a/include/i2c.h b/include/i2c.h
index 3d6d47f..89dc69d 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -205,6 +205,9 @@
  * to another I2C device synchronously. Use i2c_read()/i2c_write()
  * for simple read or write.
  *
+ * The array of message @a msgs must not be NULL.  The number of
+ * message @a num_msgs may be zero,in which case no transfer occurs.
+ *
  * @param dev Pointer to the device structure for the driver instance.
  * @param msgs Array of messages to transfer.
  * @param num_msgs Number of messages to transfer.