linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: i2c-nforce2: fix coding style issues
@ 2012-12-19 21:06 Laurent Navet
  2012-12-21 10:04 ` Jean Delvare
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Navet @ 2012-12-19 21:06 UTC (permalink / raw)
  To: w.sang; +Cc: khali, ben-linux, linux-i2c, linux-kernel, Laurent Navet

avoid these checkpatch.pl issues :
- ERROR: "foo * bar" should be "foo *bar"
- ERROR: switch and case should be at the same indent
- ERROR: "(foo*)" should be "(foo *)"
- ERROR: do not use assignment in if condition
- ERROR: space required before the open parenthesis '('
- WARNING: suspect code indent for conditional statements
- WARNING: quoted string split across lines
- WARNING: space prohibited between function name and open parenthesis '('

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
---
 drivers/i2c/busses/i2c-nforce2.c |  149 +++++++++++++++++++-------------------
 1 file changed, 75 insertions(+), 74 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 392303b..03f32c5 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -60,7 +60,7 @@
 #include <linux/io.h>
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>");
+MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
 MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
 
 
@@ -188,9 +188,9 @@ static int nforce2_check_status(struct i2c_adapter *adap)
 }
 
 /* Return negative errno on error */
-static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
+static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
 		unsigned short flags, char read_write,
-		u8 command, int size, union i2c_smbus_data * data)
+		u8 command, int size, union i2c_smbus_data *data)
 {
 	struct nforce2_smbus *smbus = adap->algo_data;
 	unsigned char protocol, pec;
@@ -203,55 +203,54 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 
 	switch (size) {
 
-		case I2C_SMBUS_QUICK:
-			protocol |= NVIDIA_SMB_PRTCL_QUICK;
-			read_write = I2C_SMBUS_WRITE;
-			break;
+	case I2C_SMBUS_QUICK:
+		protocol |= NVIDIA_SMB_PRTCL_QUICK;
+		read_write = I2C_SMBUS_WRITE;
+		break;
 
-		case I2C_SMBUS_BYTE:
-			if (read_write == I2C_SMBUS_WRITE)
-				outb_p(command, NVIDIA_SMB_CMD);
-			protocol |= NVIDIA_SMB_PRTCL_BYTE;
-			break;
-
-		case I2C_SMBUS_BYTE_DATA:
-			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE)
-				outb_p(data->byte, NVIDIA_SMB_DATA);
-			protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
-			break;
-
-		case I2C_SMBUS_WORD_DATA:
-			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE) {
-				 outb_p(data->word, NVIDIA_SMB_DATA);
-				 outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);
-			}
-			protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
-			break;
-
-		case I2C_SMBUS_BLOCK_DATA:
+	case I2C_SMBUS_BYTE:
+		if (read_write == I2C_SMBUS_WRITE)
 			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE) {
-				len = data->block[0];
-				if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
-					dev_err(&adap->dev,
-						"Transaction failed "
-						"(requested block size: %d)\n",
-						len);
-					return -EINVAL;
-				}
-				outb_p(len, NVIDIA_SMB_BCNT);
-				for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
-					outb_p(data->block[i + 1],
-					       NVIDIA_SMB_DATA+i);
+		protocol |= NVIDIA_SMB_PRTCL_BYTE;
+		break;
+
+	case I2C_SMBUS_BYTE_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE)
+			outb_p(data->byte, NVIDIA_SMB_DATA);
+		protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE) {
+			outb_p(data->word, NVIDIA_SMB_DATA);
+			outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);
+		}
+		protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
+		break;
+
+	case I2C_SMBUS_BLOCK_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE) {
+			len = data->block[0];
+			if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
+				dev_err(&adap->dev,
+				"Transaction failed (requested block size: %d)\n",
+				len);
+				return -EINVAL;
 			}
-			protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
-			break;
+			outb_p(len, NVIDIA_SMB_BCNT);
+			for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
+				outb_p(data->block[i + 1],
+				       NVIDIA_SMB_DATA+i);
+		}
+		protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
+		break;
 
-		default:
-			dev_err(&adap->dev, "Unsupported transaction %d\n", size);
-			return -EOPNOTSUPP;
+	default:
+		dev_err(&adap->dev, "Unsupported transaction %d\n", size);
+		return -EOPNOTSUPP;
 	}
 
 	outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
@@ -266,27 +265,28 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 
 	switch (size) {
 
-		case I2C_SMBUS_BYTE:
-		case I2C_SMBUS_BYTE_DATA:
-			data->byte = inb_p(NVIDIA_SMB_DATA);
-			break;
-
-		case I2C_SMBUS_WORD_DATA:
-			data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8);
-			break;
-
-		case I2C_SMBUS_BLOCK_DATA:
-			len = inb_p(NVIDIA_SMB_BCNT);
-			if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
-				dev_err(&adap->dev, "Transaction failed "
-					"(received block size: 0x%02x)\n",
-					len);
-				return -EPROTO;
-			}
-			for (i = 0; i < len; i++)
-				data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
-			data->block[0] = len;
-			break;
+	case I2C_SMBUS_BYTE:
+	case I2C_SMBUS_BYTE_DATA:
+		data->byte = inb_p(NVIDIA_SMB_DATA);
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		data->word = inb_p(NVIDIA_SMB_DATA) |
+			(inb_p(NVIDIA_SMB_DATA+1) << 8);
+		break;
+
+	case I2C_SMBUS_BLOCK_DATA:
+		len = inb_p(NVIDIA_SMB_BCNT);
+		if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
+			dev_err(&adap->dev,
+			"Transaction failed (received block size: 0x%02x)\n",
+			len);
+			return -EPROTO;
+		}
+		for (i = 0; i < len; i++)
+			data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
+		data->block[0] = len;
+		break;
 	}
 
 	return 0;
@@ -299,7 +299,7 @@ static u32 nforce2_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_PEC |
-	       (((struct nforce2_smbus*)adapter->algo_data)->blockops ?
+	       (((struct nforce2_smbus *)adapter->algo_data)->blockops ?
 		I2C_FUNC_SMBUS_BLOCK_DATA : 0);
 }
 
@@ -327,10 +327,10 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
 	{ 0 }
 };
 
-MODULE_DEVICE_TABLE (pci, nforce2_ids);
+MODULE_DEVICE_TABLE(pci, nforce2_ids);
 
 
-static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
+static int __devinit nforce2_probe_smb(struct pci_dev *dev, int bar,
 	int alt_reg, struct nforce2_smbus *smbus, const char *name)
 {
 	int error;
@@ -388,11 +388,12 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
 	int res1, res2;
 
 	/* we support 2 SMBus adapters */
-	if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL)))
+	smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL);
+	if (!smbuses)
 		return -ENOMEM;
 	pci_set_drvdata(dev, smbuses);
 
-	switch(dev->device) {
+	switch (dev->device) {
 	case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS:
 	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS:
 	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:
-- 
1.7.10.4


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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2012-12-19 21:06 [PATCH] drivers: i2c-nforce2: fix coding style issues Laurent Navet
@ 2012-12-21 10:04 ` Jean Delvare
  2012-12-21 14:15   ` Laurent Navet
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Delvare @ 2012-12-21 10:04 UTC (permalink / raw)
  To: Laurent Navet; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

Hi Laurent,

On Wed, 19 Dec 2012 22:06:11 +0100, Laurent Navet wrote:
> avoid these checkpatch.pl issues :
> - ERROR: "foo * bar" should be "foo *bar"
> - ERROR: switch and case should be at the same indent
> - ERROR: "(foo*)" should be "(foo *)"
> - ERROR: do not use assignment in if condition
> - ERROR: space required before the open parenthesis '('
> - WARNING: suspect code indent for conditional statements
> - WARNING: quoted string split across lines
> - WARNING: space prohibited between function name and open parenthesis '('
> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  drivers/i2c/busses/i2c-nforce2.c |  149 +++++++++++++++++++-------------------
>  1 file changed, 75 insertions(+), 74 deletions(-)

Thanks for the update. I have a few more comments:

> 
> diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
> index 392303b..03f32c5 100644
> --- a/drivers/i2c/busses/i2c-nforce2.c
> +++ b/drivers/i2c/busses/i2c-nforce2.c
> @@ -60,7 +60,7 @@
>  #include <linux/io.h>
>  
>  MODULE_LICENSE("GPL");
> -MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>");
> +MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
>  MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
>  
>  
> @@ -188,9 +188,9 @@ static int nforce2_check_status(struct i2c_adapter *adap)
>  }
>  
>  /* Return negative errno on error */
> -static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
> +static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
>  		unsigned short flags, char read_write,
> -		u8 command, int size, union i2c_smbus_data * data)
> +		u8 command, int size, union i2c_smbus_data *data)
>  {
>  	struct nforce2_smbus *smbus = adap->algo_data;
>  	unsigned char protocol, pec;
> @@ -203,55 +203,54 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
>  
>  	switch (size) {
>  

While you're here, please drop this useless blank line.

> -		case I2C_SMBUS_QUICK:
> -			protocol |= NVIDIA_SMB_PRTCL_QUICK;
> -			read_write = I2C_SMBUS_WRITE;
> -			break;
> +	case I2C_SMBUS_QUICK:
> +		protocol |= NVIDIA_SMB_PRTCL_QUICK;
> +		read_write = I2C_SMBUS_WRITE;
> +		break;
>  
> -		case I2C_SMBUS_BYTE:
> -			if (read_write == I2C_SMBUS_WRITE)
> -				outb_p(command, NVIDIA_SMB_CMD);
> -			protocol |= NVIDIA_SMB_PRTCL_BYTE;
> -			break;
> -
> -		case I2C_SMBUS_BYTE_DATA:
> -			outb_p(command, NVIDIA_SMB_CMD);
> -			if (read_write == I2C_SMBUS_WRITE)
> -				outb_p(data->byte, NVIDIA_SMB_DATA);
> -			protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
> -			break;
> -
> -		case I2C_SMBUS_WORD_DATA:
> -			outb_p(command, NVIDIA_SMB_CMD);
> -			if (read_write == I2C_SMBUS_WRITE) {
> -				 outb_p(data->word, NVIDIA_SMB_DATA);
> -				 outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);
> -			}
> -			protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
> -			break;
> -
> -		case I2C_SMBUS_BLOCK_DATA:
> +	case I2C_SMBUS_BYTE:
> +		if (read_write == I2C_SMBUS_WRITE)
>  			outb_p(command, NVIDIA_SMB_CMD);
> -			if (read_write == I2C_SMBUS_WRITE) {
> -				len = data->block[0];
> -				if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> -					dev_err(&adap->dev,
> -						"Transaction failed "
> -						"(requested block size: %d)\n",
> -						len);
> -					return -EINVAL;
> -				}
> -				outb_p(len, NVIDIA_SMB_BCNT);
> -				for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
> -					outb_p(data->block[i + 1],
> -					       NVIDIA_SMB_DATA+i);
> +		protocol |= NVIDIA_SMB_PRTCL_BYTE;
> +		break;
> +
> +	case I2C_SMBUS_BYTE_DATA:
> +		outb_p(command, NVIDIA_SMB_CMD);
> +		if (read_write == I2C_SMBUS_WRITE)
> +			outb_p(data->byte, NVIDIA_SMB_DATA);
> +		protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
> +		break;
> +
> +	case I2C_SMBUS_WORD_DATA:
> +		outb_p(command, NVIDIA_SMB_CMD);
> +		if (read_write == I2C_SMBUS_WRITE) {
> +			outb_p(data->word, NVIDIA_SMB_DATA);
> +			outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);

While this isn't reported by checkpatch, I'd appreciate if you could
add spaces around "+" on lines you're already touching.

> +		}
> +		protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
> +		break;
> +
> +	case I2C_SMBUS_BLOCK_DATA:
> +		outb_p(command, NVIDIA_SMB_CMD);
> +		if (read_write == I2C_SMBUS_WRITE) {
> +			len = data->block[0];
> +			if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> +				dev_err(&adap->dev,
> +				"Transaction failed (requested block size: %d)\n",
> +				len);

Your indentation is wrong here, the last two lines should be aligned on
the opening parenthesis of the previous line.

> +				return -EINVAL;
>  			}
> -			protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
> -			break;
> +			outb_p(len, NVIDIA_SMB_BCNT);
> +			for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
> +				outb_p(data->block[i + 1],
> +				       NVIDIA_SMB_DATA+i);
> +		}
> +		protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
> +		break;
>  
> -		default:
> -			dev_err(&adap->dev, "Unsupported transaction %d\n", size);
> -			return -EOPNOTSUPP;
> +	default:
> +		dev_err(&adap->dev, "Unsupported transaction %d\n", size);
> +		return -EOPNOTSUPP;
>  	}
>  
>  	outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
> @@ -266,27 +265,28 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
>  
>  	switch (size) {
>  

While you're here, please drop this useless blank line.

> -		case I2C_SMBUS_BYTE:
> -		case I2C_SMBUS_BYTE_DATA:
> -			data->byte = inb_p(NVIDIA_SMB_DATA);
> -			break;
> -
> -		case I2C_SMBUS_WORD_DATA:
> -			data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8);
> -			break;
> -
> -		case I2C_SMBUS_BLOCK_DATA:
> -			len = inb_p(NVIDIA_SMB_BCNT);
> -			if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> -				dev_err(&adap->dev, "Transaction failed "
> -					"(received block size: 0x%02x)\n",
> -					len);
> -				return -EPROTO;
> -			}
> -			for (i = 0; i < len; i++)
> -				data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
> -			data->block[0] = len;
> -			break;
> +	case I2C_SMBUS_BYTE:
> +	case I2C_SMBUS_BYTE_DATA:
> +		data->byte = inb_p(NVIDIA_SMB_DATA);
> +		break;
> +
> +	case I2C_SMBUS_WORD_DATA:
> +		data->word = inb_p(NVIDIA_SMB_DATA) |
> +			(inb_p(NVIDIA_SMB_DATA+1) << 8);

Please add a few spaces to align on the = sign:

		data->word = inb_p(NVIDIA_SMB_DATA) |
			     (inb_p(NVIDIA_SMB_DATA + 1) << 8);

> +		break;
> +
> +	case I2C_SMBUS_BLOCK_DATA:
> +		len = inb_p(NVIDIA_SMB_BCNT);
> +		if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> +			dev_err(&adap->dev,
> +			"Transaction failed (received block size: 0x%02x)\n",
> +			len);

Your indentation is wrong here, the last two lines should be aligned on
the opening parenthesis of the previous line.

> +			return -EPROTO;
> +		}
> +		for (i = 0; i < len; i++)
> +			data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
> +		data->block[0] = len;
> +		break;
>  	}
>  
>  	return 0;
> @@ -299,7 +299,7 @@ static u32 nforce2_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_PEC |
> -	       (((struct nforce2_smbus*)adapter->algo_data)->blockops ?
> +	       (((struct nforce2_smbus *)adapter->algo_data)->blockops ?
>  		I2C_FUNC_SMBUS_BLOCK_DATA : 0);
>  }
>  
> @@ -327,10 +327,10 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
>  	{ 0 }
>  };
>  
> -MODULE_DEVICE_TABLE (pci, nforce2_ids);
> +MODULE_DEVICE_TABLE(pci, nforce2_ids);
>  
>  
> -static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
> +static int __devinit nforce2_probe_smb(struct pci_dev *dev, int bar,
>  	int alt_reg, struct nforce2_smbus *smbus, const char *name)

This change causes a reject because __devinit was removed by another
patch:
http://git.pengutronix.de/?p=wsa/linux.git;a=commit;h=cda2826abea9a78d21b5e35d71db328657b756e5

The space issue was fixed in that patch too so you can simply omit that
change from your own patch to avoid the reject.

>  {
>  	int error;
> @@ -388,11 +388,12 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
>  	int res1, res2;
>  
>  	/* we support 2 SMBus adapters */
> -	if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL)))
> +	smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL);

Spaces around "*" please.

> +	if (!smbuses)
>  		return -ENOMEM;
>  	pci_set_drvdata(dev, smbuses);
>  
> -	switch(dev->device) {
> +	switch (dev->device) {
>  	case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS:
>  	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS:
>  	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:

Other than these minor details, this looks good. You could fix the
following warning as well:

WARNING: line over 80 characters
#380: FILE: i2c/busses/i2c-nforce2.c:380:
+	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base);

It's an easy one. Please resubmit with the requested changes and then
Wolfram can apply your patch. Thanks for the good work!

-- 
Jean Delvare

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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2012-12-21 10:04 ` Jean Delvare
@ 2012-12-21 14:15   ` Laurent Navet
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Navet @ 2012-12-21 14:15 UTC (permalink / raw)
  To: Jean Delvare; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

> This change causes a reject because __devinit was removed by another
> patch:
> http://git.pengutronix.de/?p=wsa/linux.git;a=commit;h=cda2826abea9a78d21b5e35d71db328657b756e5

i have tested that it applies cleanly on linux-next only, will try on
pengutronix.de/git/wsa/linux.git next time.

> It's an easy one. Please resubmit with the requested changes and then
> Wolfram can apply your patch. Thanks for the good work!
Regards,

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

* [PATCH] drivers: i2c-nforce2: fix coding style issues
@ 2013-01-09 20:50 Laurent Navet
  2013-01-10  8:32 ` Jean Delvare
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Navet @ 2013-01-09 20:50 UTC (permalink / raw)
  To: w.sang; +Cc: khali, ben-linux, linux-i2c, linux-kernel, Laurent Navet

