summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorPeter Rosin <peda@axentia.se>2016-08-26 00:07:01 +0300
committerWolfram Sang <wsa@the-dreams.de>2016-08-30 23:56:14 +0300
commitd1ed7985b9a6b85ea38a330108c51ec83381c01b (patch)
treed97296b9891543fec4e2d1da28d154db8e8a6b04 /drivers/i2c/i2c-core.c
parent718917b9875fcfa6450e7274d2727c4680c3591a (diff)
downloadlinux-d1ed7985b9a6b85ea38a330108c51ec83381c01b.tar.xz
i2c: move locking operations to their own struct
This makes it trivial to constify them, so do that. Signed-off-by: Peter Rosin <peda@axentia.se> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 05794423e01f..0722713e5910 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1768,6 +1768,12 @@ static int __process_new_adapter(struct device_driver *d, void *data)
return i2c_do_add_adapter(to_i2c_driver(d), data);
}
+static const struct i2c_lock_operations i2c_adapter_lock_ops = {
+ .lock_bus = i2c_adapter_lock_bus,
+ .trylock_bus = i2c_adapter_trylock_bus,
+ .unlock_bus = i2c_adapter_unlock_bus,
+};
+
static int i2c_register_adapter(struct i2c_adapter *adap)
{
int res = -EINVAL;
@@ -1787,11 +1793,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
goto out_list;
}
- if (!adap->lock_bus) {
- adap->lock_bus = i2c_adapter_lock_bus;
- adap->trylock_bus = i2c_adapter_trylock_bus;
- adap->unlock_bus = i2c_adapter_unlock_bus;
- }
+ if (!adap->lock_ops)
+ adap->lock_ops = &i2c_adapter_lock_ops;
rt_mutex_init(&adap->bus_lock);
rt_mutex_init(&adap->mux_lock);