linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Amaury Decrême" <amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: nelson-bExrPSV3DA0@public.gmane.org,
	mhoffman-xQSgfq/1h4JiLUuM0BA3LQ@public.gmane.org,
	amalysh-S0/GAf8tV78@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Amaury Decrême"
	<amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH v2 6/6] Cleanup
Date: Fri,  4 Jan 2013 14:13:35 +0100	[thread overview]
Message-ID: <1357305215-17643-7-git-send-email-amaury.decreme@gmail.com> (raw)
In-Reply-To: <1357305215-17643-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

This patch corrects checkpatch errors.
Some "80 columns" warnings have been expressly omitted to keep reading
easy.
The changes has also been removed as it has less meaning with version
control tools.

Signed-off-by: Amaury Decrême <amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-sis630.c |  175 ++++++++++++++++++---------------------
 1 files changed, 82 insertions(+), 93 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 4bc970d..ff08dde 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -16,24 +16,6 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/*
-   Changes:
-   24.08.2002
-   	Fixed the typo in sis630_access (Thanks to Mark M. Hoffman)
-	Changed sis630_transaction.(Thanks to Mark M. Hoffman)
-   18.09.2002
-	Added SIS730 as supported.
-   21.09.2002
-	Added high_clock module option.If this option is set
-	used Host Master Clock 56KHz (default 14KHz).For now we save old Host
-	Master Clock and after transaction completed restore (otherwise
-	it's confuse BIOS and hung Machine).
-   24.09.2002
-	Fixed typo in sis630_access
-	Fixed logical error by restoring of Host Master Clock
-   31.07.2003
-   	Added block data read/write support.
-*/
 
 /*
    Status: beta
@@ -150,9 +132,10 @@ static inline void sis630_write(u8 reg, u8 data)
 	outb(data, smbus_base + reg);
 }
 
-static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldclock)
+static int sis630_transaction_start(struct i2c_adapter *adap, int size,
+								u8 *oldclock)
 {
-        u8 temp;
+	u8 temp;
 
 	/* Make sure the SMBus host is ready to start transmitting. */
 	temp = sis630_read(SMB_CNT);
@@ -165,17 +148,18 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc
 		if (temp & (SMB_PROBE | SMB_HOSTBUSY)) {
 			dev_dbg(&adap->dev, "Failed! (%02hx)\n", temp);
 			return -EBUSY;
-                } else {
+		} else {
 			dev_dbg(&adap->dev, "Successful!\n");
 		}
-        }
+	}
 
 	/* save old clock, so we can prevent machine for hung */
 	*oldclock = sis630_read(SMB_CNT);
 
 	dev_dbg(&adap->dev, "saved clock 0x%02hx\n", *oldclock);
 
-	/* disable timeout interrupt , set Host Master Clock to 56KHz if requested */
+	/* disable timeout interrupt,
+	 * set Host Master Clock to 56KHz if requested */
 	if (high_clock)
 		sis630_write(SMB_CNT, SMBCLK_SEL);
 	else
@@ -257,7 +241,8 @@ static int sis630_transaction(struct i2c_adapter *adap, int size)
 	return result;
 }
 
