Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf978ab2 authored by David Brownell's avatar David Brownell Committed by Jean Delvare
Browse files

i2c-algo-bit: Whitespace fixes (+ NAK/ARB comments)



Fix *LOTS* of whitespace goofs and checkpatch.pl warnings, strangely
parenthesized ternary expressions, and other CodingStyle glitches.

Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 59d70df0
Loading
Loading
Loading
Loading
+105 −97
Original line number Diff line number Diff line
/* ------------------------------------------------------------------------- */
/* i2c-algo-bit.c i2c driver algorithms for bit-shift adapters		     */
/* ------------------------------------------------------------------------- */
/*   Copyright (C) 1995-2000 Simon G. Vogl
/* -------------------------------------------------------------------------
 * i2c-algo-bit.c i2c driver algorithms for bit-shift adapters
 * -------------------------------------------------------------------------
 *   Copyright (C) 1995-2000 Simon G. Vogl

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -15,8 +15,8 @@

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.		     */
/* ------------------------------------------------------------------------- */
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * ------------------------------------------------------------------------- */

/* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
   <kmalkki@cc.hut.fi> and Jean Delvare <khali@linux-fr.org> */
@@ -99,14 +99,13 @@ static int sclhi(struct i2c_algo_bit_data *adap)

	start = jiffies;
	while (!getscl(adap)) {
 		/* the hw knows how to read the clock line,
 		 * so we wait until it actually gets high.
 		 * This is safer as some chips may hold it low
 		 * while they are processing data internally. 
		/* This hw knows how to read the clock line, so we wait
		 * until it actually gets high.  This is safer as some
		 * chips may hold it low ("clock stretching") while they
		 * are processing data internally.
		 */
		if (time_after_eq(jiffies, start+adap->timeout)) {
		if (time_after_eq(jiffies, start + adap->timeout))
			return -ETIMEDOUT;
		}
		cond_resched();
	}
#ifdef DEBUG
@@ -175,9 +174,12 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
			bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
				"timeout at bit #%d\n", (int)c, i);
			return -ETIMEDOUT;
		};
		/* do arbitration here: 
		}
		/* FIXME do arbitration here:
		 * if (sb && !getsda(adap)) -> ouch! Get out of here.
		 *
		 * Report a unique code, so higher level code can retry
		 * the whole (combined) message and *NOT* issue STOP.
		 */
		scllo(adap);
	}
@@ -186,8 +188,11 @@ static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
		bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
			"timeout at ack\n", (int)c);
		return -ETIMEDOUT;
	};
	/* read ack: SDA should be pulled down by slave */
	}

	/* read ack: SDA should be pulled down by slave, or it may
	 * NAK (usually to report problems with the data we wrote).
	 */
	ack = !getsda(adap);    /* ack: sda is pulled low -> success */
	bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
		ack ? "A" : "NA");
@@ -213,7 +218,7 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
			bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit "
				"#%d\n", 7 - i);
			return -ETIMEDOUT;
		};
		}
		indata *= 2;
		if (getsda(adap))
			indata |= 0x01;
@@ -228,14 +233,15 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
 * Sanity check for the adapter hardware - check the reaction of
 * the bus lines only if it seems to be idle.
 */
static int test_bus(struct i2c_algo_bit_data *adap, char* name) {
static int test_bus(struct i2c_algo_bit_data *adap, char *name)
{
	int scl, sda;

	if (adap->getscl == NULL)
		pr_info("%s: Testing SDA only, SCL is not readable\n", name);

	sda = getsda(adap);
	scl=(adap->getscl==NULL?1:getscl(adap));
	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
	if (!scl || !sda) {
		printk(KERN_WARNING "%s: bus seems to be busy\n", name);
		goto bailout;
@@ -243,12 +249,12 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) {

	sdalo(adap);
	sda = getsda(adap);
	scl=(adap->getscl==NULL?1:getscl(adap));
	if ( 0 != sda ) {
	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
	if (sda) {
		printk(KERN_WARNING "%s: SDA stuck high!\n", name);
		goto bailout;
	}
	if ( 0 == scl ) {
	if (!scl) {
		printk(KERN_WARNING "%s: SCL unexpected low "
		       "while pulling SDA low!\n", name);
		goto bailout;
@@ -256,12 +262,12 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) {

	sdahi(adap);
	sda = getsda(adap);
	scl=(adap->getscl==NULL?1:getscl(adap));
	if ( 0 == sda ) {
	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
	if (!sda) {
		printk(KERN_WARNING "%s: SDA stuck low!\n", name);
		goto bailout;
	}
	if ( 0 == scl ) {
	if (!scl) {
		printk(KERN_WARNING "%s: SCL unexpected low "
		       "while pulling SDA high!\n", name);
		goto bailout;
@@ -269,12 +275,12 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) {

	scllo(adap);
	sda = getsda(adap);
	scl=(adap->getscl==NULL?0:getscl(adap));
	if ( 0 != scl ) {
	scl = (adap->getscl == NULL) ? 0 : getscl(adap);
	if (scl) {
		printk(KERN_WARNING "%s: SCL stuck high!\n", name);
		goto bailout;
	}
	if ( 0 == sda ) {
	if (!sda) {
		printk(KERN_WARNING "%s: SDA unexpected low "
		       "while pulling SCL low!\n", name);
		goto bailout;
@@ -282,12 +288,12 @@ static int test_bus(struct i2c_algo_bit_data *adap, char* name) {

	sclhi(adap);
	sda = getsda(adap);
	scl=(adap->getscl==NULL?1:getscl(adap));
	if ( 0 == scl ) {
	scl = (adap->getscl == NULL) ? 1 : getscl(adap);
	if (!scl) {
		printk(KERN_WARNING "%s: SCL stuck low!\n", name);
		goto bailout;
	}
	if ( 0 == sda ) {
	if (!sda) {
		printk(KERN_WARNING "%s: SDA unexpected low "
		       "while pulling SCL high!\n", name);
		goto bailout;
@@ -315,6 +321,7 @@ static int try_address(struct i2c_adapter *i2c_adap,
{
	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
	int i, ret = -1;

	for (i = 0; i <= retries; i++) {
		ret = i2c_outb(i2c_adap, addr);
		if (ret == 1 || i == retries)
@@ -344,7 +351,9 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)

	while (count > 0) {
		retval = i2c_outb(i2c_adap, *temp);
		if ((retval>0) || (nak_ok && (retval==0)))  { /* ok or ignored NAK */

		/* OK/ACK; or ignored NAK */
		if ((retval > 0) || (nak_ok && (retval == 0))) {
			count--;
			temp++;
			wrcount++;
@@ -444,7 +453,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)

	retries = nak_ok ? 0 : i2c_adap->retries;

	if ( (flags & I2C_M_TEN)  ) { 
	if (flags & I2C_M_TEN) {
		/* a ten bit address */
		addr = 0xf0 | ((msg->addr >> 7) & 0x03);
		bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr);
@@ -476,7 +485,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
			}
		}
	} else {		/* normal 7bit address	*/
		addr = ( msg->addr << 1 );
		addr = msg->addr << 1;
		if (flags & I2C_M_RD)
			addr |= 1;
		if (flags & I2C_M_REV_DIR_ADDR)
@@ -494,7 +503,6 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
{
	struct i2c_msg *pmsg;
	struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
	
	int i, ret;
	unsigned short nak_ok;