Skip to content

Commit 22290cc

Browse files
Heikki Krogerusrodrigovivi
authored andcommitted
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: Heikki Krogerus <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 621a422 commit 22290cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/i2c/busses/i2c-designware-platdrv.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,25 +205,28 @@ static void i2c_dw_remove_lock_support(struct dw_i2c_dev *dev)
205205

206206
static int dw_i2c_plat_probe(struct platform_device *pdev)
207207
{
208+
u32 flags = (uintptr_t)device_get_match_data(&pdev->dev);
208209
struct device *device = &pdev->dev;
209210
struct i2c_adapter *adap;
210211
struct dw_i2c_dev *dev;
211212
int irq, ret;
212213

213-
irq = platform_get_irq(pdev, 0);
214-
if (irq < 0)
214+
irq = platform_get_irq_optional(pdev, 0);
215+
if (irq == -ENXIO)
216+
flags |= ACCESS_POLLING;
217+
else if (irq < 0)
215218
return irq;
216219

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

221-
dev->flags = (uintptr_t)device_get_match_data(device);
222224
if (device_property_present(device, "wx,i2c-snps-model"))
223-
dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING;
225+
flags = MODEL_WANGXUN_SP | ACCESS_POLLING;
224226

225227
dev->dev = device;
226228
dev->irq = irq;
229+
dev->flags = flags;
227230
platform_set_drvdata(pdev, dev);
228231

229232
ret = dw_i2c_plat_request_regs(dev);

0 commit comments

Comments
 (0)