diff options
Diffstat (limited to 'drivers/i2c/i2c-core-base.c')
| -rw-r--r-- | drivers/i2c/i2c-core-base.c | 21 | 
1 files changed, 15 insertions, 6 deletions
| diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 28460f6a60cc..38af18645133 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -430,7 +430,7 @@ static int i2c_device_remove(struct device *dev)  	dev_pm_clear_wake_irq(&client->dev);  	device_init_wakeup(&client->dev, false); -	client->irq = 0; +	client->irq = client->init_irq;  	return status;  } @@ -741,10 +741,11 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)  	client->flags = info->flags;  	client->addr = info->addr; -	client->irq = info->irq; -	if (!client->irq) -		client->irq = i2c_dev_irq_from_resources(info->resources, +	client->init_irq = info->irq; +	if (!client->init_irq) +		client->init_irq = i2c_dev_irq_from_resources(info->resources,  							 info->num_resources); +	client->irq = client->init_irq;  	strlcpy(client->name, info->type, sizeof(client->name)); @@ -1232,6 +1233,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)  	if (!adap->lock_ops)  		adap->lock_ops = &i2c_adapter_lock_ops; +	adap->locked_flags = 0;  	rt_mutex_init(&adap->bus_lock);  	rt_mutex_init(&adap->mux_lock);  	mutex_init(&adap->userspace_clients_lock); @@ -1865,6 +1867,8 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)  	if (WARN_ON(!msgs || num < 1))  		return -EINVAL; +	if (WARN_ON(test_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags))) +		return -ESHUTDOWN;  	if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))  		return -EOPNOTSUPP; @@ -2254,7 +2258,8 @@ EXPORT_SYMBOL(i2c_put_adapter);  /**   * i2c_get_dma_safe_msg_buf() - get a DMA safe buffer for the given i2c_msg   * @msg: the message to be checked - * @threshold: the minimum number of bytes for which using DMA makes sense + * @threshold: the minimum number of bytes for which using DMA makes sense. + *	       Should at least be 1.   *   * Return: NULL if a DMA safe buffer was not obtained. Use msg->buf with PIO.   *	   Or a valid pointer to be used with DMA. After use, release it by @@ -2264,7 +2269,11 @@ EXPORT_SYMBOL(i2c_put_adapter);   */  u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold)  { -	if (msg->len < threshold) +	/* also skip 0-length msgs for bogus thresholds of 0 */ +	if (!threshold) +		pr_debug("DMA buffer for addr=0x%02x with length 0 is bogus\n", +			 msg->addr); +	if (msg->len < threshold || msg->len == 0)  		return NULL;  	if (msg->flags & I2C_M_DMA_SAFE) | 
