From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfram Sang Subject: Re: [PATCH] i2c-imx: do not allow interruptions when waiting for I2C to complete Date: Thu, 27 May 2010 13:49:48 +0200 Message-ID: <20100527114948.GC31253@pengutronix.de> References: <1274960188-12601-1-git-send-email-mkl@pengutronix.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+nBD6E3TurpgldQp" Return-path: Content-Disposition: inline In-Reply-To: <1274960188-12601-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Marc Kleine-Budde Cc: sha-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org, "Jean Delvare (PC drivers, core)" , "Ben Dooks (embedded platforms)" , Richard Zhao , Uwe =?iso-8859-15?Q?Kleine-K=F6nig?= , Arnaud Patard , linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-i2c@vger.kernel.org --+nBD6E3TurpgldQp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 27, 2010 at 01:36:27PM +0200, Marc Kleine-Budde wrote: > The i2c_imx_trx_complete() function is using > wait_event_interruptible_timeout() to wait for the I2C controller to > signal that it has completed an I2C bus operation. If the process that > causes the I2C operation receives a signal, the wait will be > interrupted, returning an error. It is better to let the I2C operation > finished before handling the signal (i.e. returning into userspace). >=20 > It is safe to use wait_event_timeout() instead, because the timeout > will allow the process to exit if the I2C bus hangs. It's also better > to allow the I2C operation to finish, because unacknowledged I2C > operations can cause the I2C bus to hang. >=20 > Signed-off-by: Marc Kleine-Budde > --- > drivers/i2c/busses/i2c-imx.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c > index d1ff940..d7051fe 100644 > --- a/drivers/i2c/busses/i2c-imx.c > +++ b/drivers/i2c/busses/i2c-imx.c > @@ -161,7 +161,7 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct= *i2c_imx) > { > int result; > =20 > - result =3D wait_event_interruptible_timeout(i2c_imx->queue, > + result =3D wait_event_timeout(i2c_imx->queue, > i2c_imx->i2csr & I2SR_IIF, HZ / 10); > =20 > if (unlikely(result < 0)) { That 'if' can go, too. wait_event_timeout does not return neg values. --=20 Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | --+nBD6E3TurpgldQp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkv+XFwACgkQD27XaX1/VRtH9ACgxswVYA+J2tkR62LsKz74f5tK 7loAn32AwnhlDwuNbu9wHOkZEXwTsRGC =XmUv -----END PGP SIGNATURE----- --+nBD6E3TurpgldQp--