linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c/mips: Fix error return codes from Sibyte i2c bus driver
@ 2010-06-20 17:57 Guenter Roeck
       [not found] ` <1277056673-4305-1-git-send-email-guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2010-06-20 17:57 UTC (permalink / raw)
  To: khali-PUYAD+kWke1g9hUCZPvPmw, ben-linux-elnMNo+KYs3YtjvyW6yDsg,
	hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Guenter Roeck

Sibyte i2c bus driver returns non-descriptive error values.
Update to return error values as defined in Documentation/i2c/fault-codes.

Signed-off-by: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
---
 drivers/i2c/busses/i2c-sibyte.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 3d76a18..329cbee 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 		}
 		break;
 	default:
-		return -1;      /* XXXKW better error code? */
+		return -EOPNOTSUPP;
 	}
 
 	while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
@@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
 	if (error & M_SMB_ERROR) {
 		/* Clear error bit by writing a 1 */
 		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
-		return -1;      /* XXXKW better error code? */
+		return -ENXIO;
 	}
 
 	if (data_bytes == 1)
-- 
1.7.0.87.g0901d

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

* Re: [PATCH] i2c/mips: Fix error return codes from Sibyte i2c bus driver
       [not found] ` <1277056673-4305-1-git-send-email-guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
@ 2010-06-21 17:02   ` Jean Delvare
       [not found]     ` <20100621190252.2adc6bd8-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2010-06-21 17:02 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg,
	hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi Guenter,

On Sun, 20 Jun 2010 10:57:53 -0700, Guenter Roeck wrote:
> Sibyte i2c bus driver returns non-descriptive error values.
> Update to return error values as defined in Documentation/i2c/fault-codes.
> 
> Signed-off-by: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-sibyte.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
> index 3d76a18..329cbee 100644
> --- a/drivers/i2c/busses/i2c-sibyte.c
> +++ b/drivers/i2c/busses/i2c-sibyte.c
> @@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
>  		}
>  		break;
>  	default:
> -		return -1;      /* XXXKW better error code? */
> +		return -EOPNOTSUPP;
>  	}
>  
>  	while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
> @@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
>  	if (error & M_SMB_ERROR) {
>  		/* Clear error bit by writing a 1 */
>  		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
> -		return -1;      /* XXXKW better error code? */
> +		return -ENXIO;
>  	}
>  
>  	if (data_bytes == 1)

