diff options
author | Peter Rosin <peda@axentia.se> | 2016-08-25 23:07:01 +0200 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2016-08-30 22:56:14 +0200 |
commit | d1ed7985b9a6b85ea38a330108c51ec83381c01b (patch) | |
tree | d97296b9891543fec4e2d1da28d154db8e8a6b04 /drivers/i2c/i2c-mux.c | |
parent | 718917b9875fcfa6450e7274d2727c4680c3591a (diff) | |
download | linux-d1ed7985b9a6b85ea38a330108c51ec83381c01b.tar.gz linux-d1ed7985b9a6b85ea38a330108c51ec83381c01b.tar.bz2 linux-d1ed7985b9a6b85ea38a330108c51ec83381c01b.zip |
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-mux.c')
-rw-r--r-- | drivers/i2c/i2c-mux.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 90f59c088750..83768e85a919 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -267,6 +267,18 @@ struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent, } EXPORT_SYMBOL_GPL(i2c_mux_alloc); +static const struct i2c_lock_operations i2c_mux_lock_ops = { + .lock_bus = i2c_mux_lock_bus, + .trylock_bus = i2c_mux_trylock_bus, + .unlock_bus = i2c_mux_unlock_bus, +}; + +static const struct i2c_lock_operations i2c_parent_lock_ops = { + .lock_bus = i2c_parent_lock_bus, + .trylock_bus = i2c_parent_trylock_bus, + .unlock_bus = i2c_parent_unlock_bus, +}; + int i2c_mux_add_adapter(struct i2c_mux_core *muxc, u32 force_nr, u32 chan_id, unsigned int class) @@ -316,15 +328,10 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, priv->adap.retries = parent->retries; priv->adap.timeout = parent->timeout; priv->adap.quirks = parent->quirks; - if (muxc->mux_locked) { - priv->adap.lock_bus = i2c_mux_lock_bus; - priv->adap.trylock_bus = i2c_mux_trylock_bus; - priv->adap.unlock_bus = i2c_mux_unlock_bus; - } else { - priv->adap.lock_bus = i2c_parent_lock_bus; - priv->adap.trylock_bus = i2c_parent_trylock_bus; - priv->adap.unlock_bus = i2c_parent_unlock_bus; - } + if (muxc->mux_locked) + priv->adap.lock_ops = &i2c_mux_lock_ops; + else + priv->adap.lock_ops = &i2c_parent_lock_ops; /* Sanity check on class */ if (i2c_mux_parent_classes(parent) & class) |