All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: kpc2000: rename some variables and clean up code
@ 2020-02-05  2:48 Jerry Lin
  2020-02-10 16:48 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Jerry Lin @ 2020-02-05  2:48 UTC (permalink / raw)
  To: gregkh, linux-kernel

Rename some variables to be more understandable and module-related
and remove some redundant code to make it more easy-to-read.

Signed-off-by: Jerry Lin <wahahab11@gmail.com>
---
 drivers/staging/kpc2000/kpc2000_i2c.c | 118 +++++++++++++---------------------
 1 file changed, 44 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c
index 4b8ab4b..ed2f823 100644
--- a/drivers/staging/kpc2000/kpc2000_i2c.c
+++ b/drivers/staging/kpc2000/kpc2000_i2c.c
@@ -16,6 +16,7 @@
  *	Matt Sickler <matt.sickler@daktronics.com>,
  *	Jordon Hofer <jordon.hofer@daktronics.com>
  */
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -27,13 +28,14 @@
 #include <linux/fs.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
+
 #include "kpc.h"
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Matt.Sickler@Daktronics.com");
 
 struct kpc_i2c {
-	unsigned long           smba;
+	unsigned long           io_base;
 	struct i2c_adapter      adapter;
 	unsigned int            features;
 };
@@ -45,16 +47,16 @@ struct kpc_i2c {
 #define REG_SIZE 8
 
 /* I801 SMBus address offsets */
-#define SMBHSTSTS(p)    ((0  * REG_SIZE) + (p)->smba)
-#define SMBHSTCNT(p)    ((2  * REG_SIZE) + (p)->smba)
-#define SMBHSTCMD(p)    ((3  * REG_SIZE) + (p)->smba)
-#define SMBHSTADD(p)    ((4  * REG_SIZE) + (p)->smba)
-#define SMBHSTDAT0(p)   ((5  * REG_SIZE) + (p)->smba)
-#define SMBHSTDAT1(p)   ((6  * REG_SIZE) + (p)->smba)
-#define SMBBLKDAT(p)    ((7  * REG_SIZE) + (p)->smba)
-#define SMBPEC(p)       ((8  * REG_SIZE) + (p)->smba)   /* ICH3 and later */
-#define SMBAUXSTS(p)    ((12 * REG_SIZE) + (p)->smba)   /* ICH4 and later */
-#define SMBAUXCTL(p)    ((13 * REG_SIZE) + (p)->smba)   /* ICH4 and later */
+#define SMBHSTSTS(p)    ((0  * REG_SIZE) + (p)->io_base)
+#define SMBHSTCNT(p)    ((2  * REG_SIZE) + (p)->io_base)
+#define SMBHSTCMD(p)    ((3  * REG_SIZE) + (p)->io_base)
+#define SMBHSTADD(p)    ((4  * REG_SIZE) + (p)->io_base)
+#define SMBHSTDAT0(p)   ((5  * REG_SIZE) + (p)->io_base)
+#define SMBHSTDAT1(p)   ((6  * REG_SIZE) + (p)->io_base)
+#define SMBBLKDAT(p)    ((7  * REG_SIZE) + (p)->io_base)
+#define SMBPEC(p)       ((8  * REG_SIZE) + (p)->io_base)   /* ICH3 and later */
+#define SMBAUXSTS(p)    ((12 * REG_SIZE) + (p)->io_base)   /* ICH4 and later */
+#define SMBAUXCTL(p)    ((13 * REG_SIZE) + (p)->io_base)   /* ICH4 and later */
 
 /* PCI Address Constants */
 #define SMBBAR      4
@@ -433,9 +435,9 @@ static int i801_block_transaction(struct kpc_i2c *priv,
 }
 
 /* Return negative errno on error. */
-static s32 i801_access(struct i2c_adapter *adap, u16 addr,
-		       unsigned short flags, char read_write, u8 command,
-		       int size, union i2c_smbus_data *data)
+static s32 kpc_smbus_xfer(struct i2c_adapter *adap, u16 addr,
+			  unsigned short flags, char read_write, u8 command,
+			  int size, union i2c_smbus_data *data)
 {
 	int hwpec;
 	int block = 0;
@@ -444,19 +446,18 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 
 	hwpec = (priv->features & FEATURE_SMBUS_PEC) &&
 		(flags & I2C_CLIENT_PEC) &&
-		size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA;
+		(size != I2C_SMBUS_QUICK) &&
+		(size != I2C_SMBUS_I2C_BLOCK_DATA);
 
 	switch (size) {
 	case I2C_SMBUS_QUICK:
 		dev_dbg(&priv->adapter.dev, "  [acc] SMBUS_QUICK\n");
 		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
 		       SMBHSTADD(priv));
-
 		xact = I801_QUICK;
 		break;
 	case I2C_SMBUS_BYTE:
 		dev_dbg(&priv->adapter.dev, "  [acc] SMBUS_BYTE\n");
-
 		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
 		       SMBHSTADD(priv));
 		if (read_write == I2C_SMBUS_WRITE)
@@ -467,7 +468,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 		dev_dbg(&priv->adapter.dev, "  [acc] SMBUS_BYTE_DATA\n");
 		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
 		       SMBHSTADD(priv));