-static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *data, int read_write)
+static int sis630_block_data(struct i2c_adapter *adap,
+				union i2c_smbus_data *data, int read_write)
 {
 	int i, len = 0, rc = 0;
 	u8 oldclock = 0;
@@ -272,19 +257,18 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
 		for (i = 1; i <= len; i++) {
 			dev_dbg(&adap->dev, "set data 0x%02hx\n", data->block[i]);
 			/* set data */
-			sis630_write(SMB_BYTE+(i-1)%8, data->block[i]);
-			if (i==8 || (len<8 && i==len)) {
-				dev_dbg(&adap->dev, "start trans len=%d i=%d\n",len ,i);
+			sis630_write(SMB_BYTE + (i - 1) % 8, data->block[i]);
+			if (i == 8 || (len < 8 && i == len)) {
+				dev_dbg(&adap->dev, "start trans len=%d i=%d\n", len, i);
 				/* first transaction */
 				rc = sis630_transaction_start(adap,
 						SIS630_BLOCK_DATA, &oldclock);
 				if (rc)
 					return rc;
-			}
-			else if ((i-1)%8 == 7 || i==len) {
-				dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i);
-				if (i>8) {
-					dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n",len,i);
+			} else if ((i - 1) % 8 == 7 || i == len) {
+				dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n", len, i);
+				if (i > 8) {
+					dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n", len, i);
 					/*
 					   If this is not first transaction,
 					   we must clear sticky bit.
@@ -300,8 +284,7 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
 				}
 			}
 		}
-	}
-	else {
+	} else {
 		/* read request */
 		data->block[0] = len = 0;
 		rc = sis630_transaction_start(adap,
@@ -324,12 +307,12 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
 
 			dev_dbg(&adap->dev, "block data read len=0x%hx\n", data->block[0]);
 
-			for (i=0; i < 8 && len < data->block[0]; i++,len++) {
+			for (i = 0; i < 8 && len < data->block[0]; i++, len++) {
 				dev_dbg(&adap->dev, "read i=%d len=%d\n", i, len);
-				data->block[len+1] = sis630_read(SMB_BYTE+i);
+				data->block[len + 1] = sis630_read(SMB_BYTE + i);
 			}
 
-			dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n",len,i);
+			dev_dbg(&adap->dev, "clear smbary_sts len=%d i=%d\n", len, i);
 
 			/* clear SMBARY_STS */
 			sis630_write(SMB_STS, BYTE_DONE_STS);
@@ -349,42 +332,47 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
 	int status;
 
 	switch (size) {
-		case I2C_SMBUS_QUICK:
-			sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
-			size = SIS630_QUICK;
-			break;
-		case I2C_SMBUS_BYTE:
-			sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
-			if (read_write == I2C_SMBUS_WRITE)
-				sis630_write(SMB_CMD, command);
-			size = SIS630_BYTE;
-			break;
-		case I2C_SMBUS_BYTE_DATA:
-			sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
-			sis630_write(SMB_CMD, command);
-			if (read_write == I2C_SMBUS_WRITE)
-				sis630_write(SMB_BYTE, data->byte);
-			size = SIS630_BYTE_DATA;
-			break;
-		case I2C_SMBUS_PROC_CALL:
-		case I2C_SMBUS_WORD_DATA:
-			sis630_write(SMB_ADDR,((addr & 0x7f) << 1) | (read_write & 0x01));
+	case I2C_SMBUS_QUICK:
+		sis630_write(SMB_ADDR,
+				((addr & 0x7f) << 1) | (read_write & 0x01));
+		size = SIS630_QUICK;
+		break;
+	case I2C_SMBUS_BYTE:
+		sis630_write(SMB_ADDR,
+				((addr & 0x7f) << 1) | (read_write & 0x01));
+		if (read_write == I2C_SMBUS_WRITE)
 			sis630_write(SMB_CMD, command);
-			if (read_write == I2C_SMBUS_WRITE) {
-				sis630_write(SMB_BYTE, data->word & 0xff);
-				sis630_write(SMB_BYTE + 1,(data->word & 0xff00) >> 8);
-			}
-			size = (size == I2C_SMBUS_PROC_CALL ? SIS630_PCALL : SIS630_WORD_DATA);
-			break;
-		case I2C_SMBUS_BLOCK_DATA:
-			sis630_write(SMB_ADDR,((addr & 0x7f) << 1) | (read_write & 0x01));
-			sis630_write(SMB_CMD, command);
-			size = SIS630_BLOCK_DATA;
-			return sis630_block_data(adap, data, read_write);
-		default:
-			dev_warn(&adap->dev, "Unsupported transaction %d\n",
-				 size);
-			return -EOPNOTSUPP;
+		size = SIS630_BYTE;
+		break;
+	case I2C_SMBUS_BYTE_DATA:
+		sis630_write(SMB_ADDR,
+				((addr & 0x7f) << 1) | (read_write & 0x01));
+		sis630_write(SMB_CMD, command);
+		if (read_write == I2C_SMBUS_WRITE)
+			sis630_write(SMB_BYTE, data->byte);
+		size = SIS630_BYTE_DATA;
+		break;
+	case I2C_SMBUS_PROC_CALL:
+	case I2C_SMBUS_WORD_DATA:
+		sis630_write(SMB_ADDR,
+				((addr & 0x7f) << 1) | (read_write & 0x01));
+		sis630_write(SMB_CMD, command);
+		if (read_write == I2C_SMBUS_WRITE) {
+			sis630_write(SMB_BYTE, data->word & 0xff);
+			sis630_write(SMB_BYTE + 1, (data->word & 0xff00) >> 8);
+		}
+		size = (size == I2C_SMBUS_PROC_CALL ? SIS630_PCALL :
+							SIS630_WORD_DATA);
+		break;
+	case I2C_SMBUS_BLOCK_DATA:
+		sis630_write(SMB_ADDR,
+				((addr & 0x7f) << 1) | (read_write & 0x01));
+		sis630_write(SMB_CMD, command);
+		size = SIS630_BLOCK_DATA;
+		return sis630_block_data(adap, data, read_write);
+	default:
+		dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+		return -EOPNOTSUPP;
 	}
 
 	status = sis630_transaction(adap, size);
@@ -396,15 +384,16 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
 		return 0;
 	}
 
-	switch(size) {
-		case SIS630_BYTE:
-		case SIS630_BYTE_DATA:
-			data->byte = sis630_read(SMB_BYTE);
-			break;
-		case SIS630_PCALL:
-		case SIS630_WORD_DATA:
-			data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
-			break;
+	switch (size) {
+	case SIS630_BYTE:
+	case SIS630_BYTE_DATA:
+		data->byte = sis630_read(SMB_BYTE);
+		break;
+	case SIS630_PCALL:
+	case SIS630_WORD_DATA:
+		data->word = sis630_read(SMB_BYTE) +
+					(sis630_read(SMB_BYTE + 1) << 8);
+		break;
 	}
 
 	return 0;
@@ -412,9 +401,9 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
 
 static u32 sis630_func(struct i2c_adapter *adapter)
 {
-	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
-		I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL |
-		I2C_FUNC_SMBUS_BLOCK_DATA;
+	return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
+		I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
+		I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_DATA;
 }
 
 static int sis630_setup(struct pci_dev *sis630_dev)
@@ -426,19 +415,18 @@ static int sis630_setup(struct pci_dev *sis630_dev)
 	unsigned short acpi_base;
 
 	/* check for supported SiS devices */
-	for (i=0; supported[i] > 0 ; i++) {
-		if ((dummy = pci_get_device(PCI_VENDOR_ID_SI, supported[i], dummy)))
+	for (i = 0; supported[i] > 0; i++) {
+		dummy = pci_get_device(PCI_VENDOR_ID_SI, supported[i], dummy);
+		if (dummy)
 			break; /* found */
 	}
 
 	if (dummy) {
 		pci_dev_put(dummy);
-	}
-        else if (force) {
+	} else if (force) {
 		dev_err(&sis630_dev->dev, "WARNING: Can't detect SIS630 compatible device, but "
 			"loading because of force option enabled\n");
- 	}
-	else {
+	} else {
 		return -ENODEV;
 	}
 
@@ -446,7 +434,7 @@ static int sis630_setup(struct pci_dev *sis630_dev)
 	   Enable ACPI first , so we can accsess reg 74-75
 	   in acpi io space and read acpi base addr
 	*/
-	if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) {
+	if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, &b)) {
 		dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n");
 		retval = -ENODEV;
 		goto exit;
@@ -460,7 +448,8 @@ static int sis630_setup(struct pci_dev *sis630_dev)
 	}
 
 	/* Determine the ACPI base address */
-	if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) {
+	if (pci_read_config_word(sis630_dev,
+					SIS630_ACPI_BASE_REG, &acpi_base)) {
 		dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n");
 		retval = -ENODEV;
 		goto exit;
@@ -519,7 +508,7 @@ static DEFINE_PCI_DEVICE_TABLE(sis630_ids) = {
 	{ 0, }
 };
 
-MODULE_DEVICE_TABLE (pci, sis630_ids);
+MODULE_DEVICE_TABLE(pci, sis630_ids);
 
 static int sis630_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
-- 
1.7.8.6

  parent reply	other threads:[~2013-01-04 13:13 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1346204115-30293-1-git-send-email-amaury.decreme@gmail.com>
     [not found] ` <1346204115-30293-2-git-send-email-amaury.decreme@gmail.com>
     [not found]   ` <1346204115-30293-2-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-04 12:57     ` [PATCH resend 1/2] I2C: sis630: sis964 bus Jean Delvare
     [not found]       ` <20121004145702.2be5b612-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-04 11:33         ` Amaury Decrême
     [not found] ` <1346204115-30293-3-git-send-email-amaury.decreme@gmail.com>
     [not found]   ` <1346204115-30293-3-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-04 15:29     ` [PATCH resend 2/2] I2C: sis630: Cleaning and cosmetics Jean Delvare
     [not found]       ` <20121004172939.387eb8d1-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-04 11:44         ` Amaury Decrême
2013-01-04 12:53           ` Jean Delvare
     [not found] ` <1346204115-30293-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-12-18 11:51   ` [PATCH resend 0/2] I2C: sis630: add sis964 support Jean Delvare
     [not found]     ` <20121218125105.25c2cbb6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-12-28 19:24       ` Amaury Decrême
2013-01-04  9:39         ` Jean Delvare
2013-01-04 13:13   ` [PATCH v2 0/6] " Amaury Decrême
     [not found]     ` <1357305215-17643-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-04 13:13       ` [PATCH v2 1/6] Add SIS964 bus support to i2c-sis630 Amaury Decrême
     [not found]         ` <1357305215-17643-2-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 16:28           ` Jean Delvare
2013-01-04 13:13       ` [PATCH v2 2/6] Bugfix: clear sticky bits Amaury Decrême
     [not found]         ` <1357305215-17643-3-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 16:34           ` Jean Delvare
2013-01-04 13:13       ` [PATCH v2 3/6] Bugfix: behavior after collision Amaury Decrême
     [not found]         ` <1357305215-17643-4-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 16:38           ` Jean Delvare
2013-01-04 13:13       ` [PATCH v2 4/6] Cosmetics: hex to constants for SMBus commands Amaury Decrême
     [not found]         ` <1357305215-17643-5-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 17:42           ` Jean Delvare
     [not found]             ` <20130128184233.48b19a04-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 20:58               ` Amaury Decrême
2013-01-04 13:13       ` [PATCH v2 5/6] Misc: display unsigned hex Amaury Decrême
     [not found]         ` <1357305215-17643-6-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 18:33           ` Jean Delvare
     [not found]             ` <20130128193304.657b869f-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 21:00               ` Amaury Decrême
2013-01-04 13:13       ` Amaury Decrême [this message]
     [not found]         ` <1357305215-17643-7-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 18:40           ` [PATCH v2 6/6] Cleanup Jean Delvare
     [not found]             ` <20130128194007.3d3c0d4d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 21:10               ` Amaury Decrême
2013-01-24  7:28       ` [PATCH v2 0/6] I2C: sis630: add sis964 support Wolfram Sang
     [not found]         ` <20130124072818.GM8364-8EAEigeeuNG034pCzgS/Qg7AFbiQbgqx@public.gmane.org>
2013-01-24  7:30           ` Jean Delvare
     [not found]             ` <20130124083043.57f91a3d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-28 21:21               ` [PATCH v3 " Amaury Decrême
     [not found]                 ` <1359408070-31832-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-28 21:21                   ` [PATCH v3 1/6] Add SIS964 bus support to i2c-sis630 Amaury Decrême
2013-01-28 21:21                   ` [PATCH v3 2/6] Bugfix: clear sticky bits Amaury Decrême
2013-01-28 21:21                   ` [PATCH v3 3/6] Bugfix: behavior after collision Amaury Decrême
2013-01-28 21:21                   ` [PATCH v3 4/6] Cosmetics: hex to constants for SMBus commands Amaury Decrême
     [not found]                     ` <1359408070-31832-5-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-29  9:13                       ` Jean Delvare
2013-01-28 21:21                   ` [PATCH v3 5/6] Misc: display unsigned hex Amaury Decrême
     [not found]                     ` <1359408070-31832-6-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-29  9:19                       ` Jean Delvare
2013-01-28 21:21                   ` [PATCH v3 6/6] Cleanup Amaury Decrême
     [not found]                     ` <1359408070-31832-7-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-29  9:31                       ` Jean Delvare
     [not found]                         ` <20130129103151.21262d1d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-29 20:22                           ` [PATCH v4] Cleanup Amaury Decrême
     [not found]                             ` <1359490946-24005-1-git-send-email-amaury.decreme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-01-30  9:06                               ` Jean Delvare
     [not found]                                 ` <20130130100638.43422a3e-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-01-30 22:16                                   ` Amaury Decrême

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=1357305215-17643-7-git-send-email-amaury.decreme@gmail.com \
    --to=amaury.decreme-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amalysh-S0/GAf8tV78@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mhoffman-xQSgfq/1h4JiLUuM0BA3LQ@public.gmane.org \
    --cc=nelson-bExrPSV3DA0@public.gmane.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;
as well as URLs for NNTP newsgroup(s).