lkml.org 
[lkml]   [2020]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] HID: mcp2221: add usb to i2c-smbus host bridge

> + if (num == 1) {
> + if (msgs->flags & I2C_M_RD) {
> + ret = mcp_i2c_smbus_read(mcp, msgs, MCP2221_I2C_RD_DATA,
> + 0, 0, NULL);
> + } else {
> + ret = mcp_i2c_write(mcp, msgs, MCP2221_I2C_WR_DATA, 1);
> + }
> + if (ret)
> + goto exit;
> + ret = num;
> + } else if (num == 2) {
> + /* Ex transaction; send reg address and read its contents */
> + if (msgs[0].addr == msgs[1].addr &&
> + !(msgs[0].flags & I2C_M_RD) &&
> + (msgs[1].flags & I2C_M_RD)) {
> +
> + ret = mcp_i2c_write(mcp, &msgs[0],
> + MCP2221_I2C_WR_NO_STOP, 0);
> + if (ret)
> + goto exit;
> +
> + ret = mcp_i2c_smbus_read(mcp, &msgs[1],
> + MCP2221_I2C_RD_RPT_START,
> + 0, 0, NULL);
> + if (ret)
> + goto exit;
> + ret = num;
> + } else {
> + dev_err(&adapter->dev,
> + "unsupported multi-msg i2c transaction\n");
> + ret = -EOPNOTSUPP;
> + }
> + } else {
> + dev_err(&adapter->dev,
> + "unsupported multi-msg i2c transaction\n");
> + ret = -EOPNOTSUPP;
> + }

Have a look at struct i2c_adapter_quirks and especially the flags to let
the I2C core do the sanity checks from here.

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-03-10 13:30    [W:0.284 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site