From: Dan Carpenter <error27@gmail.com>
To: Leon Pelzmann <brunonick1801@gmail.com>, sudipm.mukherjee@gmail.com
Cc: gregkh@linuxfoundation.org, teddy.wang@siliconmotion.com,
linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: sm750fb: remove ineffective sw_i2c_wait() busy loop
Date: Mon, 16 Nov 2026 08:24:07 +0300 [thread overview]
Message-ID: <avqTdwA-2E_-lKL9@stanley.mountain> (raw)
In-Reply-To: <20261115215427.112315-1-brunonick1801@gmail.com>
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 <brunonick1801@gmail.com>
> ---
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
prev parent reply other threads:[~2026-11-16 5:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 21:54 [PATCH] staging: sm750fb: remove ineffective sw_i2c_wait() busy loop Leon Pelzmann
2026-11-16 5:24 ` Dan Carpenter [this message]
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=avqTdwA-2E_-lKL9@stanley.mountain \
--to=error27@gmail.com \
--cc=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