Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Triet Hoang" <triet.hoang.dev@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v2] input: touchscreen: Convert to DEFINE_SIMPLE_DEV_PM_OPS()
Date: Fri, 21 Aug 2026 04:19:51 +0000	[thread overview]
Message-ID: <20260821041951.7DE131F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821040905.104590-1-triet.hoang.dev@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The logic in `ad7879_toggle()` is completely inverted, causing the sysfs `disable` attribute to malfunction and desynchronize the hardware state from software tracking.
--

--- Patch [1]: [PATCH v2] input: touchscreen: Convert to DEFINE_SIMPLE_DEV_PM_OPS() ---
commit b2cacedba4aaf53cb97b0b4bbb302d78a3a37daf
Author: Triet Hoang <triet.hoang.dev@gmail.com>

input: touchscreen: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

This commit converts the deprecated SIMPLE_DEV_PM_OPS to
DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr() across several touchscreen
drivers. This allows dropping the __maybe_unused annotations and reduces
kernel size when PM features are disabled.

> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index 31d2a3029d5f6..10f8574f478e2 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c

[ ... ]

> @@ -329,8 +329,7 @@ static int __maybe_unused ad7879_resume(struct device *dev)
>  	return 0;
>  }
>  
> -SIMPLE_DEV_PM_OPS(ad7879_pm_ops, ad7879_suspend, ad7879_resume);
> -EXPORT_SYMBOL(ad7879_pm_ops);
> +EXPORT_SIMPLE_DEV_PM_OPS(ad7879_pm_ops, ad7879_suspend, ad7879_resume);
>  
>  static void ad7879_toggle(struct ad7879 *ts, bool disable)
>  {

[Severity: High]
This is a pre-existing issue, but the logic in this function appears to be
completely inverted.

Looking at the full ad7879_toggle() function in
drivers/input/touchscreen/ad7879.c:

static void ad7879_toggle(struct ad7879 *ts, bool disable)
{
        guard(mutex)(&ts->input->mutex);

        if (!ts->suspended && input_device_enabled(ts->input)) {

                if (disable) {
                        if (ts->disabled)
                                __ad7879_enable(ts);
                } else {
                        if (!ts->disabled)
                                __ad7879_disable(ts);
                }
        }

        ts->disabled = disable;
}

If a user writes 1 to the disable sysfs attribute (disable == true), and the
device is already marked disabled (ts->disabled == true), won't this logic
actually enable the hardware by calling __ad7879_enable(ts)?

Conversely, if the user writes 0 to enable the device (disable == false)
while the device is currently enabled (ts->disabled == false), won't this
unexpectedly disable the hardware?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260821040905.104590-1-triet.hoang.dev@gmail.com?part=1

      reply	other threads:[~2026-08-21  4:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  2:44 [PATCH] input: touchscreen: Convert to DEFINE_SIMPLE_DEV_PM_OPS() Triet Hoang
2026-08-21  2:55 ` sashiko-bot
2026-08-21  4:09   ` [PATCH v2] " Triet Hoang
2026-08-21  4:19     ` sashiko-bot [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=20260821041951.7DE131F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=triet.hoang.dev@gmail.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