Module Name: src
Committed By: riastradh
Date: Sun May 22 18:41:14 UTC 2022
Modified Files:
src/sys/external/bsd/drm2/linux: linux_i2c.c
Log Message:
linux: Repeat i2c transfer if driver fails with EAGAIN.
The Intel GMBUS (graphics management bus, i2c controller) relies on
this now to fall back from interrupt-driven xfers to bit-banging.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/external/bsd/drm2/linux/linux_i2c.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/linux/linux_i2c.c
diff -u src/sys/external/bsd/drm2/linux/linux_i2c.c:1.6 src/sys/external/bsd/drm2/linux/linux_i2c.c:1.7
--- src/sys/external/bsd/drm2/linux/linux_i2c.c:1.6 Sun Dec 19 11:49:12 2021
+++ src/sys/external/bsd/drm2/linux/linux_i2c.c Sun May 22 18:41:14 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_i2c.c,v 1.6 2021/12/19 11:49:12 riastradh Exp $ */
+/* $NetBSD: linux_i2c.c,v 1.7 2022/05/22 18:41:14 riastradh Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.6 2021/12/19 11:49:12 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.7 2022/05/22 18:41:14 riastradh Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -127,8 +127,18 @@ i2c_master_recv(const struct i2c_client
int
__i2c_transfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int n)
{
+ unsigned timeout = hz; /* XXX adapter->timeout */
+ unsigned start = getticks();
+ int ret, nretries = 0;
+
+ do {
+ ret = (*adapter->algo->master_xfer)(adapter, msgs, n);
+ if (ret != -EAGAIN)
+ break;
+ } while (nretries++ < adapter->retries &&
+ getticks() - start < timeout);
- return (*adapter->algo->master_xfer)(adapter, msgs, n);
+ return ret;
}
int