Unverified Commit 22290cc9 authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Rodrigo Vivi
Browse files

i2c: designware: Use polling by default when there is no irq resource



The irq resource itself can be used as a generic way to
determine when polling is needed.

This not only removes the need for special additional device
properties that would soon be needed when the platform may
or may not have the irq, but it also removes the need to
check the platform in the first place in order to determine
is polling needed or not.

Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20250701122252.2590230-2-heikki.krogerus@linux.intel.com


Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 621a4220
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -205,25 +205,28 @@ static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)

static int dw_i2c_plat_probe(struct platform_device *pdev)
{
	u32 flags = (uintptr_t)device_get_match_data(&pdev->dev);
	struct device *device = &pdev->dev;
	struct i2c_adapter *adap;
	struct dw_i2c_dev *dev;
	int irq, ret;

	irq = platform_get_irq(pdev, 0);
	if (irq < 0)
	irq = platform_get_irq_optional(pdev, 0);
	if (irq == -ENXIO)
		flags |= ACCESS_POLLING;
	else if (irq < 0)
		return irq;

	dev = devm_kzalloc(device, sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return -ENOMEM;

	dev->flags = (uintptr_t)device_get_match_data(device);
	if (device_property_present(device, "wx,i2c-snps-model"))
		dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING;
		flags = MODEL_WANGXUN_SP | ACCESS_POLLING;

	dev->dev = device;
	dev->irq = irq;
	dev->flags = flags;
	platform_set_drvdata(pdev, dev);

	ret = dw_i2c_plat_request_regs(dev);