public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Atanasov <alex@ssi.bg>
To: Jean Delvare <khali@linux-fr.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] I2C block read
Date: Wed, 7 Jun 2006 21:06:42 +0300	[thread overview]
Message-ID: <20060607210642.5cd59aba.alex@ssi.bg> (raw)
In-Reply-To: <20060607194943.db8f1889.khali@linux-fr.org>

On Wed, 7 Jun 2006 19:49:43 +0200
Jean Delvare wrote:

> Hi Alexander,
> 
> > 	When doing i2c block read the lenght is passed as the first
> > byte of the buffer, so we must copy it from user otherwise temp is
> > uninitialized.
> 
> > --- drivers/i2c/i2c-dev.c.orig	2006-01-04 02:00:00.000000000
> > +0200 +++ drivers/i2c/i2c-dev.c	2006-06-07
> > 19:46:08.000000000 +0300 @@ -337,6 +337,7 @@
> >  
> >  		if ((data_arg.size == I2C_SMBUS_PROC_CALL) || 
> >  		    (data_arg.size == I2C_SMBUS_BLOCK_PROC_CALL)
> > || 
> > +		    (data_arg.size == I2C_SMBUS_BLOCK_DATA) ||
> >  		    (data_arg.read_write == I2C_SMBUS_WRITE)) {
> >  			if (copy_from_user(&temp, data_arg.data,
> > datasize)) return -EFAULT;
> 
> Nack. Firstly, your comment says I2C block read, but your code changes
> SMBus block read. These are two different transactions. Secondly, for
> SMBus block read, the master doesn't ask for a given number of bytes.
> Instead, the chip decides and returns the number of (following) bytes
> as the first byte of the read part of the transaction. Check the SMBus
> specification.
> 
> So your patch is not correct, sorry.


	10x. Here is the case:
I use SMBus block read with scx200_acb as a bus it uses the lenght
which is as i say uninitialized and tries to read a number of random bytes
from the board i use. And it doesn't return the lenght as a first byte,
so the drivers reads until it gets an oops. Which in turn makes me wonder
why with this patch i correcly receive the number of bytes i pass,
looking at the driver i can not see that it gets the lenght from the read data.
I don't know well SMBus/I2C specs but read with buffer and no lenght 
doesn't look sane to me. So how should this be fixed?

--
have fun,
alex

 

	

  reply	other threads:[~2006-06-07 18:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-07 17:33 [PATCH] I2C block read Alexander Atanasov
2006-06-07 17:49 ` Jean Delvare
2006-06-07 18:06   ` Alexander Atanasov [this message]
2006-06-07 18:50     ` Jean Delvare
2006-06-07 19:53       ` Jordan Crouse
2006-06-08 13:29       ` [PATCH] " Alexander Atanasov
2006-06-11 13:30         ` Jean Delvare
2006-06-12 14:16           ` Alexander Atanasov

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=20060607210642.5cd59aba.alex@ssi.bg \
    --to=alex@ssi.bg \
    --cc=khali@linux-fr.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