mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	i2c: designware: Get right data length
IC_DATA_CMD[11] indicates the first data byte received after the address phase for receive transfer in Master receiver or Slave receiver mode, this bit was set in some transfer flow. IC_DATA_CMD[7:0] contains the data to be transmitted or received on the I2C bus, so we should use the lower 8 bits to get the real data length. Signed-off-by: Liguang Zhang <zhangliguang@linux.alibaba.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
		
							parent
							
								
									a1858ce0cf
								
							
						
					
					
						commit
						f53f15ba5a
					
				
					 2 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -38,6 +38,8 @@
 | 
				
			||||||
#define DW_IC_CON_TX_EMPTY_CTRL			BIT(8)
 | 
					#define DW_IC_CON_TX_EMPTY_CTRL			BIT(8)
 | 
				
			||||||
#define DW_IC_CON_RX_FIFO_FULL_HLD_CTRL		BIT(9)
 | 
					#define DW_IC_CON_RX_FIFO_FULL_HLD_CTRL		BIT(9)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DW_IC_DATA_CMD_DAT			GENMASK(7, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Registers offset
 | 
					 * Registers offset
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -432,7 +432,7 @@ i2c_dw_read(struct dw_i2c_dev *dev)
 | 
				
			||||||
			regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
 | 
								regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
 | 
				
			||||||
			/* Ensure length byte is a valid value */
 | 
								/* Ensure length byte is a valid value */
 | 
				
			||||||
			if (flags & I2C_M_RECV_LEN &&
 | 
								if (flags & I2C_M_RECV_LEN &&
 | 
				
			||||||
			    tmp <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
 | 
								    (tmp & DW_IC_DATA_CMD_DAT) <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
 | 
				
			||||||
				len = i2c_dw_recv_len(dev, tmp);
 | 
									len = i2c_dw_recv_len(dev, tmp);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			*buf++ = tmp;
 | 
								*buf++ = tmp;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue