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 Support i2c bus lock operations.
details: https://anonhg.NetBSD.org/src/rev/29f714402750
branches: trunk
changeset: 1027863:29f714402750
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 00:59:25 2021 +0000
description:
Support i2c bus lock operations.
diffstat:
sys/external/bsd/drm2/include/linux/i2c.h | 12 +++++++++++-
sys/external/bsd/drm2/linux/linux_i2c.c | 13 ++++++++++---
2 files changed, 21 insertions(+), 4 deletions(-)
diffs (68 lines):
diff -r 578fabf4d10f -r 29f714402750 sys/external/bsd/drm2/include/linux/i2c.h
--- a/sys/external/bsd/drm2/include/linux/i2c.h Sun Dec 19 00:59:17 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/i2c.h Sun Dec 19 00:59:25 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c.h,v 1.8 2015/03/05 17:29:18 riastradh Exp $ */
+/* $NetBSD: i2c.h,v 1.9 2021/12/19 00:59:25 riastradh Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -87,6 +87,7 @@
char name[I2C_NAME_SIZE];
const struct i2c_algorithm *algo;
void *algo_data;
+ const struct i2c_lock_operations *lock_ops;
int retries;
struct module *owner;
unsigned int class; /* I2C_CLASS_* */
@@ -107,6 +108,15 @@
};
/*
+ * struct i2c_lock_operations: i2c bus lock operations.
+ */
+struct i2c_lock_operations {
+ void (*lock_bus)(struct i2c_adapter *, unsigned);
+ int (*trylock_bus)(struct i2c_adapter *, unsigned);
+ void (*unlock_bus)(struct i2c_adapter *, unsigned);
+};
+
+/*
* struct i2c_board_info: Parameters to find an i2c bus and a slave on
* it. type is the name of an i2c driver; addr is the slave address;
* platform_data is an extra parameter to pass to the i2c driver.
diff -r 578fabf4d10f -r 29f714402750 sys/external/bsd/drm2/linux/linux_i2c.c
--- a/sys/external/bsd/drm2/linux/linux_i2c.c Sun Dec 19 00:59:17 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_i2c.c Sun Dec 19 00:59:25 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_i2c.c,v 1.3 2015/03/05 17:29:18 riastradh Exp $ */
+/* $NetBSD: linux_i2c.c,v 1.4 2021/12/19 00:59:25 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.3 2015/03/05 17:29:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_i2c.c,v 1.4 2021/12/19 00:59:25 riastradh Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -127,8 +127,15 @@
int
i2c_transfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int n)
{
+ int ret;
- return (*adapter->algo->master_xfer)(adapter, msgs, n);
+ if (adapter->lock_ops)
+ (*adapter->lock_ops->lock_bus)(adapter, 0);
+ ret = (*adapter->algo->master_xfer)(adapter, msgs, n);
+ if (adapter->lock_ops)
+ (*adapter->lock_ops->unlock_bus)(adapter, 0);
+
+ return ret;
}
static int
Home |
Main Index |
Thread Index |
Old Index