mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leon Pelzmann <brunonick1801@gmail.com>
To: gregkh@linuxfoundation.org
Cc: sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com,
	linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	Leon Pelzmann <brunonick1801@gmail.com>
Subject: [PATCH] staging: sm750fb: remove ineffective sw_i2c_wait() busy loop
Date: Sun, 15 Nov 2026 22:54:27 +0100	[thread overview]
Message-ID: <20261115215427.112315-1-brunonick1801@gmail.com> (raw)

sw_i2c_wait() is meant to insert a delay between the bit-banged I2C
operations, but it only consists of a loop that computes a value into
a local variable which is never read. The loop has no side effects, so
the compiler removes it entirely and the function compiles to nothing.
With W=1 this also triggers:

  ddk750_swi2c.c:95:16: error: variable 'tmp' set but not used
  [-Werror=unused-but-set-variable=]

Remove the function and all of its call sites. The I2C timing is not
changed by this: the object code of ddk750_swi2c.o (x86_64, gcc,
allmodconfig) is identical before and after this change.

The W=1 warning was found by building the driver, and the change was
prepared with the help of an AI coding assistant (Claude); it was
verified by comparing the objdump output before and after the change.

Signed-off-by: Leon Pelzmann <brunonick1801@gmail.com>
---
 drivers/staging/sm750fb/ddk750_swi2c.c | 34 --------------------------
 1 file changed, 34 deletions(-)

diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c
index e63f3b00ec..e298bf3128 100644
--- a/drivers/staging/sm750fb/ddk750_swi2c.c
+++ b/drivers/staging/sm750fb/ddk750_swi2c.c
@@ -75,31 +75,6 @@ static unsigned long sw_i2c_data_gpio_mux_reg = GPIO_MUX;
 static unsigned long sw_i2c_data_gpio_data_reg = GPIO_DATA;
 static unsigned long sw_i2c_data_gpio_data_dir_reg = GPIO_DATA_DIRECTION;
 
-/*
- *  This function puts a delay between command
- */
-static void sw_i2c_wait(void)
-{
-	/* find a bug:
-	 * peekIO method works well before suspend/resume
-	 * but after suspend, peekIO(0x3ce,0x61) & 0x10
-	 * always be non-zero,which makes the while loop
-	 * never finish.
-	 * use non-ultimate for loop below is safe
-	 */
-
-    /* Change wait algorithm to use PCI bus clock,
-     * it's more reliable than counter loop ..
-     * write 0x61 to 0x3ce and read from 0x3cf
-     */
-	int i, tmp;
-
-	for (i = 0; i < 600; i++) {
-		tmp = i;
-		tmp += i;
-	}
-}
-
 /*
  *  This function set/reset the SCL GPIO pin
  *
@@ -257,11 +232,8 @@ static long sw_i2c_write_byte(unsigned char data)
 		else
 			sw_i2c_sda(0);
 
-		sw_i2c_wait();
-
 		/* Toggle clk line to one */
 		sw_i2c_scl(1);
-		sw_i2c_wait();
 
 		/* Shift byte to be sent */
 		value = value << 1;
@@ -272,9 +244,7 @@ static long sw_i2c_write_byte(unsigned char data)
 	sw_i2c_sda(1);
 
 	/* Set the SCL High for ack */
-	sw_i2c_wait();
 	sw_i2c_scl(1);
-	sw_i2c_wait();
 
 	/* Read SDA, until SDA==0 */
 	for (i = 0; i < 0xff; i++) {
@@ -282,9 +252,7 @@ static long sw_i2c_write_byte(unsigned char data)
 			break;
 
 		sw_i2c_scl(0);
-		sw_i2c_wait();
 		sw_i2c_scl(1);
-		sw_i2c_wait();
 	}
 
 	/* Set the SCL Low and SDA High */
@@ -316,11 +284,9 @@ static unsigned char sw_i2c_read_byte(unsigned char ack)
 		/* Set the SCL to Low and SDA to High (Input) */
 		sw_i2c_scl(0);
 		sw_i2c_sda(1);
-		sw_i2c_wait();
 
 		/* Set the SCL High */
 		sw_i2c_scl(1);
-		sw_i2c_wait();
 
 		/* Read data bits from SDA */
 		data |= (sw_i2c_read_sda() << i);
-- 
2.56.0


                 reply	other threads:[~2026-11-15 21:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261115215427.112315-1-brunonick1801@gmail.com \
    --to=brunonick1801@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=sudipm.mukherjee@gmail.com \
    --cc=teddy.wang@siliconmotion.com \
    /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

all inboxes | Powered by JetHome®