Definitely an improvement. However, returning -ENXIO on all errors
seems wrong. This error value should only be returned on missing ack
from the slave on address byte. Isn't it possible to distinguish
between different error kinds? M_SMB_ERROR_TYPE seems promising, but
one would need to look up the datasheet (which I don't have) to
discover its meaning.

-- 
Jean Delvare

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

* Re: [PATCH] i2c/mips: Fix error return codes from Sibyte i2c bus driver
       [not found]     ` <20100621190252.2adc6bd8-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-06-22 11:54       ` Guenter Roeck
  2010-06-26 16:14         ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2010-06-22 11:54 UTC (permalink / raw)
  To: Jean Delvare
  Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
	hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Mon, Jun 21, 2010 at 01:02:52PM -0400, Jean Delvare wrote:
> Hi Guenter,
> 
> On Sun, 20 Jun 2010 10:57:53 -0700, Guenter Roeck wrote:
> > Sibyte i2c bus driver returns non-descriptive error values.
> > Update to return error values as defined in Documentation/i2c/fault-codes.
> > 
> > Signed-off-by: Guenter Roeck <guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
> > ---
> >  drivers/i2c/busses/i2c-sibyte.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
> > index 3d76a18..329cbee 100644
> > --- a/drivers/i2c/busses/i2c-sibyte.c
> > +++ b/drivers/i2c/busses/i2c-sibyte.c
> > @@ -94,7 +94,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
> >  		}
> >  		break;
> >  	default:
> > -		return -1;      /* XXXKW better error code? */
> > +		return -EOPNOTSUPP;
> >  	}
> >  
> >  	while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
> > @@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
> >  	if (error & M_SMB_ERROR) {
> >  		/* Clear error bit by writing a 1 */
> >  		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
> > -		return -1;      /* XXXKW better error code? */
> > +		return -ENXIO;
> >  	}
> >  
> >  	if (data_bytes == 1)
> 
> Definitely an improvement. However, returning -ENXIO on all errors
> seems wrong. This error value should only be returned on missing ack
> from the slave on address byte. Isn't it possible to distinguish
> between different error kinds? M_SMB_ERROR_TYPE seems promising, but
> one would need to look up the datasheet (which I don't have) to
> discover its meaning.
> 
Makes sense. I'll dig up a copy of the datasheet and see if I can improve it.

Guenter

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

* Re: [PATCH] i2c/mips: Fix error return codes from Sibyte i2c bus driver
  2010-06-22 11:54       ` Guenter Roeck
@ 2010-06-26 16:14         ` Maciej W. Rozycki
  2010-06-26 16:29           ` Jean Delvare
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2010-06-26 16:14 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Jean Delvare, ben-linux@fluff.org, hsweeten@visionengravers.com,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org

On Tue, 22 Jun 2010, Guenter Roeck wrote:

> > > @@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
> > >  	if (error & M_SMB_ERROR) {
> > >  		/* Clear error bit by writing a 1 */
> > >  		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
> > > -		return -1;      /* XXXKW better error code? */
> > > +		return -ENXIO;
> > >  	}
> > >  
> > >  	if (data_bytes == 1)
> > 
> > Definitely an improvement. However, returning -ENXIO on all errors
> > seems wrong. This error value should only be returned on missing ack
> > from the slave on address byte. Isn't it possible to distinguish
> > between different error kinds? M_SMB_ERROR_TYPE seems promising, but
> > one would need to look up the datasheet (which I don't have) to
> > discover its meaning.
> > 
> Makes sense. I'll dig up a copy of the datasheet and see if I can improve it.

 The M_SMB_ERROR_TYPE bit is cleared if an expected ackonwledgement has 
not been seen and set if the transfer has failed after 15 retries.  So 
that's probably ENXIO for the former and EIO for the latter.

  Maciej

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

* Re: [PATCH] i2c/mips: Fix error return codes from Sibyte i2c bus driver
  2010-06-26 16:14         ` Maciej W. Rozycki
@ 2010-06-26 16:29           ` Jean Delvare
  0 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2010-06-26 16:29 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Guenter Roeck, ben-linux@fluff.org, hsweeten@visionengravers.com,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org

On Sat, 26 Jun 2010 17:14:59 +0100 (BST), Maciej W. Rozycki wrote:
> On Tue, 22 Jun 2010, Guenter Roeck wrote:
> 
> > > > @@ -104,7 +104,7 @@ static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
> > > >  	if (error & M_SMB_ERROR) {
> > > >  		/* Clear error bit by writing a 1 */
> > > >  		csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
> > > > -		return -1;      /* XXXKW better error code? */
> > > > +		return -ENXIO;
> > > >  	}
> > > >  
> > > >  	if (data_bytes == 1)
> > > 
> > > Definitely an improvement. However, returning -ENXIO on all errors
> > > seems wrong. This error value should only be returned on missing ack
> > > from the slave on address byte. Isn't it possible to distinguish
> > > between different error kinds? M_SMB_ERROR_TYPE seems promising, but
> > > one would need to look up the datasheet (which I don't have) to
> > > discover its meaning.
> > > 
> > Makes sense. I'll dig up a copy of the datasheet and see if I can improve it.
> 
>  The M_SMB_ERROR_TYPE bit is cleared if an expected ackonwledgement has 
> not been seen and set if the transfer has failed after 15 retries.  So 
> that's probably ENXIO for the former and EIO for the latter.

Exactly what Guenter did. Good.

-- 
Jean Delvare

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

end of thread, other threads:[~2010-06-26 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-20 17:57 [PATCH] i2c/mips: Fix error return codes from Sibyte i2c bus driver Guenter Roeck
     [not found] ` <1277056673-4305-1-git-send-email-guenter.roeck-IzeFyvvaP7pWk0Htik3J/w@public.gmane.org>
2010-06-21 17:02   ` Jean Delvare
     [not found]     ` <20100621190252.2adc6bd8-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-22 11:54       ` Guenter Roeck
2010-06-26 16:14         ` Maciej W. Rozycki
2010-06-26 16:29           ` Jean Delvare

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