Re: [PATCH] staging: sm750fb: remove ineffective sw_i2c_wait() busy loop

From
Dan Carpenter <hidden>
Date
2026-11-16 05:24:13
Also in
linux-staging, lkml
Reply to
Leon Pelzmann, 2026-11-15
Sudip, Is anyone still using this driver?

On Sun, Nov 15, 2026 at 10:54:27PM +0100, Leon Pelzmann wrote:
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 <redacted>
---
This driver is old and when it was written the loop did add a delay.
It does the silly stuff to hide that the loop is a no-op from the
compiler but then compilers got clever and saw that it still a no-op.

The busy loop was added based on testing and is presumably required.

Your patch doesn't break the driver but it disguises the bug to make it
look as if the driver works.  We don't want that.  We want the bugs to
be obvious.

We have some guesses as to how to fix the driver, but actually we can't
do it without testing so we are in a bind.  We can't move forward
without testing.  To be honest, the most likely way forward is to remove
the driver if no one is using it.

regards,
dan carpenter
Thread (3 messages) 3 messages, 3 authors, last reply 7h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help