1
0
Fork 0
alistair23-linux/drivers/i2c
Wolfram Sang bae1d3a05a i2c: core: remove use of in_atomic()
Commit cea443a81c ("i2c: Support i2c_transfer in atomic contexts")
added in_atomic() to the I2C core. However, the use of in_atomic()
outside of core kernel code is discouraged and was already[1] when this
code was added in early 2008. The above commit was a preparation for
commit b7a3670131 ("i2c-pxa: Add polling transfer"). Its commit
message says explicitly it was added "for cases where I2C transactions
have to occur at times interrup[t]s are disabled". So, the intention was
'disabled interrupts'. This matches the use cases for atomic I2C
transfers I have seen so far: very late communication (mostly to a PMIC)
to powerdown or reboot the system. For those cases, interrupts are
disabled then. It doesn't seem that in_atomic() adds value.

After a discussion with Peter Zijlstra[2], we came up with a better set
of conditionals to match the use case.

The I2C core will soon gain an extra callback into bus drivers
especially for atomic transfers to make them more generic. The code
deciding which transfer to use (atomic/non-atomic) should mimic the
behaviour which locking to use (trylock/lock). This is why we add a
helper for it.

[1] https://lwn.net/Articles/274695/
[2] http://patchwork.ozlabs.org/patch/1067437/

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Stefan Lengfeld <contact@stefanchrist.eu>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2019-04-16 13:08:05 +02:00
..
algos i2c: algo-bit: convert to SPDX header 2019-02-05 14:05:03 +01:00
busses i2c: brcmstb: remove unused struct member 2019-04-15 13:42:36 +02:00
muxes Merge branch 'i2c/for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2018-10-29 14:44:03 -07:00
Kconfig treewide: surround Kconfig file paths with double quotes 2018-12-22 00:25:54 +09:00
Makefile i2c: don't use any __deprecated handling anymore 2018-08-24 17:26:43 +02:00
i2c-boardinfo.c i2c: i2c-boardinfo: fix memory leaks on devinfo 2017-11-27 19:14:29 +01:00
i2c-core-acpi.c i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper 2018-12-03 21:40:02 +02:00
i2c-core-base.c i2c: core: remove use of in_atomic() 2019-04-16 13:08:05 +02:00
i2c-core-of.c i2c: of: Try to find an I2C adapter matching the parent 2019-02-05 13:41:49 +01:00
i2c-core-slave.c i2c: remove i2c_lock_adapter and use i2c_lock_bus directly 2018-07-13 00:09:37 +02:00
i2c-core-smbus.c i2c: core-smbus: don't trace smbus_reply data on errors 2019-02-14 18:01:33 +01:00
i2c-core.h i2c: core: remove use of in_atomic() 2019-04-16 13:08:05 +02:00
i2c-dev.c i2c: expand minor range when registering chrdev region 2019-02-15 09:53:34 +01:00
i2c-mux.c Merge branch 'i2c/for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2018-08-21 17:40:46 -07:00
i2c-slave-eeprom.c i2c: Drop owner assignment from i2c_driver 2015-08-10 08:37:35 +02:00
i2c-smbus.c i2c: i2c-smbus: add of_i2c_setup_smbus_alert 2017-10-28 23:42:47 +02:00
i2c-stub.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00