-
 		outb_p(command, SMBHSTCMD(priv));
 		if (read_write == I2C_SMBUS_WRITE)
 			outb_p(data->byte, SMBHSTDAT0(priv));
@@ -477,7 +477,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 		dev_dbg(&priv->adapter.dev, "  [acc] SMBUS_WORD_DATA\n");
 		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
 		       SMBHSTADD(priv));
-
 		outb_p(command, SMBHSTCMD(priv));
 		if (read_write == I2C_SMBUS_WRITE) {
 			outb_p(data->word & 0xff, SMBHSTDAT0(priv));
@@ -489,7 +488,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 		dev_dbg(&priv->adapter.dev, "  [acc] SMBUS_BLOCK_DATA\n");
 		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
 		       SMBHSTADD(priv));
-
 		outb_p(command, SMBHSTCMD(priv));
 		block = 1;
 		break;
@@ -517,11 +515,12 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 
 	if (hwpec) { /* enable/disable hardware PEC */
 		dev_dbg(&priv->adapter.dev, "  [acc] hwpec: yes\n");
-		outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv));
+		outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC,
+		       SMBAUXCTL(priv));
 	} else {
 		dev_dbg(&priv->adapter.dev, "  [acc] hwpec: no\n");
-		outb_p(inb_p(SMBAUXCTL(priv)) &
-				(~SMBAUXCTL_CRC), SMBAUXCTL(priv));
+		outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC),
+		       SMBAUXCTL(priv));
 	}
 
 	if (block) {
@@ -572,7 +571,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
 	return 0;
 }
 