avoid these checkpatch.pl issues :
- ERROR: "foo * bar" should be "foo *bar"
- ERROR: switch and case should be at the same indent
- ERROR: "(foo*)" should be "(foo *)"
- ERROR: do not use assignment in if condition
- ERROR: space required before the open parenthesis '('
- WARNING: suspect code indent for conditional statements
- WARNING: quoted string split across lines
- WARNING: space prohibited between function name and open parenthesis '('

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
---
 drivers/i2c/busses/i2c-nforce2.c |  153 +++++++++++++++++++-------------------
 1 file changed, 76 insertions(+), 77 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 392303b..90357a2 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -60,7 +60,7 @@
 #include <linux/io.h>
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>");
+MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
 MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
 
 
@@ -188,9 +188,9 @@ static int nforce2_check_status(struct i2c_adapter *adap)
 }
 
 /* Return negative errno on error */
-static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
+static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
 		unsigned short flags, char read_write,
-		u8 command, int size, union i2c_smbus_data * data)
+		u8 command, int size, union i2c_smbus_data *data)
 {
 	struct nforce2_smbus *smbus = adap->algo_data;
 	unsigned char protocol, pec;
@@ -202,56 +202,54 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 	pec = (flags & I2C_CLIENT_PEC) ? NVIDIA_SMB_PRTCL_PEC : 0;
 
 	switch (size) {
+	case I2C_SMBUS_QUICK:
+		protocol |= NVIDIA_SMB_PRTCL_QUICK;
+		read_write = I2C_SMBUS_WRITE;
+		break;
 
-		case I2C_SMBUS_QUICK:
-			protocol |= NVIDIA_SMB_PRTCL_QUICK;
-			read_write = I2C_SMBUS_WRITE;
-			break;
-
-		case I2C_SMBUS_BYTE:
-			if (read_write == I2C_SMBUS_WRITE)
-				outb_p(command, NVIDIA_SMB_CMD);
-			protocol |= NVIDIA_SMB_PRTCL_BYTE;
-			break;
-
-		case I2C_SMBUS_BYTE_DATA:
-			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE)
-				outb_p(data->byte, NVIDIA_SMB_DATA);
-			protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
-			break;
-
-		case I2C_SMBUS_WORD_DATA:
+	case I2C_SMBUS_BYTE:
+		if (read_write == I2C_SMBUS_WRITE)
 			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE) {
-				 outb_p(data->word, NVIDIA_SMB_DATA);
-				 outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);
-			}
-			protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
-			break;
-
-		case I2C_SMBUS_BLOCK_DATA:
-			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE) {
-				len = data->block[0];
-				if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
-					dev_err(&adap->dev,
-						"Transaction failed "
-						"(requested block size: %d)\n",
-						len);
-					return -EINVAL;
-				}
-				outb_p(len, NVIDIA_SMB_BCNT);
-				for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
-					outb_p(data->block[i + 1],
-					       NVIDIA_SMB_DATA+i);
+		protocol |= NVIDIA_SMB_PRTCL_BYTE;
+		break;
+
+	case I2C_SMBUS_BYTE_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE)
+			outb_p(data->byte, NVIDIA_SMB_DATA);
+		protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE) {
+			outb_p(data->word, NVIDIA_SMB_DATA);
+			outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1);
+		}
+		protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
+		break;
+
+	case I2C_SMBUS_BLOCK_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE) {
+			len = data->block[0];
+			if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
+				dev_err(&adap->dev,
+					"Transaction failed (requested block size: %d)\n",
+					len);
+				return -EINVAL;
 			}
