Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux linux: Repeat i2c transfer if dr...
details: https://anonhg.NetBSD.org/src/rev/aff538227dc1
branches: trunk
changeset: 366352:aff538227dc1
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun May 22 18:41:14 2022 +0000
description:
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.
diffstat:
sys/external/bsd/drm2/linux/linux_i2c.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diffs (38 lines):
diff -r 4ce24bd92b7f -r aff538227dc1 sys/external/bsd/drm2/linux/linux_i2c.c
--- a/sys/external/bsd/drm2/linux/linux_i2c.c Sun May 22 17:55:08 2022 +0000
+++ b/sys/external/bsd/drm2/linux/linux_i2c.c Sun May 22 18:41:14 2022 +0000
@@ -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 @@
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;
- return (*adapter->algo->master_xfer)(adapter, msgs, n);
+ do {
+ ret = (*adapter->algo->master_xfer)(adapter, msgs, n);
+ if (ret != -EAGAIN)
+ break;
+ } while (nretries++ < adapter->retries &&
+ getticks() - start < timeout);
+
+ return ret;
}
int
Home |
Main Index |
Thread Index |
Old Index