From: jsg Date: Tue, 1 Mar 2022 11:50:37 +0000 (+0000) Subject: __i2c_transfer() should not lock the bus X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=65bb161be730d3059017bc30fa33f9562c35407a;p=openbsd __i2c_transfer() should not lock the bus i2c_transfer() locks the bus --- diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index 8ad9e61f0e4..e92f394f8d7 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.91 2022/02/28 02:40:16 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.92 2022/03/01 11:50:37 jsg Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -1132,13 +1132,10 @@ fail: } int -i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +__i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { int ret, retries; - if (adap->lock_ops) - adap->lock_ops->lock_bus(adap, 0); - retries = adap->retries; retry: if (adap->algo) @@ -1150,6 +1147,19 @@ retry: goto retry; } + return ret; +} + +int +i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +{ + int ret; + + if (adap->lock_ops) + adap->lock_ops->lock_bus(adap, 0); + + ret = __i2c_transfer(adap, msgs, num); + if (adap->lock_ops) adap->lock_ops->unlock_bus(adap, 0); diff --git a/sys/dev/pci/drm/include/linux/i2c.h b/sys/dev/pci/drm/include/linux/i2c.h index cdb6a69a4c3..bb1ca0fd9a9 100644 --- a/sys/dev/pci/drm/include/linux/i2c.h +++ b/sys/dev/pci/drm/include/linux/i2c.h @@ -1,4 +1,4 @@ -/* $OpenBSD: i2c.h,v 1.5 2022/03/01 04:08:04 jsg Exp $ */ +/* $OpenBSD: i2c.h,v 1.6 2022/03/01 11:50:37 jsg Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -91,14 +91,9 @@ struct i2c_algo_bit_data { struct i2c_controller ic; }; +int __i2c_transfer(struct i2c_adapter *, struct i2c_msg *, int); int i2c_transfer(struct i2c_adapter *, struct i2c_msg *, int); -static inline int -__i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) -{ - return i2c_transfer(adap, msgs, num); -} - static inline int i2c_add_adapter(struct i2c_adapter *adap) {