linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Rishi Gupta <gupt21@gmail.com>
Cc: jikos@kernel.org, benjamin.tissoires@redhat.com,
	wsa+renesas@sang-engineering.com, gregkh@linuxfoundation.org,
	linux-i2c@vger.kernel.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] HID: mcp2221: add usb to i2c-smbus host bridge
Date: Tue, 10 Mar 2020 13:29:34 +0100	[thread overview]
Message-ID: <20200310122934.GA13896@ninjato> (raw)
In-Reply-To: <1580185137-11255-1-git-send-email-gupt21@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]


> +	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.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2020-03-10 12:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28  4:18 [PATCH v3] HID: mcp2221: add usb to i2c-smbus host bridge Rishi Gupta
2020-02-10 13:50 ` rishi gupta
2020-03-02  8:38   ` rishi gupta
2020-03-10 11:42 ` Jiri Kosina
2020-03-10 12:11   ` rishi gupta
2020-03-10 12:29 ` Wolfram Sang [this message]
2020-03-10 12:54   ` rishi gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200310122934.GA13896@ninjato \
    --to=wsa@the-dreams.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gupt21@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).