-			protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
-			break;
+			outb_p(len, NVIDIA_SMB_BCNT);
+			for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
+				outb_p(data->block[i + 1],
+				       NVIDIA_SMB_DATA + i);
+		}
+		protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
+		break;
 
-		default:
-			dev_err(&adap->dev, "Unsupported transaction %d\n", size);
-			return -EOPNOTSUPP;
+	default:
+		dev_err(&adap->dev, "Unsupported transaction %d\n", size);
+		return -EOPNOTSUPP;
 	}
 
 	outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
@@ -265,28 +263,27 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 		return 0;
 
 	switch (size) {
-
-		case I2C_SMBUS_BYTE:
-		case I2C_SMBUS_BYTE_DATA:
-			data->byte = inb_p(NVIDIA_SMB_DATA);
-			break;
-
-		case I2C_SMBUS_WORD_DATA:
-			data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8);
-			break;
-
-		case I2C_SMBUS_BLOCK_DATA:
-			len = inb_p(NVIDIA_SMB_BCNT);
-			if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
-				dev_err(&adap->dev, "Transaction failed "
-					"(received block size: 0x%02x)\n",
-					len);
-				return -EPROTO;
-			}
-			for (i = 0; i < len; i++)
-				data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
-			data->block[0] = len;
-			break;
+	case I2C_SMBUS_BYTE:
+	case I2C_SMBUS_BYTE_DATA:
+		data->byte = inb_p(NVIDIA_SMB_DATA);
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA + 1) << 8);
+		break;
+
+	case I2C_SMBUS_BLOCK_DATA:
+		len = inb_p(NVIDIA_SMB_BCNT);
+		if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
+			dev_err(&adap->dev,
+				"Transaction failed (received block size: 0x%02x)\n",
+				len);
+			return -EPROTO;
+		}
+		for (i = 0; i < len; i++)
+			data->block[i + 1] = inb_p(NVIDIA_SMB_DATA + i);
+		data->block[0] = len;
+		break;
 	}
 
 	return 0;
