All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danny Kaehn <danny.kaehn@plexus.com>
To: <jikos@kernel.org>, <benjamin.tissoires@redhat.com>,
	<andriy.shevchenko@linux.intel.com>
Cc: <linux-input@vger.kernel.org>, <ethan.twardy@plexus.com>,
	Danny Kaehn <danny.kaehn@plexus.com>
Subject: [PATCH v2] hid: cp2112: Fix IRQ shutdown stopping polling for all IRQs on chip
Date: Wed, 11 Oct 2023 13:23:17 -0500	[thread overview]
Message-ID: <20231011182317.1053344-1-danny.kaehn@plexus.com> (raw)

Previously cp2112_gpio_irq_shutdown() always cancelled the
gpio_poll_worker, even if other IRQs were still active, and did not set
the gpio_poll flag to false. This resulted in any call to _shutdown()
resulting in interrupts no longer functioning on the chip until a
_remove() occurred (a.e. the cp2112 is unplugged or system rebooted).

Only cancel polling if all IRQs are disabled/masked, and correctly set
the gpio_poll flag, allowing polling to restart when an interrupt is
next enabled.

Signed-off-by: Danny Kaehn <danny.kaehn@plexus.com>
---

Changes since v1 -- resolving comments from Andy:
- Addressed patch message missing parens
- Fixed opening bracket on newline


 drivers/hid/hid-cp2112.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 54c33a24f844..b24d398f430f 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -1168,7 +1168,11 @@ static void cp2112_gpio_irq_shutdown(struct irq_data *d)
 	struct cp2112_device *dev = gpiochip_get_data(gc);
 
 	cp2112_gpio_irq_mask(d);
-	cancel_delayed_work_sync(&dev->gpio_poll_worker);
+
+	if (!dev->irq_mask) {
+		dev->gpio_poll = false;
+		cancel_delayed_work_sync(&dev->gpio_poll_worker);
+	}
 }
 
 static int cp2112_gpio_irq_type(struct irq_data *d, unsigned int type)
-- 
2.25.1


             reply	other threads:[~2023-10-11 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 18:23 Danny Kaehn [this message]
2023-10-11 18:45 ` [PATCH v2] hid: cp2112: Fix IRQ shutdown stopping polling for all IRQs on chip Danny Kaehn
2023-10-25 14:17 ` Benjamin Tissoires

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=20231011182317.1053344-1-danny.kaehn@plexus.com \
    --to=danny.kaehn@plexus.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=ethan.twardy@plexus.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.