Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1387561

[PATCH] i2c: octeon: Remove zero-length message support

From Jan Glauber <jglauber@cavium.com>
Newsgroups linux.kernel
Subject [PATCH] i2c: octeon: Remove zero-length message support
Date 2016-04-26 16:50 +0200
Message-ID <rsctl-Xx-33@gated-at.bofh.it> (permalink)
References <rsaKS-81H-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Zero-length message support (SMBUS QUICK or i2c) never worked with
the Octeon hardware. Disable SMBUS QUICK support and bail out in
case of a zero-length i2c request.

After this change 'i2c-detect -q' will return an error on Octeon but
the previously reported results were wrong anyway.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
 drivers/i2c/busses/i2c-octeon.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 9f11e19..e8a65f5 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -837,9 +837,6 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
 	int i, result, length = *rlength;
 	bool final_read = false;
 
-	if (length < 1)
-		return -EINVAL;
-
 	octeon_i2c_data_write(i2c, (target << 1) | 1);
 	octeon_i2c_ctl_write(i2c, TWSI_CTL_ENAB);
 
@@ -925,6 +922,12 @@ static int octeon_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 	for (i = 0; ret == 0 && i < num; i++) {
 		struct i2c_msg *pmsg = &msgs[i];
 
+		/* zero-length messages are not supported */
+		if (!pmsg->len) {
+			ret = -EOPNOTSUPP;
+			break;
+		}
+
 		ret = octeon_i2c_start(i2c);
 		if (ret)
 			return ret;
@@ -998,7 +1001,7 @@ static struct i2c_bus_recovery_info octeon_i2c_recovery_info = {
 
 static u32 octeon_i2c_functionality(struct i2c_adapter *adap)
 {
-	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
+	return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK) |
 	       I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_SMBUS_BLOCK_PROC_CALL;
 }
 
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Jan Glauber <jglauber@cavium.com> - 2016-04-25 16:40 +0200
  Re: [PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Wolfram Sang <wsa@the-dreams.de> - 2016-04-26 00:20 +0200
    Re: [PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Jan Glauber <jan.glauber@caviumnetworks.com> - 2016-04-26 08:50 +0200
      Re: [PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Wolfram Sang <wsa@the-dreams.de> - 2016-04-26 09:40 +0200
        Re: [PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Jan Glauber <jan.glauber@caviumnetworks.com> - 2016-04-26 14:40 +0200
          Re: [PATCH v7 03/15] i2c: octeon: Remove I2C_FUNC_SMBUS_QUICK support Wolfram Sang <wsa@the-dreams.de> - 2016-04-26 15:00 +0200
            [PATCH] i2c: octeon: Remove zero-length message support Jan Glauber <jglauber@cavium.com> - 2016-04-26 16:50 +0200
              Re: [PATCH] i2c: octeon: Remove zero-length message support Wolfram Sang <wsa@the-dreams.de> - 2016-04-26 23:10 +0200

csiph-web