@@ -299,7 +296,7 @@ static u32 nforce2_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_PEC |
-	       (((struct nforce2_smbus*)adapter->algo_data)->blockops ?
+	       (((struct nforce2_smbus *)adapter->algo_data)->blockops ?
 		I2C_FUNC_SMBUS_BLOCK_DATA : 0);
 }
 
@@ -327,10 +324,10 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
 	{ 0 }
 };
 
-MODULE_DEVICE_TABLE (pci, nforce2_ids);
+MODULE_DEVICE_TABLE(pci, nforce2_ids);
 
 
-static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
+static int __devinit nforce2_probe_smb(struct pci_dev *dev, int bar,
 	int alt_reg, struct nforce2_smbus *smbus, const char *name)
 {
 	int error;
@@ -377,7 +374,8 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
 		release_region(smbus->base, smbus->size);
 		return error;
 	}
-	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base);
+	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n",
+		smbus->base);
 	return 0;
 }
 
@@ -388,11 +386,12 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
 	int res1, res2;
 
 	/* we support 2 SMBus adapters */
-	if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL)))
+	smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
+	if (!smbuses)
 		return -ENOMEM;
 	pci_set_drvdata(dev, smbuses);
 
-	switch(dev->device) {
+	switch (dev->device) {
 	case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS:
 	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS:
 	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:
-- 
1.7.10.4


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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2013-01-09 20:50 Laurent Navet
@ 2013-01-10  8:32 ` Jean Delvare
  2013-01-10  8:52   ` Laurent Navet
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Delvare @ 2013-01-10  8:32 UTC (permalink / raw)
  To: Laurent Navet; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

Hi Laurent,

Thanks for the updated patch.

On Wed,  9 Jan 2013 21:50:24 +0100, Laurent Navet wrote:
> avoid these checkpatch.pl issues :
> - ERROR: "foo * bar" should be "foo *bar"
> - ERROR: switch and case should be at the same indent
> - ERROR: "(foo*)" should be "(foo *)"
> - ERROR: do not use assignment in if condition
> - ERROR: space required before the open parenthesis '('
> - WARNING: suspect code indent for conditional statements
> - WARNING: quoted string split across lines
> - WARNING: space prohibited between function name and open parenthesis '('

Unfortunately your patch also add one new checkpatch.pl warning:

WARNING: line over 80 characters
#245: FILE: drivers/i2c/busses/i2c-nforce2.c:272:
+		data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA + 1) << 8);

