History

i2c: core: introduce callbacks for atomic transfers

We had the request to access devices very late when interrupts are not available anymore multiple times now. Mostly to prepare shutdown or reboot. Allow adapters to specify a specific callback for this case. Note that we fall back to the generic {master|smbus}_xfer callback if this new atomic one is not present. This is intentional to preserve the previous behaviour and avoid regressions. Because there are drivers not using interrupts or because it might have worked "accidently" before.

Wolfram Sang committed 7 years ago

Commit 63b96981 parent 83c42214 files · +36 −10Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/i2c.h+12−3
@@ -499,9 +499,13 @@ i2c_register_board_info(int busnum, struct i2c_board_info const *info, · 498 unmodified lines
499499 * @master_xfer: Issue a set of i2c transactions to the given I2C adapter
500500 * defined by the msgs array, with num messages available to transfer via
501501 * the adapter specified by adap.
502+ * @master_xfer_atomic: same as @master_xfer. Yet, only using atomic context
503+ * so e.g. PMICs can be accessed very late before shutdown. Optional.
502504 * @smbus_xfer: Issue smbus transactions to the given I2C adapter. If this
503505 * is not present, then the bus layer will try and convert the SMBus calls
504506 * into I2C transfers instead.
507+ * @smbus_xfer_atomic: same as @smbus_xfer. Yet, only using atomic context
508+ * so e.g. PMICs can be accessed very late before shutdown. Optional.
505509 * @functionality: Return the flags that this algorithm/adapter pair supports
506510 * from the I2C_FUNC_* flags.
507511 * @reg_slave: Register given client to I2C slave mode of this adapter
@@ -512,9 +516,9 @@ i2c_register_board_info(int busnum, struct i2c_board_info const *info, · 4 unmodified lines
512516 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584
513517 * to name two of the most common.
514518 *
515− * The return codes from the @master_xfer field should indicate the type of
516− * error code that occurred during the transfer, as documented in the kernel
517− * Documentation file Documentation/i2c/fault-codes.
519+ * The return codes from the @master_xfer{_atomic} fields should indicate the
520+ * type of error code that occurred during the transfer, as documented in the
521+ * Kernel Documentation file Documentation/i2c/fault-codes.
518522 */
519523 struct i2c_algorithm {
520524 /*
@@ -528,9 +532,14 @@ struct i2c_algorithm { · 7 unmodified lines
528532 */
529533 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
530534 int num);
535+ int (*master_xfer_atomic)(struct i2c_adapter *adap,
536+ struct i2c_msg *msgs, int num);
531537 int (*smbus_xfer)(struct i2c_adapter *adap, u16 addr,
532538 unsigned short flags, char read_write,
533539 u8 command, int size, union i2c_smbus_data *data);
540+ int (*smbus_xfer_atomic)(struct i2c_adapter *adap, u16 addr,
541+ unsigned short flags, char read_write,
542+ u8 command, int size, union i2c_smbus_data *data);
534543
535544 /* To determine what the adapter supports */
536545 u32 (*functionality)(struct i2c_adapter *adap);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t