diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2018-09-20 12:14:21 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2018-10-05 12:13:37 -0400 |
commit | cc52612ec0f3b80c19126a36b8c1e12a8f5a8e78 (patch) | |
tree | 4c49e272d64de08da146af9eb9714ae1f681a422 | |
parent | a7163dc2138d96b3593b7d4430d35e506696a62f (diff) |
i2c: core: remove level of indentation in i2c_transfer
Using the common kernel pattern to bail out at the beginning if some
conditions are not met, we can save a level of indentation. No
functional change.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/i2c-core-base.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index c2b352c46fae..799776c6d421 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c | |||
@@ -1922,6 +1922,11 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1922 | { | 1922 | { |
1923 | int ret; | 1923 | int ret; |
1924 | 1924 | ||
1925 | if (!adap->algo->master_xfer) { | ||
1926 | dev_dbg(&adap->dev, "I2C level transfers not supported\n"); | ||
1927 | return -EOPNOTSUPP; | ||
1928 | } | ||
1929 | |||
1925 | /* REVISIT the fault reporting model here is weak: | 1930 | /* REVISIT the fault reporting model here is weak: |
1926 | * | 1931 | * |
1927 | * - When we get an error after receiving N bytes from a slave, | 1932 | * - When we get an error after receiving N bytes from a slave, |
@@ -1938,25 +1943,19 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1938 | * one (discarding status on the second message) or errno | 1943 | * one (discarding status on the second message) or errno |
1939 | * (discarding status on the first one). | 1944 | * (discarding status on the first one). |
1940 | */ | 1945 | */ |
1941 | 1946 | if (in_atomic() || irqs_disabled()) { | |
1942 | if (adap->algo->master_xfer) { | 1947 | ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT); |
1943 | if (in_atomic() || irqs_disabled()) { | 1948 | if (!ret) |
1944 | ret = i2c_trylock_bus(adap, I2C_LOCK_SEGMENT); | 1949 | /* I2C activity is ongoing. */ |
1945 | if (!ret) | 1950 | return -EAGAIN; |
1946 | /* I2C activity is ongoing. */ | ||
1947 | return -EAGAIN; | ||
1948 | } else { | ||
1949 | i2c_lock_bus(adap, I2C_LOCK_SEGMENT); | ||
1950 | } | ||
1951 | |||
1952 | ret = __i2c_transfer(adap, msgs, num); | ||
1953 | i2c_unlock_bus(adap, I2C_LOCK_SEGMENT); | ||
1954 | |||
1955 | return ret; | ||
1956 | } else { | 1951 | } else { |
1957 | dev_dbg(&adap->dev, "I2C level transfers not supported\n"); | 1952 | i2c_lock_bus(adap, I2C_LOCK_SEGMENT); |
1958 | return -EOPNOTSUPP; | ||
1959 | } | 1953 | } |
1954 | |||
1955 | ret = __i2c_transfer(adap, msgs, num); | ||
1956 | i2c_unlock_bus(adap, I2C_LOCK_SEGMENT); | ||
1957 | |||
1958 | return ret; | ||
1960 | } | 1959 | } |
1961 | EXPORT_SYMBOL(i2c_transfer); | 1960 | EXPORT_SYMBOL(i2c_transfer); |
1962 | 1961 | ||