Please fix.

> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  drivers/i2c/busses/i2c-nforce2.c |  153 +++++++++++++++++++-------------------
>  1 file changed, 76 insertions(+), 77 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
> index 392303b..90357a2 100644
> --- a/drivers/i2c/busses/i2c-nforce2.c
> +++ b/drivers/i2c/busses/i2c-nforce2.c
> (...)
> @@ -327,10 +324,10 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
>  	{ 0 }
>  };
>  
> -MODULE_DEVICE_TABLE (pci, nforce2_ids);
> +MODULE_DEVICE_TABLE(pci, nforce2_ids);
>  
>  
> -static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
> +static int __devinit nforce2_probe_smb(struct pci_dev *dev, int bar,
>  	int alt_reg, struct nforce2_smbus *smbus, const char *name)
>  {
>  	int error;

As mentioned previously, __devinit has been dropped meanwhile, so this
change doesn't apply cleanly. Please rebase your patch on top of kernel
3.8-rc3 (or Wolfram's i2c tree) so that Wolfram can apply it.

All the rest looks very good now, thanks for the good work.

-- 
Jean Delvare

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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2013-01-10  8:32 ` Jean Delvare
@ 2013-01-10  8:52   ` Laurent Navet
  2013-01-10  9:21     ` Jean Delvare
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Navet @ 2013-01-10  8:52 UTC (permalink / raw)
  To: Jean Delvare; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

Hi Jean,

>
> Unfortunately your patch also add one new checkpatch.pl warning:
>
> WARNING: line over 80 characters
> #245: FILE: drivers/i2c/busses/i2c-nforce2.c:272:
> +		data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA + 1) << 8);
>
> Please fix.
>
> As mentioned previously, __devinit has been dropped meanwhile, so this
> change doesn't apply cleanly. Please rebase your patch on top of kernel
> 3.8-rc3 (or Wolfram's i2c tree) so that Wolfram can apply it.
>
> All the rest looks very good now, thanks for the good work.

I've worked and tested against git.pengutronix.de wsa/linux.git
( http://git.pengutronix.de/?p=wsa/linux.git;a=summary )
Isnt' it the right one ?


-- 
Laurent.

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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2013-01-10  8:52   ` Laurent Navet
@ 2013-01-10  9:21     ` Jean Delvare
  2013-01-10  9:40       ` Wolfram Sang
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Delvare @ 2013-01-10  9:21 UTC (permalink / raw)
  To: Laurent Navet; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

On Thu, 10 Jan 2013 09:52:36 +0100, Laurent Navet wrote:
> Hi Jean,
> 
> >
> > Unfortunately your patch also add one new checkpatch.pl warning:
> >
> > WARNING: line over 80 characters
> > #245: FILE: drivers/i2c/busses/i2c-nforce2.c:272:
> > +		data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA + 1) << 8);
> >
> > Please fix.
> >
> > As mentioned previously, __devinit has been dropped meanwhile, so this
> > change doesn't apply cleanly. Please rebase your patch on top of kernel
> > 3.8-rc3 (or Wolfram's i2c tree) so that Wolfram can apply it.
> >
> > All the rest looks very good now, thanks for the good work.
> 
> I've worked and tested against git.pengutronix.de wsa/linux.git
> ( http://git.pengutronix.de/?p=wsa/linux.git;a=summary )
> Isnt' it the right one ?

Only if you use branch i2c-embedded/for-next of that repository.
Otherwise you're lacking the patch which removed the __dev* markers.

Wolfram, it would be great if you could update your tree to avoid that
kind of issue.

-- 
Jean Delvare

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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2013-01-10  9:21     ` Jean Delvare
@ 2013-01-10  9:40       ` Wolfram Sang
  0 siblings, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2013-01-10  9:40 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Laurent Navet, ben-linux, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

> Wolfram, it would be great if you could update your tree to avoid that
> kind of issue.

Done now. Sorry for the inconvenience.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* [PATCH] drivers: i2c-nforce2: fix coding style issues
@ 2013-01-10 14:07 Laurent Navet
  2013-01-10 16:34 ` Jean Delvare
  2013-01-24  7:27 ` Wolfram Sang
  0 siblings, 2 replies; 11+ messages in thread
From: Laurent Navet @ 2013-01-10 14:07 UTC (permalink / raw)
  To: w.sang; +Cc: khali, ben-linux, linux-i2c, linux-kernel, Laurent Navet

avoid these checkpatch.pl issues :
- ERROR: "foo * bar" should be "foo *bar"
- ERROR: switch and case should be at the same indent
- ERROR: "(foo*)" should be "(foo *)"
- ERROR: do not use assignment in if condition
- ERROR: space required before the open parenthesis '('
- WARNING: suspect code indent for conditional statements
- WARNING: quoted string split across lines
- WARNING: space prohibited between function name and open parenthesis '('
- WARNING: line over 80 characters
also add spaces around some "+", "=", "*"

Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
---
 drivers/i2c/busses/i2c-nforce2.c |  152 +++++++++++++++++++-------------------
 1 file changed, 76 insertions(+), 76 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index adac854..ac88f40 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -60,7 +60,7 @@
 #include <linux/io.h>
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>");
+MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
 MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
 
 
@@ -188,9 +188,9 @@ static int nforce2_check_status(struct i2c_adapter *adap)
 }
 
 /* Return negative errno on error */
-static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
+static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
 		unsigned short flags, char read_write,
-		u8 command, int size, union i2c_smbus_data * data)
+		u8 command, int size, union i2c_smbus_data *data)
 {
 	struct nforce2_smbus *smbus = adap->algo_data;
 	unsigned char protocol, pec;
@@ -202,56 +202,54 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 	pec = (flags & I2C_CLIENT_PEC) ? NVIDIA_SMB_PRTCL_PEC : 0;
 
 	switch (size) {
+	case I2C_SMBUS_QUICK:
+		protocol |= NVIDIA_SMB_PRTCL_QUICK;
+		read_write = I2C_SMBUS_WRITE;
+		break;
 
-		case I2C_SMBUS_QUICK:
-			protocol |= NVIDIA_SMB_PRTCL_QUICK;
-			read_write = I2C_SMBUS_WRITE;
-			break;
-
-		case I2C_SMBUS_BYTE:
-			if (read_write == I2C_SMBUS_WRITE)
-				outb_p(command, NVIDIA_SMB_CMD);
-			protocol |= NVIDIA_SMB_PRTCL_BYTE;
-			break;
-
-		case I2C_SMBUS_BYTE_DATA:
-			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE)
-				outb_p(data->byte, NVIDIA_SMB_DATA);
-			protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
-			break;
-
-		case I2C_SMBUS_WORD_DATA:
+	case I2C_SMBUS_BYTE:
+		if (read_write == I2C_SMBUS_WRITE)
 			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE) {
-				 outb_p(data->word, NVIDIA_SMB_DATA);
-				 outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);
-			}
-			protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
-			break;
-
-		case I2C_SMBUS_BLOCK_DATA:
-			outb_p(command, NVIDIA_SMB_CMD);
-			if (read_write == I2C_SMBUS_WRITE) {
-				len = data->block[0];
-				if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
-					dev_err(&adap->dev,
-						"Transaction failed "
-						"(requested block size: %d)\n",
-						len);
-					return -EINVAL;
-				}
-				outb_p(len, NVIDIA_SMB_BCNT);
-				for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
-					outb_p(data->block[i + 1],
-					       NVIDIA_SMB_DATA+i);
+		protocol |= NVIDIA_SMB_PRTCL_BYTE;
+		break;
+
+	case I2C_SMBUS_BYTE_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE)
+			outb_p(data->byte, NVIDIA_SMB_DATA);
+		protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE) {
+			outb_p(data->word, NVIDIA_SMB_DATA);
+			outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1);
+		}
+		protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
+		break;
+
+	case I2C_SMBUS_BLOCK_DATA:
+		outb_p(command, NVIDIA_SMB_CMD);
+		if (read_write == I2C_SMBUS_WRITE) {
+			len = data->block[0];
+			if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
+				dev_err(&adap->dev,
+					"Transaction failed (requested block size: %d)\n",
+					len);
+				return -EINVAL;
 			}
