linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: sis96x: Refactor for readability and style improvements
@ 2025-07-28 13:14 Darshan R.
  2025-07-29  9:38 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Darshan R. @ 2025-07-28 13:14 UTC (permalink / raw)
  To: jdelvare, andi.shyti; +Cc: linux-i2c, linux-kernel, Darshan R.

This commit introduces several minor, non-functional code quality
improvements to the SiS96x I2C bus driver. The primary goal is to
enhance code clarity and align better with standard kernel coding
practices.

Key changes include:
*   **Separating assignments from conditionals:** Break out `read` operations
    (e.g., `sis96x_read()`) from `if` statement conditions, making the
    control flow more explicit and easier to follow. This avoids
    common pitfalls of assignment within conditional expressions.
*   **Whitespace and alignment fixes:** Adjust parameter alignment in
    function definitions and remove extraneous trailing whitespace,
    improving visual consistency and adherence to kernel coding style.

These changes are purely refactoring-oriented and have no functional
impact on the driver's operation.

Signed-off-by: Darshan R. <rathod.darshan.0896@gmail.com>
---
 drivers/i2c/busses/i2c-sis96x.c | 51 ++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 23 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 77529dda6fcd..1bab881b2610 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -11,7 +11,7 @@
 
     This module relies on quirk_sis_96x_smbus (drivers/pci/quirks.c)
     for just about every machine for which users have reported.
-    If this module isn't detecting your 96x south bridge, have a 
+    If this module isn't detecting your 96x south bridge, have a
     look there.
 
     We assume there can only be one SiS96x with one SMBus interface.
@@ -65,12 +65,12 @@ static u16 sis96x_smbus_base;
 
 static inline u8 sis96x_read(u8 reg)
 {
-	return inb(sis96x_smbus_base + reg) ;
+	return inb(sis96x_smbus_base + reg);
 }
 
 static inline void sis96x_write(u8 reg, u8 data)
 {
-	outb(data, sis96x_smbus_base + reg) ;
+	outb(data, sis96x_smbus_base + reg);
 }
 
 /* Execute a SMBus transaction.
@@ -85,22 +85,24 @@ static int sis96x_transaction(int size)
 	dev_dbg(&sis96x_adapter.dev, "SMBus transaction %d\n", size);
 
 	/* Make sure the SMBus host is ready to start transmitting */
-	if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
+	temp = sis96x_read(SMB_CNT);
 
-		dev_dbg(&sis96x_adapter.dev, "SMBus busy (0x%02x). "
-			"Resetting...\n", temp);
+	if ((temp & 0x03) != 0x00) {
+		dev_dbg(&sis96x_adapter.dev, "SMBus busy (0x%02x). Resetting...\n", temp);
 
-		/* kill the transaction */
-		sis96x_write(SMB_HOST_CNT, 0x20);
+	/* kill the transaction */
+	sis96x_write(SMB_HOST_CNT, 0x20);
 
-		/* check it again */
-		if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
-			dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp);
-			return -EBUSY;
-		} else {
-			dev_dbg(&sis96x_adapter.dev, "Successful\n");
-		}
+	/* check it again */
+	temp = sis96x_read(SMB_CNT);
+
+	if ((temp & 0x03) != 0x00) {
+		dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp);
+		return -EBUSY;
+	} else {
+		dev_dbg(&sis96x_adapter.dev, "Successful\n");
 	}
+}
 
 	/* Turn off timeout interrupts, set fast host clock */
 	sis96x_write(SMB_CNT, 0x20);
@@ -138,7 +140,9 @@ static int sis96x_transaction(int size)
 
 	/* Finish up by resetting the bus */
 	sis96x_write(SMB_STS, temp);
-	if ((temp = sis96x_read(SMB_STS))) {
+
+	temp = sis96x_read(SMB_STS);
+	if (temp) {
 		dev_dbg(&sis96x_adapter.dev, "Failed reset at "
 			"end of transaction! (0x%02x)\n", temp);
 	}
@@ -147,9 +151,9 @@ static int sis96x_transaction(int size)
 }
 
 /* Return negative errno on error. */
-static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
+static s32 sis96x_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)
 {
 	int status;
 
@@ -182,7 +186,7 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
 			sis96x_write(SMB_BYTE, data->word & 0xff);
 			sis96x_write(SMB_BYTE + 1, (data->word & 0xff00) >> 8);
 		}
