public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: Francesco Lavra <flavra@baylibre.com>
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [PATCH v3] i2c: Add FTDI FT4222H USB I2C adapter
Date: Wed, 4 Feb 2026 23:06:17 +0100	[thread overview]
Message-ID: <aYPBXTrREaaXZIdM@zenone.zhora.eu> (raw)
In-Reply-To: <20260129155230.3054708-1-flavra@baylibre.com>

Hi Francesco,

...

> +static int ft4222_i2c_write(struct ft4222_i2c *ftdi, u8 flags, u8 slave_addr,
> +			    u8 *data, int len)
> +{
> +	struct usb_device *udev = ftdi->udev;
> +	unsigned int pipe = usb_sndbulkpipe(udev, FT4222_EP_TX);
> +	u8 *buf = ftdi->ubuf;
> +	int written = 0;
> +
> +	dev_dbg(&ftdi->adapter.dev, "write to 0x%02x, flags 0x%02x, len %d",
> +		slave_addr, flags, len);

Here and in every dev_dbg/dev_err, you are missing the "\n" at
the end of the message.

> +	buf[0] = slave_addr << 1;
> +	buf[2] = buf[3] = 0;
> +	do {
> +		int pkt_len = min(FT4222_TX_HDRLEN + len - written,
> +				  FT4222_BULK_MAXLEN);
> +		bool first_pkt = (written == 0);
> +		bool last_pkt = (written + pkt_len == FT4222_TX_HDRLEN + len);
> +		int ret, actual_len;
> +
> +		buf[1] = 0;
> +		if (first_pkt)
> +			buf[1] |= flags & FT4222_FLAG_RESTART;

Aren't we losing the _START case here?

Andi

> +		if (last_pkt)
> +			buf[1] |= flags & FT4222_FLAG_STOP;
> +		if (buf[1] == 0)
> +			buf[1] = FT4222_FLAG_NONE;
> +		memcpy(buf + FT4222_TX_HDRLEN, data + written,
> +		       pkt_len - FT4222_TX_HDRLEN);
> +		ret = usb_bulk_msg(udev, pipe, buf, pkt_len, &actual_len,
> +				   FT4222_IO_TIMEOUT);
> +		if (ret < 0)
> +			return ret;
> +		if (actual_len < pkt_len)
> +			return -EIO;
> +		ret = ft4222_i2c_get_status(ftdi);
> +		if (ret < 0)
> +			return ret;
> +		written += pkt_len - FT4222_TX_HDRLEN;
> +	} while (written < len);
> +	return 0;
> +}

  reply	other threads:[~2026-02-04 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 15:52 [PATCH v3] i2c: Add FTDI FT4222H USB I2C adapter Francesco Lavra
2026-02-04 22:06 ` Andi Shyti [this message]
2026-02-09  9:17   ` Francesco Lavra

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=aYPBXTrREaaXZIdM@zenone.zhora.eu \
    --to=andi.shyti@kernel.org \
    --cc=flavra@baylibre.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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