-			protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
-			break;
+			outb_p(len, NVIDIA_SMB_BCNT);
+			for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
+				outb_p(data->block[i + 1],
+				       NVIDIA_SMB_DATA + i);
+		}
+		protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
+		break;
 
-		default:
-			dev_err(&adap->dev, "Unsupported transaction %d\n", size);
-			return -EOPNOTSUPP;
+	default:
+		dev_err(&adap->dev, "Unsupported transaction %d\n", size);
+		return -EOPNOTSUPP;
 	}
 
 	outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
@@ -265,28 +263,28 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
 		return 0;
 
 	switch (size) {
-
-		case I2C_SMBUS_BYTE:
-		case I2C_SMBUS_BYTE_DATA:
-			data->byte = inb_p(NVIDIA_SMB_DATA);
-			break;
-
-		case I2C_SMBUS_WORD_DATA:
-			data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8);
-			break;
-
-		case I2C_SMBUS_BLOCK_DATA:
-			len = inb_p(NVIDIA_SMB_BCNT);
-			if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
-				dev_err(&adap->dev, "Transaction failed "
-					"(received block size: 0x%02x)\n",
-					len);
-				return -EPROTO;
-			}
-			for (i = 0; i < len; i++)
-				data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
-			data->block[0] = len;
-			break;
+	case I2C_SMBUS_BYTE:
+	case I2C_SMBUS_BYTE_DATA:
+		data->byte = inb_p(NVIDIA_SMB_DATA);
+		break;
+
+	case I2C_SMBUS_WORD_DATA:
+		data->word = inb_p(NVIDIA_SMB_DATA) |
+			     (inb_p(NVIDIA_SMB_DATA + 1) << 8);
+		break;
+
+	case I2C_SMBUS_BLOCK_DATA:
+		len = inb_p(NVIDIA_SMB_BCNT);
+		if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
+			dev_err(&adap->dev,
+				"Transaction failed (received block size: 0x%02x)\n",
+				len);
+			return -EPROTO;
+		}
+		for (i = 0; i < len; i++)
+			data->block[i + 1] = inb_p(NVIDIA_SMB_DATA + i);
+		data->block[0] = len;
+		break;
 	}
 
 	return 0;
@@ -299,7 +297,7 @@ static u32 nforce2_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_PEC |
-	       (((struct nforce2_smbus*)adapter->algo_data)->blockops ?
+	       (((struct nforce2_smbus *)adapter->algo_data)->blockops ?
 		I2C_FUNC_SMBUS_BLOCK_DATA : 0);
 }
 
@@ -327,7 +325,7 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
 	{ 0 }
 };
 
-MODULE_DEVICE_TABLE (pci, nforce2_ids);
+MODULE_DEVICE_TABLE(pci, nforce2_ids);
 
 
 static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
@@ -377,7 +375,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
 		release_region(smbus->base, smbus->size);
 		return error;
 	}
-	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base);
+	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n",
+		smbus->base);
 	return 0;
 }
 
