From 2156c0eeb9f5294012e4bb1dbce900c8470102db Mon Sep 17 00:00:00 2001 From: jsg Date: Mon, 26 Jul 2021 06:24:22 +0000 Subject: [PATCH] retry i2c transfers on -EAGAIN up to the number of times specified in struct i2c_adapter inteldrm gmbus returns -EAGAIN to fallback to gpio bitbanging --- sys/dev/pci/drm/drm_linux.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index 58ec65b597e..126c078b56e 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.80 2021/07/07 02:38:21 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.81 2021/07/26 06:24:22 jsg Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -1037,15 +1037,21 @@ fail: int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - int ret; + int ret, retries; if (adap->lock_ops) adap->lock_ops->lock_bus(adap, 0); + retries = adap->retries; +retry: if (adap->algo) ret = adap->algo->master_xfer(adap, msgs, num); else ret = i2c_master_xfer(adap, msgs, num); + if (ret == -EAGAIN && retries > 0) { + retries--; + goto retry; + } if (adap->lock_ops) adap->lock_ops->unlock_bus(adap, 0); -- 2.20.1