-		size = (size == I2C_SMBUS_PROC_CALL ? 
+		size = (size == I2C_SMBUS_PROC_CALL ?
 			SIS96x_PROC_CALL : SIS96x_WORD_DATA);
 		break;
 
@@ -196,7 +200,7 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
 		return status;
 
 	if ((size != SIS96x_PROC_CALL) &&
-		((read_write == I2C_SMBUS_WRITE) || (size == SIS96x_QUICK)))
+	   ((read_write == I2C_SMBUS_WRITE) || (size == SIS96x_QUICK)))
 		return 0;
 
 	switch (size) {
@@ -240,7 +244,7 @@ static const struct pci_device_id sis96x_ids[] = {
 MODULE_DEVICE_TABLE (pci, sis96x_ids);
 
 static int sis96x_probe(struct pci_dev *dev,
-				const struct pci_device_id *id)
+			const struct pci_device_id *id)
 {
 	u16 ww = 0;
 	int retval;
@@ -263,7 +267,7 @@ static int sis96x_probe(struct pci_dev *dev,
 		return -EINVAL;
 	}
 	dev_info(&dev->dev, "SiS96x SMBus base address: 0x%04x\n",
-			sis96x_smbus_base);
+		 sis96x_smbus_base);
 
 	retval = acpi_check_resource_conflict(&dev->resource[SIS96x_BAR]);
 	if (retval)
@@ -286,7 +290,8 @@ static int sis96x_probe(struct pci_dev *dev,
 	snprintf(sis96x_adapter.name, sizeof(sis96x_adapter.name),
 		"SiS96x SMBus adapter at 0x%04x", sis96x_smbus_base);
 
-	if ((retval = i2c_add_adapter(&sis96x_adapter))) {
+	retval = i2c_add_adapter(&sis96x_adapter);
+	if (retval) {
 		dev_err(&dev->dev, "Couldn't register adapter!\n");
 		release_region(sis96x_smbus_base, SMB_IOSIZE);
 		sis96x_smbus_base = 0;
-- 
2.43.0


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

* Re: [PATCH] i2c: sis96x: Refactor for readability and style improvements
  2025-07-28 13:14 [PATCH] i2c: sis96x: Refactor for readability and style improvements Darshan R.
@ 2025-07-29  9:38 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-07-29  9:38 UTC (permalink / raw)
  To: Darshan R., jdelvare, andi.shyti
  Cc: oe-kbuild-all, linux-i2c, linux-kernel, Darshan R.

Hi Darshan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on andi-shyti/i2c/i2c-host]
[also build test WARNING on linus/master v6.16 next-20250729]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Darshan-R/i2c-sis96x-Refactor-for-readability-and-style-improvements/20250728-213139
base:   https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link:    https://lore.kernel.org/r/20250728131418.9424-1-rathod.darshan.0896%40gmail.com
patch subject: [PATCH] i2c: sis96x: Refactor for readability and style improvements
config: i386-randconfig-r071-20250729 (https://download.01.org/0day-ci/archive/20250729/202507291702.7DUZcvW4-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507291702.7DUZcvW4-lkp@intel.com/

smatch warnings:
drivers/i2c/busses/i2c-sis96x.c:94 sis96x_transaction() warn: inconsistent indenting

vim +94 drivers/i2c/busses/i2c-sis96x.c

^1da177e4c3f41 Linus Torvalds 2005-04-16   75  
^1da177e4c3f41 Linus Torvalds 2005-04-16   76  /* Execute a SMBus transaction.
^1da177e4c3f41 Linus Torvalds 2005-04-16   77     int size is from SIS96x_QUICK to SIS96x_BLOCK_DATA
^1da177e4c3f41 Linus Torvalds 2005-04-16   78   */
^1da177e4c3f41 Linus Torvalds 2005-04-16   79  static int sis96x_transaction(int size)
^1da177e4c3f41 Linus Torvalds 2005-04-16   80  {
^1da177e4c3f41 Linus Torvalds 2005-04-16   81  	int temp;
^1da177e4c3f41 Linus Torvalds 2005-04-16   82  	int result = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16   83  	int timeout = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16   84  
^1da177e4c3f41 Linus Torvalds 2005-04-16   85  	dev_dbg(&sis96x_adapter.dev, "SMBus transaction %d\n", size);
^1da177e4c3f41 Linus Torvalds 2005-04-16   86  
^1da177e4c3f41 Linus Torvalds 2005-04-16   87  	/* Make sure the SMBus host is ready to start transmitting */
1f3ce966edb415 Darshan R      2025-07-28   88  	temp = sis96x_read(SMB_CNT);
^1da177e4c3f41 Linus Torvalds 2005-04-16   89  
1f3ce966edb415 Darshan R      2025-07-28   90  	if ((temp & 0x03) != 0x00) {
1f3ce966edb415 Darshan R      2025-07-28   91  		dev_dbg(&sis96x_adapter.dev, "SMBus busy (0x%02x). Resetting...\n", temp);
^1da177e4c3f41 Linus Torvalds 2005-04-16   92  
^1da177e4c3f41 Linus Torvalds 2005-04-16   93  	/* kill the transaction */
^1da177e4c3f41 Linus Torvalds 2005-04-16  @94  	sis96x_write(SMB_HOST_CNT, 0x20);
^1da177e4c3f41 Linus Torvalds 2005-04-16   95  
^1da177e4c3f41 Linus Torvalds 2005-04-16   96  	/* check it again */
1f3ce966edb415 Darshan R      2025-07-28   97  	temp = sis96x_read(SMB_CNT);
1f3ce966edb415 Darshan R      2025-07-28   98  
1f3ce966edb415 Darshan R      2025-07-28   99  	if ((temp & 0x03) != 0x00) {
^1da177e4c3f41 Linus Torvalds 2005-04-16  100  		dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp);
97140342e69d47 David Brownell 2008-07-14  101  		return -EBUSY;
^1da177e4c3f41 Linus Torvalds 2005-04-16  102  	} else {
^1da177e4c3f41 Linus Torvalds 2005-04-16  103  		dev_dbg(&sis96x_adapter.dev, "Successful\n");
^1da177e4c3f41 Linus Torvalds 2005-04-16  104  	}
^1da177e4c3f41 Linus Torvalds 2005-04-16  105  }
^1da177e4c3f41 Linus Torvalds 2005-04-16  106  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-07-29  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-28 13:14 [PATCH] i2c: sis96x: Refactor for readability and style improvements Darshan R.
2025-07-29  9:38 ` kernel test robot

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