@@ -388,11 +387,12 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	int res1, res2;
 
 	/* we support 2 SMBus adapters */
-	if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL)))
+	smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
+	if (!smbuses)
 		return -ENOMEM;
 	pci_set_drvdata(dev, smbuses);
 
-	switch(dev->device) {
+	switch (dev->device) {
 	case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS:
 	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS:
 	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:
-- 
1.7.10.4


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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2013-01-10 14:07 Laurent Navet
@ 2013-01-10 16:34 ` Jean Delvare
  2013-01-24  7:27 ` Wolfram Sang
  1 sibling, 0 replies; 11+ messages in thread
From: Jean Delvare @ 2013-01-10 16:34 UTC (permalink / raw)
  To: Laurent Navet; +Cc: w.sang, ben-linux, linux-i2c, linux-kernel

On Thu, 10 Jan 2013 15:07:42 +0100, Laurent Navet wrote:
> avoid these checkpatch.pl issues :
> - ERROR: "foo * bar" should be "foo *bar"
> - ERROR: switch and case should be at the same indent
> - ERROR: "(foo*)" should be "(foo *)"
> - ERROR: do not use assignment in if condition
> - ERROR: space required before the open parenthesis '('
> - WARNING: suspect code indent for conditional statements
> - WARNING: quoted string split across lines
> - WARNING: space prohibited between function name and open parenthesis '('
> - WARNING: line over 80 characters
> also add spaces around some "+", "=", "*"
> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>
> ---
>  drivers/i2c/busses/i2c-nforce2.c |  152 +++++++++++++++++++-------------------
>  1 file changed, 76 insertions(+), 76 deletions(-)

Very nice, thanks for the good work.

Reviewed-by: Jean Delvare <khali@linux-fr.org>

> 
> diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
> index adac854..ac88f40 100644
> --- a/drivers/i2c/busses/i2c-nforce2.c
> +++ b/drivers/i2c/busses/i2c-nforce2.c
> @@ -60,7 +60,7 @@
>  #include <linux/io.h>
>  
>  MODULE_LICENSE("GPL");
> -MODULE_AUTHOR ("Hans-Frieder Vogt <hfvogt@gmx.net>");
> +MODULE_AUTHOR("Hans-Frieder Vogt <hfvogt@gmx.net>");
>  MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
>  
>  
> @@ -188,9 +188,9 @@ static int nforce2_check_status(struct i2c_adapter *adap)
>  }
>  
>  /* Return negative errno on error */
> -static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
> +static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
>  		unsigned short flags, char read_write,
> -		u8 command, int size, union i2c_smbus_data * data)
> +		u8 command, int size, union i2c_smbus_data *data)
>  {
>  	struct nforce2_smbus *smbus = adap->algo_data;
>  	unsigned char protocol, pec;
> @@ -202,56 +202,54 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
>  	pec = (flags & I2C_CLIENT_PEC) ? NVIDIA_SMB_PRTCL_PEC : 0;
>  
>  	switch (size) {
> +	case I2C_SMBUS_QUICK:
> +		protocol |= NVIDIA_SMB_PRTCL_QUICK;
> +		read_write = I2C_SMBUS_WRITE;
> +		break;
>  
> -		case I2C_SMBUS_QUICK:
> -			protocol |= NVIDIA_SMB_PRTCL_QUICK;
> -			read_write = I2C_SMBUS_WRITE;
> -			break;
> -
> -		case I2C_SMBUS_BYTE:
> -			if (read_write == I2C_SMBUS_WRITE)
> -				outb_p(command, NVIDIA_SMB_CMD);
> -			protocol |= NVIDIA_SMB_PRTCL_BYTE;
> -			break;
> -
> -		case I2C_SMBUS_BYTE_DATA:
> -			outb_p(command, NVIDIA_SMB_CMD);
> -			if (read_write == I2C_SMBUS_WRITE)
> -				outb_p(data->byte, NVIDIA_SMB_DATA);
> -			protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
> -			break;
> -
> -		case I2C_SMBUS_WORD_DATA:
> +	case I2C_SMBUS_BYTE:
> +		if (read_write == I2C_SMBUS_WRITE)
>  			outb_p(command, NVIDIA_SMB_CMD);
> -			if (read_write == I2C_SMBUS_WRITE) {
> -				 outb_p(data->word, NVIDIA_SMB_DATA);
> -				 outb_p(data->word >> 8, NVIDIA_SMB_DATA+1);
> -			}
> -			protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
> -			break;
> -
> -		case I2C_SMBUS_BLOCK_DATA:
> -			outb_p(command, NVIDIA_SMB_CMD);
> -			if (read_write == I2C_SMBUS_WRITE) {
> -				len = data->block[0];
> -				if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> -					dev_err(&adap->dev,
> -						"Transaction failed "
> -						"(requested block size: %d)\n",
> -						len);
> -					return -EINVAL;
> -				}
> -				outb_p(len, NVIDIA_SMB_BCNT);
> -				for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
> -					outb_p(data->block[i + 1],
> -					       NVIDIA_SMB_DATA+i);
> +		protocol |= NVIDIA_SMB_PRTCL_BYTE;
> +		break;
> +
> +	case I2C_SMBUS_BYTE_DATA:
> +		outb_p(command, NVIDIA_SMB_CMD);
> +		if (read_write == I2C_SMBUS_WRITE)
> +			outb_p(data->byte, NVIDIA_SMB_DATA);
> +		protocol |= NVIDIA_SMB_PRTCL_BYTE_DATA;
> +		break;
> +
> +	case I2C_SMBUS_WORD_DATA:
> +		outb_p(command, NVIDIA_SMB_CMD);
> +		if (read_write == I2C_SMBUS_WRITE) {
> +			outb_p(data->word, NVIDIA_SMB_DATA);
> +			outb_p(data->word >> 8, NVIDIA_SMB_DATA + 1);
> +		}
> +		protocol |= NVIDIA_SMB_PRTCL_WORD_DATA | pec;
> +		break;
> +
> +	case I2C_SMBUS_BLOCK_DATA:
> +		outb_p(command, NVIDIA_SMB_CMD);
> +		if (read_write == I2C_SMBUS_WRITE) {
> +			len = data->block[0];
> +			if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> +				dev_err(&adap->dev,
> +					"Transaction failed (requested block size: %d)\n",
> +					len);
> +				return -EINVAL;
>  			}
> -			protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
> -			break;
> +			outb_p(len, NVIDIA_SMB_BCNT);
> +			for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
> +				outb_p(data->block[i + 1],
> +				       NVIDIA_SMB_DATA + i);
> +		}
> +		protocol |= NVIDIA_SMB_PRTCL_BLOCK_DATA | pec;
> +		break;
>  
> -		default:
> -			dev_err(&adap->dev, "Unsupported transaction %d\n", size);
> -			return -EOPNOTSUPP;
> +	default:
> +		dev_err(&adap->dev, "Unsupported transaction %d\n", size);
> +		return -EOPNOTSUPP;
>  	}
>  
>  	outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
> @@ -265,28 +263,28 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
>  		return 0;
>  
>  	switch (size) {
> -
> -		case I2C_SMBUS_BYTE:
> -		case I2C_SMBUS_BYTE_DATA:
> -			data->byte = inb_p(NVIDIA_SMB_DATA);
> -			break;
> -
> -		case I2C_SMBUS_WORD_DATA:
> -			data->word = inb_p(NVIDIA_SMB_DATA) | (inb_p(NVIDIA_SMB_DATA+1) << 8);
> -			break;
> -
> -		case I2C_SMBUS_BLOCK_DATA:
> -			len = inb_p(NVIDIA_SMB_BCNT);
> -			if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> -				dev_err(&adap->dev, "Transaction failed "
> -					"(received block size: 0x%02x)\n",
> -					len);
> -				return -EPROTO;
> -			}
> -			for (i = 0; i < len; i++)
> -				data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
> -			data->block[0] = len;
> -			break;
> +	case I2C_SMBUS_BYTE:
> +	case I2C_SMBUS_BYTE_DATA:
> +		data->byte = inb_p(NVIDIA_SMB_DATA);
> +		break;
> +
> +	case I2C_SMBUS_WORD_DATA:
> +		data->word = inb_p(NVIDIA_SMB_DATA) |
> +			     (inb_p(NVIDIA_SMB_DATA + 1) << 8);
> +		break;
> +
> +	case I2C_SMBUS_BLOCK_DATA:
> +		len = inb_p(NVIDIA_SMB_BCNT);
> +		if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
> +			dev_err(&adap->dev,
> +				"Transaction failed (received block size: 0x%02x)\n",
> +				len);
> +			return -EPROTO;
> +		}
> +		for (i = 0; i < len; i++)
> +			data->block[i + 1] = inb_p(NVIDIA_SMB_DATA + i);
> +		data->block[0] = len;
> +		break;
>  	}
>  
>  	return 0;
> @@ -299,7 +297,7 @@ static u32 nforce2_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_PEC |
> -	       (((struct nforce2_smbus*)adapter->algo_data)->blockops ?
> +	       (((struct nforce2_smbus *)adapter->algo_data)->blockops ?
>  		I2C_FUNC_SMBUS_BLOCK_DATA : 0);
>  }
>  
> @@ -327,7 +325,7 @@ static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
>  	{ 0 }
>  };
>  
> -MODULE_DEVICE_TABLE (pci, nforce2_ids);
> +MODULE_DEVICE_TABLE(pci, nforce2_ids);
>  
>  
>  static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
> @@ -377,7 +375,8 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,
>  		release_region(smbus->base, smbus->size);
>  		return error;
>  	}
> -	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base);
> +	dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n",
> +		smbus->base);
>  	return 0;
>  }
>  
> @@ -388,11 +387,12 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	int res1, res2;
>  
>  	/* we support 2 SMBus adapters */
> -	if (!(smbuses = kzalloc(2*sizeof(struct nforce2_smbus), GFP_KERNEL)))
> +	smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
> +	if (!smbuses)
>  		return -ENOMEM;
>  	pci_set_drvdata(dev, smbuses);
>  
> -	switch(dev->device) {
> +	switch (dev->device) {
>  	case PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS:
>  	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SMBUS:
>  	case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:


-- 
Jean Delvare

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

* Re: [PATCH] drivers: i2c-nforce2: fix coding style issues
  2013-01-10 14:07 Laurent Navet
  2013-01-10 16:34 ` Jean Delvare
@ 2013-01-24  7:27 ` Wolfram Sang
  1 sibling, 0 replies; 11+ messages in thread
From: Wolfram Sang @ 2013-01-24  7:27 UTC (permalink / raw)
  To: Laurent Navet; +Cc: khali, ben-linux, linux-i2c, linux-kernel

On Thu, Jan 10, 2013 at 03:07:42PM +0100, Laurent Navet wrote:
> avoid these checkpatch.pl issues :
> - ERROR: "foo * bar" should be "foo *bar"
> - ERROR: switch and case should be at the same indent
> - ERROR: "(foo*)" should be "(foo *)"
> - ERROR: do not use assignment in if condition
> - ERROR: space required before the open parenthesis '('
> - WARNING: suspect code indent for conditional statements
> - WARNING: quoted string split across lines
> - WARNING: space prohibited between function name and open parenthesis '('
> - WARNING: line over 80 characters
> also add spaces around some "+", "=", "*"
> 
> Signed-off-by: Laurent Navet <laurent.navet@gmail.com>

Thanks, applied to for-next.


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

end of thread, other threads:[~2013-01-24  7:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 21:06 [PATCH] drivers: i2c-nforce2: fix coding style issues Laurent Navet
2012-12-21 10:04 ` Jean Delvare
2012-12-21 14:15   ` Laurent Navet
  -- strict thread matches above, loose matches on Subject: below --
2013-01-09 20:50 Laurent Navet
2013-01-10  8:32 ` Jean Delvare
2013-01-10  8:52   ` Laurent Navet
2013-01-10  9:21     ` Jean Delvare
2013-01-10  9:40       ` Wolfram Sang
2013-01-10 14:07 Laurent Navet
2013-01-10 16:34 ` Jean Delvare
2013-01-24  7:27 ` Wolfram Sang

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