-static u32 i801_func(struct i2c_adapter *adapter)
+static u32 kpc_func(struct i2c_adapter *adapter)
 {
 	struct kpc_i2c *priv = i2c_get_adapdata(adapter);
 
@@ -587,54 +586,25 @@ static u32 i801_func(struct i2c_adapter *adapter)
 
 	// http://lxr.free-electrons.com/source/include/uapi/linux/i2c.h#L85
 
-	u32 f =
-		I2C_FUNC_I2C                     | /* 0x00000001(I enabled this
-						    * one)
-						    */
-		!I2C_FUNC_10BIT_ADDR             |		/* 0x00000002 */
-		!I2C_FUNC_PROTOCOL_MANGLING      |		/* 0x00000004 */
-		((priv->features & FEATURE_SMBUS_PEC) ?
-			I2C_FUNC_SMBUS_PEC : 0)  |		/* 0x00000008 */
-		!I2C_FUNC_SMBUS_BLOCK_PROC_CALL  |		/* 0x00008000 */
-		I2C_FUNC_SMBUS_QUICK             |		/* 0x00010000 */
-		!I2C_FUNC_SMBUS_READ_BYTE	 |		/* 0x00020000 */
-		!I2C_FUNC_SMBUS_WRITE_BYTE       |		/* 0x00040000 */
-		!I2C_FUNC_SMBUS_READ_BYTE_DATA   |		/* 0x00080000 */
-		!I2C_FUNC_SMBUS_WRITE_BYTE_DATA  |		/* 0x00100000 */
-		!I2C_FUNC_SMBUS_READ_WORD_DATA   |		/* 0x00200000 */
-		!I2C_FUNC_SMBUS_WRITE_WORD_DATA  |		/* 0x00400000 */
-		!I2C_FUNC_SMBUS_PROC_CALL        |		/* 0x00800000 */
-		!I2C_FUNC_SMBUS_READ_BLOCK_DATA  |		/* 0x01000000 */
-		!I2C_FUNC_SMBUS_WRITE_BLOCK_DATA |		/* 0x02000000 */
-		((priv->features & FEATURE_I2C_BLOCK_READ) ?
-			I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0) |	/* 0x04000000 */
-		I2C_FUNC_SMBUS_WRITE_I2C_BLOCK   |		/* 0x08000000 */
-
-		I2C_FUNC_SMBUS_BYTE              | /* _READ_BYTE  _WRITE_BYTE */
-		I2C_FUNC_SMBUS_BYTE_DATA         | /* _READ_BYTE_DATA
-						    * _WRITE_BYTE_DATA
-						    */
-		I2C_FUNC_SMBUS_WORD_DATA         | /* _READ_WORD_DATA
-						    * _WRITE_WORD_DATA
-						    */
-		I2C_FUNC_SMBUS_BLOCK_DATA        | /* _READ_BLOCK_DATA
-						    * _WRITE_BLOCK_DATA
-						    */
-		!I2C_FUNC_SMBUS_I2C_BLOCK        | /* _READ_I2C_BLOCK
-						    * _WRITE_I2C_BLOCK
-						    */
-		!I2C_FUNC_SMBUS_EMUL;              /* _QUICK  _BYTE
-						    * _BYTE_DATA  _WORD_DATA
-						    * _PROC_CALL
-						    * _WRITE_BLOCK_DATA
-						    * _I2C_BLOCK _PEC
-						    */
+	u32 f = I2C_FUNC_I2C |
+		I2C_FUNC_SMBUS_QUICK |
+		I2C_FUNC_SMBUS_WRITE_I2C_BLOCK |
+		I2C_FUNC_SMBUS_BYTE |
+		I2C_FUNC_SMBUS_BYTE_DATA |
+		I2C_FUNC_SMBUS_WORD_DATA |
+		I2C_FUNC_SMBUS_BLOCK_DATA;
+
+	if (priv->features & FEATURE_SMBUS_PEC)
+		f |= I2C_FUNC_SMBUS_PEC;
+	if (priv->features & FEATURE_I2C_BLOCK_READ)
+		f |= I2C_FUNC_SMBUS_READ_I2C_BLOCK;
+
 	return f;
 }
 
-static const struct i2c_algorithm smbus_algorithm = {
-	.smbus_xfer     = i801_access,
-	.functionality  = i801_func,
+static const struct i2c_algorithm kpc_algorithm = {
+	.smbus_xfer     = kpc_smbus_xfer,
+	.functionality  = kpc_func,
 };
 
 /********************************
@@ -653,16 +623,16 @@ static int kpc_i2c_probe(struct platform_device *pldev)
 	i2c_set_adapdata(&priv->adapter, priv);
 	priv->adapter.owner = THIS_MODULE;
 	priv->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
-	priv->adapter.algo = &smbus_algorithm;
+	priv->adapter.algo = &kpc_algorithm;
 
 	res = platform_get_resource(pldev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENXIO;
 
-	priv->smba = (unsigned long)devm_ioremap_nocache(&pldev->dev,
-							 res->start,
-							 resource_size(res));
-	if (!priv->smba)
+	priv->io_base = (unsigned long)devm_ioremap_nocache(&pldev->dev,
+							    res->start,
+							    resource_size(res));
+	if (!priv->io_base)
 		return -ENOMEM;
 
 	platform_set_drvdata(pldev, priv);
-- 
2.7.4


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

* Re: [PATCH] staging: kpc2000: rename some variables and clean up code
  2020-02-05  2:48 [PATCH] staging: kpc2000: rename some variables and clean up code Jerry Lin
@ 2020-02-10 16:48 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2020-02-10 16:48 UTC (permalink / raw)
  To: Jerry Lin; +Cc: linux-kernel

On Wed, Feb 05, 2020 at 10:48:21AM +0800, Jerry Lin wrote:
> Rename some variables to be more understandable and module-related
> and remove some redundant code to make it more easy-to-read.
> 
> Signed-off-by: Jerry Lin <wahahab11@gmail.com>
> ---
>  drivers/staging/kpc2000/kpc2000_i2c.c | 118 +++++++++++++---------------------
>  1 file changed, 44 insertions(+), 74 deletions(-)


Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2020-02-10 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05  2:48 [PATCH] staging: kpc2000: rename some variables and clean up code Jerry Lin
2020-02-10 16:48 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.