diff options
Diffstat (limited to 'drivers/i2c')
| -rw-r--r-- | drivers/i2c/busses/i2c-hisi.c | 13 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-imx-lpi2c.c | 6 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-mxs.c | 18 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-xgene-slimpro.c | 3 | ||||
| -rw-r--r-- | drivers/i2c/i2c-core-base.c | 13 | ||||
| -rw-r--r-- | drivers/i2c/i2c-core-of.c | 5 | ||||
| -rw-r--r-- | drivers/i2c/i2c-dev.c | 24 | ||||
| -rw-r--r-- | drivers/i2c/i2c-slave-eeprom.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/i2c-slave-testunit.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/i2c-smbus.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/muxes/i2c-mux-ltc4306.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/muxes/i2c-mux-pca9541.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/muxes/i2c-mux-pca954x.c | 2 | 
13 files changed, 66 insertions, 28 deletions
| diff --git a/drivers/i2c/busses/i2c-hisi.c b/drivers/i2c/busses/i2c-hisi.c index 8c6c7075c765..e067671b3ce2 100644 --- a/drivers/i2c/busses/i2c-hisi.c +++ b/drivers/i2c/busses/i2c-hisi.c @@ -316,6 +316,13 @@ static void hisi_i2c_xfer_msg(struct hisi_i2c_controller *ctlr)  		    max_write == 0)  			break;  	} + +	/* +	 * Disable the TX_EMPTY interrupt after finishing all the messages to +	 * avoid overwhelming the CPU. +	 */ +	if (ctlr->msg_tx_idx == ctlr->msg_num) +		hisi_i2c_disable_int(ctlr, HISI_I2C_INT_TX_EMPTY);  }  static irqreturn_t hisi_i2c_irq(int irq, void *context) @@ -341,7 +348,11 @@ static irqreturn_t hisi_i2c_irq(int irq, void *context)  		hisi_i2c_read_rx_fifo(ctlr);  out: -	if (int_stat & HISI_I2C_INT_TRANS_CPLT || ctlr->xfer_err) { +	/* +	 * Only use TRANS_CPLT to indicate the completion. On error cases we'll +	 * get two interrupts, INT_ERR first then TRANS_CPLT. +	 */ +	if (int_stat & HISI_I2C_INT_TRANS_CPLT) {  		hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL);  		hisi_i2c_clear_int(ctlr, HISI_I2C_INT_ALL);  		complete(ctlr->completion); diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 188f2a36d2fd..a49b14d52a98 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -463,6 +463,8 @@ static int lpi2c_imx_xfer(struct i2c_adapter *adapter,  		if (num == 1 && msgs[0].len == 0)  			goto stop; +		lpi2c_imx->rx_buf = NULL; +		lpi2c_imx->tx_buf = NULL;  		lpi2c_imx->delivered = 0;  		lpi2c_imx->msglen = msgs[i].len;  		init_completion(&lpi2c_imx->complete); @@ -503,10 +505,14 @@ disable:  static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id)  {  	struct lpi2c_imx_struct *lpi2c_imx = dev_id; +	unsigned int enabled;  	unsigned int temp; +	enabled = readl(lpi2c_imx->base + LPI2C_MIER); +  	lpi2c_imx_intctrl(lpi2c_imx, 0);  	temp = readl(lpi2c_imx->base + LPI2C_MSR); +	temp &= enabled;  	if (temp & MSR_RDF)  		lpi2c_imx_read_rxfifo(lpi2c_imx); diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index d113bed79545..e0f3b3545cfe 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c @@ -171,7 +171,7 @@ static void mxs_i2c_dma_irq_callback(void *param)  }  static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap, -			struct i2c_msg *msg, uint32_t flags) +			struct i2c_msg *msg, u8 *buf, uint32_t flags)  {  	struct dma_async_tx_descriptor *desc;  	struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap); @@ -226,7 +226,7 @@ static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap,  		}  		/* Queue the DMA data transfer. */ -		sg_init_one(&i2c->sg_io[1], msg->buf, msg->len); +		sg_init_one(&i2c->sg_io[1], buf, msg->len);  		dma_map_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE);  		desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[1], 1,  					DMA_DEV_TO_MEM, @@ -259,7 +259,7 @@ static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap,  		/* Queue the DMA data transfer. */  		sg_init_table(i2c->sg_io, 2);  		sg_set_buf(&i2c->sg_io[0], &i2c->addr_data, 1); -		sg_set_buf(&i2c->sg_io[1], msg->buf, msg->len); +		sg_set_buf(&i2c->sg_io[1], buf, msg->len);  		dma_map_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE);  		desc = dmaengine_prep_slave_sg(i2c->dmach, i2c->sg_io, 2,  					DMA_MEM_TO_DEV, @@ -563,6 +563,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,  	struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);  	int ret;  	int flags; +	u8 *dma_buf;  	int use_pio = 0;  	unsigned long time_left; @@ -588,13 +589,20 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,  		if (ret && (ret != -ENXIO))  			mxs_i2c_reset(i2c);  	} else { +		dma_buf = i2c_get_dma_safe_msg_buf(msg, 1); +		if (!dma_buf) +			return -ENOMEM; +  		reinit_completion(&i2c->cmd_complete); -		ret = mxs_i2c_dma_setup_xfer(adap, msg, flags); -		if (ret) +		ret = mxs_i2c_dma_setup_xfer(adap, msg, dma_buf, flags); +		if (ret) { +			i2c_put_dma_safe_msg_buf(dma_buf, msg, false);  			return ret; +		}  		time_left = wait_for_completion_timeout(&i2c->cmd_complete,  						msecs_to_jiffies(1000)); +		i2c_put_dma_safe_msg_buf(dma_buf, msg, true);  		if (!time_left)  			goto timeout; diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c index 63259b3ea5ab..3538d36368a9 100644 --- a/drivers/i2c/busses/i2c-xgene-slimpro.c +++ b/drivers/i2c/busses/i2c-xgene-slimpro.c @@ -308,6 +308,9 @@ static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip,  	u32 msg[3];  	int rc; +	if (writelen > I2C_SMBUS_BLOCK_MAX) +		return -EINVAL; +  	memcpy(ctx->dma_buffer, data, writelen);  	paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen,  			       DMA_TO_DEVICE); diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index cb5fa971d67e..ae3af738b03f 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -561,15 +561,8 @@ static int i2c_device_probe(struct device *dev)  		goto err_detach_pm_domain;  	} -	/* -	 * When there are no more users of probe(), -	 * rename probe_new to probe. -	 */ -	if (driver->probe_new) -		status = driver->probe_new(client); -	else if (driver->probe) -		status = driver->probe(client, -				       i2c_match_id(driver->id_table, client)); +	if (driver->probe) +		status = driver->probe(client);  	else  		status = -EINVAL; @@ -1057,7 +1050,7 @@ static int dummy_probe(struct i2c_client *client)  static struct i2c_driver dummy_driver = {  	.driver.name	= "dummy", -	.probe_new	= dummy_probe, +	.probe		= dummy_probe,  	.id_table	= dummy_id,  }; diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index bce6b796e04c..545436b7dd53 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -178,6 +178,11 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,  			return NOTIFY_OK;  		} +		/* +		 * Clear the flag before adding the device so that fw_devlink +		 * doesn't skip adding consumers to this device. +		 */ +		rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;  		client = of_i2c_register_device(adap, rd->dn);  		if (IS_ERR(client)) {  			dev_err(&adap->dev, "failed to create client for '%pOF'\n", diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 107623c4cc14..95a0b63ac560 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -646,7 +646,7 @@ static void i2cdev_dev_release(struct device *dev)  	kfree(i2c_dev);  } -static int i2cdev_attach_adapter(struct device *dev, void *dummy) +static int i2cdev_attach_adapter(struct device *dev)  {  	struct i2c_adapter *adap;  	struct i2c_dev *i2c_dev; @@ -685,7 +685,7 @@ err_put_i2c_dev:  	return NOTIFY_DONE;  } -static int i2cdev_detach_adapter(struct device *dev, void *dummy) +static int i2cdev_detach_adapter(struct device *dev)  {  	struct i2c_adapter *adap;  	struct i2c_dev *i2c_dev; @@ -711,9 +711,9 @@ static int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action,  	switch (action) {  	case BUS_NOTIFY_ADD_DEVICE: -		return i2cdev_attach_adapter(dev, NULL); +		return i2cdev_attach_adapter(dev);  	case BUS_NOTIFY_DEL_DEVICE: -		return i2cdev_detach_adapter(dev, NULL); +		return i2cdev_detach_adapter(dev);  	}  	return NOTIFY_DONE; @@ -725,6 +725,18 @@ static struct notifier_block i2cdev_notifier = {  /* ------------------------------------------------------------------------- */ +static int __init i2c_dev_attach_adapter(struct device *dev, void *dummy) +{ +	i2cdev_attach_adapter(dev); +	return 0; +} + +static int __exit i2c_dev_detach_adapter(struct device *dev, void *dummy) +{ +	i2cdev_detach_adapter(dev); +	return 0; +} +  /*   * module load/unload record keeping   */ @@ -752,7 +764,7 @@ static int __init i2c_dev_init(void)  		goto out_unreg_class;  	/* Bind to already existing adapters right away */ -	i2c_for_each_dev(NULL, i2cdev_attach_adapter); +	i2c_for_each_dev(NULL, i2c_dev_attach_adapter);  	return 0; @@ -768,7 +780,7 @@ out:  static void __exit i2c_dev_exit(void)  {  	bus_unregister_notifier(&i2c_bus_type, &i2cdev_notifier); -	i2c_for_each_dev(NULL, i2cdev_detach_adapter); +	i2c_for_each_dev(NULL, i2c_dev_detach_adapter);  	class_destroy(i2c_dev_class);  	unregister_chrdev_region(MKDEV(I2C_MAJOR, 0), I2C_MINORS);  } diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index 5f25f23c4ff8..5946c0d0aef9 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c @@ -207,7 +207,7 @@ static struct i2c_driver i2c_slave_eeprom_driver = {  	.driver = {  		.name = "i2c-slave-eeprom",  	}, -	.probe_new = i2c_slave_eeprom_probe, +	.probe = i2c_slave_eeprom_probe,  	.remove = i2c_slave_eeprom_remove,  	.id_table = i2c_slave_eeprom_id,  }; diff --git a/drivers/i2c/i2c-slave-testunit.c b/drivers/i2c/i2c-slave-testunit.c index 75ee7ebdb614..a49642bbae4b 100644 --- a/drivers/i2c/i2c-slave-testunit.c +++ b/drivers/i2c/i2c-slave-testunit.c @@ -171,7 +171,7 @@ static struct i2c_driver i2c_slave_testunit_driver = {  	.driver = {  		.name = "i2c-slave-testunit",  	}, -	.probe_new = i2c_slave_testunit_probe, +	.probe = i2c_slave_testunit_probe,  	.remove = i2c_slave_testunit_remove,  	.id_table = i2c_slave_testunit_id,  }; diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index cd19546d31fc..138c3f5e0093 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -169,7 +169,7 @@ static struct i2c_driver smbalert_driver = {  	.driver = {  		.name	= "smbus_alert",  	}, -	.probe_new	= smbalert_probe, +	.probe		= smbalert_probe,  	.remove		= smbalert_remove,  	.id_table	= smbalert_ids,  }; diff --git a/drivers/i2c/muxes/i2c-mux-ltc4306.c b/drivers/i2c/muxes/i2c-mux-ltc4306.c index 70835825083f..5a03031519be 100644 --- a/drivers/i2c/muxes/i2c-mux-ltc4306.c +++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c @@ -306,7 +306,7 @@ static struct i2c_driver ltc4306_driver = {  		.name	= "ltc4306",  		.of_match_table = of_match_ptr(ltc4306_of_match),  	}, -	.probe_new	= ltc4306_probe, +	.probe		= ltc4306_probe,  	.remove		= ltc4306_remove,  	.id_table	= ltc4306_id,  }; diff --git a/drivers/i2c/muxes/i2c-mux-pca9541.c b/drivers/i2c/muxes/i2c-mux-pca9541.c index 09d1d9e67e31..ce0fb69249a8 100644 --- a/drivers/i2c/muxes/i2c-mux-pca9541.c +++ b/drivers/i2c/muxes/i2c-mux-pca9541.c @@ -336,7 +336,7 @@ static struct i2c_driver pca9541_driver = {  		   .name = "pca9541",  		   .of_match_table = of_match_ptr(pca9541_of_match),  		   }, -	.probe_new = pca9541_probe, +	.probe = pca9541_probe,  	.remove = pca9541_remove,  	.id_table = pca9541_id,  }; diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 3639e6d7304c..0ccee2ae5720 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -554,7 +554,7 @@ static struct i2c_driver pca954x_driver = {  		.pm	= &pca954x_pm,  		.of_match_table = pca954x_of_match,  	}, -	.probe_new	= pca954x_probe, +	.probe		= pca954x_probe,  	.remove		= pca954x_remove,  	.id_table	= pca954x_id,  }; |