public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* wrong assumption in i2c-at91-master.c ?
@ 2022-03-07 15:57 Michael Walle
  2022-03-07 17:09 ` Codrin.Ciubotariu
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Walle @ 2022-03-07 15:57 UTC (permalink / raw)
  To: Codrin Ciubotariu, Tudor Ambarus; +Cc: linux-i2c

Hi,

I saw that the at91 i2c driver has some kind of heuristic in
at91_twi_xfer(). It assumes that if there are exactly two
messages to transfer, the first is the address write of a
common i2c write address, read data transaction. I don't
think that assumption is correct.

Also there is no check if msg->len is actually smaller
than the width of the address which can be written to
AT91_TWI_IADR.

I think, what is at least missing is that, the first
one is actually a write and have at max 3 bytes (IIRC
thats the max width of AT91_TWI_IADR).

Actually, I don't find any code at all which would
handle multiple messages. Looks like it just supports
num == 2 (and assumes the first message fits into the
AT91_TWI_IADR) and num == 1.

-michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: wrong assumption in i2c-at91-master.c ?
  2022-03-07 15:57 wrong assumption in i2c-at91-master.c ? Michael Walle
@ 2022-03-07 17:09 ` Codrin.Ciubotariu
  2022-03-07 17:23   ` Michael Walle
  0 siblings, 1 reply; 3+ messages in thread
From: Codrin.Ciubotariu @ 2022-03-07 17:09 UTC (permalink / raw)
  To: michael, Tudor.Ambarus; +Cc: linux-i2c

On 07.03.2022 17:57, Michael Walle wrote:
> Hi,

Mi Michael,

> 
> I saw that the at91 i2c driver has some kind of heuristic in
> at91_twi_xfer(). It assumes that if there are exactly two
> messages to transfer, the first is the address write of a
> common i2c write address, read data transaction. I don't
> think that assumption is correct.
> 
> Also there is no check if msg->len is actually smaller
> than the width of the address which can be written to
> AT91_TWI_IADR.
> 
> I think, what is at least missing is that, the first
> one is actually a write and have at max 3 bytes (IIRC
> thats the max width of AT91_TWI_IADR).
> 
> Actually, I don't find any code at all which would
> handle multiple messages. Looks like it just supports
> num == 2 (and assumes the first message fits into the
> AT91_TWI_IADR) and num == 1.

The constraints are set using the quirks feature [1] of the i2c subsystem.

Best regards,
Codrin


[1] 
https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2c-at91-master.c#L720

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: wrong assumption in i2c-at91-master.c ?
  2022-03-07 17:09 ` Codrin.Ciubotariu
@ 2022-03-07 17:23   ` Michael Walle
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Walle @ 2022-03-07 17:23 UTC (permalink / raw)
  To: Codrin.Ciubotariu; +Cc: Tudor.Ambarus, linux-i2c

Hi Codrin,

Am 2022-03-07 18:09, schrieb Codrin.Ciubotariu@microchip.com:
> On 07.03.2022 17:57, Michael Walle wrote:
>> I saw that the at91 i2c driver has some kind of heuristic in
>> at91_twi_xfer(). It assumes that if there are exactly two
>> messages to transfer, the first is the address write of a
>> common i2c write address, read data transaction. I don't
>> think that assumption is correct.
>> 
>> Also there is no check if msg->len is actually smaller
>> than the width of the address which can be written to
>> AT91_TWI_IADR.
>> 
>> I think, what is at least missing is that, the first
>> one is actually a write and have at max 3 bytes (IIRC
>> thats the max width of AT91_TWI_IADR).
>> 
>> Actually, I don't find any code at all which would
>> handle multiple messages. Looks like it just supports
>> num == 2 (and assumes the first message fits into the
>> AT91_TWI_IADR) and num == 1.
> 
> The constraints are set using the quirks feature [1] of the i2c 
> subsystem.

Ahhh! Now it makes sense. Thanks.

-michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-07 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-07 15:57 wrong assumption in i2c-at91-master.c ? Michael Walle
2022-03-07 17:09 ` Codrin.Ciubotariu
2022-03-07 17:23   ` Michael Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox