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
499 * @master_xfer: Issue a set of i2c transactions to the given I2C adapter499 * @master_xfer: Issue a set of i2c transactions to the given I2C adapter
500 * defined by the msgs array, with num messages available to transfer via500 * defined by the msgs array, with num messages available to transfer via
501 * the adapter specified by adap.501 * 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.
502 * @smbus_xfer: Issue smbus transactions to the given I2C adapter. If this504 * @smbus_xfer: Issue smbus transactions to the given I2C adapter. If this
503 * is not present, then the bus layer will try and convert the SMBus calls505 * is not present, then the bus layer will try and convert the SMBus calls
504 * into I2C transfers instead.506 * 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.
505 * @functionality: Return the flags that this algorithm/adapter pair supports509 * @functionality: Return the flags that this algorithm/adapter pair supports
506 * from the I2C_FUNC_* flags.510 * from the I2C_FUNC_* flags.
507 * @reg_slave: Register given client to I2C slave mode of this adapter511 * @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
512 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584516 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584
513 * to name two of the most common.517 * to name two of the most common.
514 *518 *
515 * The return codes from the @master_xfer field should indicate the type of519 * The return codes from the @master_xfer{_atomic} fields should indicate the
516 * error code that occurred during the transfer, as documented in the kernel520 * type of error code that occurred during the transfer, as documented in the
517 * Documentation file Documentation/i2c/fault-codes.521 * Kernel Documentation file Documentation/i2c/fault-codes.
518 */522 */
519struct i2c_algorithm {523struct i2c_algorithm {
520 /*524 /*
@@ -528,9 +532,14 @@ struct i2c_algorithm { · 7 unmodified lines
528 */532 */
529 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,533 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
530 int num);534 int num);
535 int (*master_xfer_atomic)(struct i2c_adapter *adap,
536 struct i2c_msg *msgs, int num);
531 int (*smbus_xfer)(struct i2c_adapter *adap, u16 addr,537 int (*smbus_xfer)(struct i2c_adapter *adap, u16 addr,
532 unsigned short flags, char read_write,538 unsigned short flags, char read_write,
533 u8 command, int size, union i2c_smbus_data *data);539 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);
534 543
535 /* To determine what the adapter supports */544 /* To determine what the adapter supports */
536 u32 (*functionality)(struct i2c_adapter *adap);545 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