lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 4 Apr 2014 09:32:32 -0700
From:	Sören Brinkmann <soren.brinkmann@...inx.com>
To:	Wolfram Sang <wsa@...-dreams.de>
CC:	Rob Herring <robh+dt@...nel.org>, Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>,
	Rob Landley <rob@...dley.net>,
	Russell King <linux@....linux.org.uk>,
	Grant Likely <grant.likely@...aro.org>,
	Michal Simek <michal.simek@...inx.com>,
	Mike Looijmans <mike.looijmans@...ic.nl>,
	<linux-kernel@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>,
	Harini Katakam <harinik@...inx.com>,
	<linux-doc@...r.kernel.org>, <devicetree@...r.kernel.org>,
	<linux-i2c@...r.kernel.org>
Subject: Re: [PATCH v4 2/3] i2c: Add driver for Cadence I2C controller

On Fri, 2014-04-04 at 04:38PM +0200, Wolfram Sang wrote:
> On Thu, Apr 03, 2014 at 10:59:26AM -0700, Soren Brinkmann wrote:
> > Add a driver for the Cadence I2C controller. This controller is for
> > example found in Xilinx Zynq.
> > 
> > Signed-off-by: Soren Brinkmann <soren.brinkmann@...inx.com>
> > Tested-by: Michal Simek <michal.simek@...inx.com>
> > Reviewed-by: Harini Katakam <harinik@...inx.com>
> 
> Only minor stuff, but since you resend anyhow because of 400kHz issue...
> 
> > +static void cdns_i2c_mrecv(struct cdns_i2c *id)
> > +{
> > +	unsigned int ctrl_reg;
> > +	unsigned int isr_status;
> > +
> > +	id->p_recv_buf = id->p_msg->buf;
> > +	id->recv_count = id->p_msg->len;
> > +
> > +	/* Put the controller in master receive mode and clear the FIFO */
> > +	ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
> > +	ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO;
> > +
> > +	if ((id->p_msg->flags & I2C_M_RECV_LEN) == I2C_M_RECV_LEN)
> 
> 'if (id->p_msg->flags & I2C_M_RECV_LEN)' is enough.
> 
> > +		/* Report the other error interrupts to application as EIO */
> > +		if (id->err_status & (CDNS_I2C_IXR_RX_UNF |
> > +				      CDNS_I2C_IXR_TX_OVF |
> > +				      CDNS_I2C_IXR_RX_OVF |
> > +				      CDNS_I2C_IXR_NACK)) {
> > +			cdns_i2c_master_reset(adap);
> > +			return -EIO;
> > +		}
> 
> NACK is returned as -ENXIO. Check 'Documentation/i2c/fault-codes' for
> standard patterns. I'd think the rest is EIO, though.

Okay, I'll put this into the next version:
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 43af8c351c8b..63f3f03ecc9b 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -311,7 +311,7 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
        ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
        ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO;
 
-       if ((id->p_msg->flags & I2C_M_RECV_LEN) == I2C_M_RECV_LEN)
+       if (id->p_msg->flags & I2C_M_RECV_LEN)
                id->recv_count = I2C_SMBUS_BLOCK_MAX + 1;
 
        /*
@@ -531,12 +531,13 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                if (ret)
                        return ret;
 
-               /* Report the other error interrupts to application as EIO */
-               if (id->err_status & (CDNS_I2C_IXR_RX_UNF |
-                                     CDNS_I2C_IXR_TX_OVF |
-                                     CDNS_I2C_IXR_RX_OVF |
-                                     CDNS_I2C_IXR_NACK)) {
+               /* Report the other error interrupts to application */
+               if (id->err_status) {
                        cdns_i2c_master_reset(adap);
+
+                       if (id->err_status & CDNS_I2C_IXR_NACK)
+                               return -ENXIO;
+
                        return -EIO;
                }
        }

	Thanks,
	Sören


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