nmk_i2c_xfer(9)
πΈ NAME πΈ
okay so bestie, nmk_i2c_xfer(9) β from the Kernel API Manual β is literally the I2C transfer function used by the kernel framework. iconic. π
β¨ SYNOPSIS β¨
int nmk_i2c_xfer (struct i2c_adapter *i2c_adap , struct i2c_msg msgs[] ,
int num_msgs );
π ARGUMENTS π
i2c_adapβ adapter pointer to the controller, aka the whole vibe check for which controller we're talking to. π¦msgsβ pointer to data to be written. yes, that's the description; no cap. πnum_msgsβ number of messages to be executed. slay the count. β¨
π¦ DESCRIPTION π¦
this is the function called by the generic kernel i2c_transfer or i2c_smbus...() API calls. and lowkey important: this code is protected by the semaphore set in the kernel i2c_transfer function. periodt. π
π NOTE π
π READ TRANSFER π
we impose a restriction, bestie: the first message has to be the index message for any read transaction. fr fr. π
- a no index is coded as
'0', - 2byte big endian index is coded as
'3'!!!msg[0].bufholds the actual index.
this is compatible with generic messages of smbus emulator that send a one byte index.
example: an I2C transaction to read 2 bytes from index 0:
idx = 0; msg[0].addr = client->addr; msg[0].flags = 0x0; msg[0].len = 1; msg[0].buf = idx;
msg[1].addr = client->addr; msg[1].flags = I2C_M_RD; msg[1].len = 2;
msg[1].buf = rd_buff i2c_transfer(adap, msg, 2);
π¦ WRITE TRANSFER π¦
the I2C standard interface interprets all data as payload. if you want to emulate an SMBUS write transaction, put the index as first byte(or first and second) in the payload. π
example: an I2C transaction to write 2 bytes from index 1:
wr_buff[0] = 0x1; wr_buff[1] = 0x23; wr_buff[2] = 0x46; msg[0].flags = 0x0; msg[0].len = 3; msg[0].buf = wr_buff; i2c_transfer(adap, msg, 1);
to read or write a block of data (multiple bytes) using SMBUS emulation, please use the i2c_smbus_read_i2c_block_data or i2c_smbus_write_i2c_block_data API. that's the move. π
β¨
π SEE ALSO π
kernel file ./drivers/i2c/busses/i2c-nomadik.c struct i2c_vendor_data(9), struct i2c_nmk_client(9), struct nmk_i2c_dev(9), flush_i2c_fifo(9), disable_all_interrupts(9), clear_all_interrupts(9), init_hw(9), load_i2c_mcr_reg(9), setup_i2c_controller(9), read_i2c(9), write_i2c(9), nmk_i2c_xfer_one(9), disable_interrupts(9), i2c_irq_handler(9). go read, bestie. π
π«Ά source/version:./drivers/i2c/bussesΒ· date:October 2026Β· page:nmk_i2c_xfer(9)β bye bestie, go slay those transfers πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms