This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 918f4603913e66d7ab730b44c2b3afb02770b6e3
Author: yangsong8 <[email protected]>
AuthorDate: Wed Nov 11 15:16:45 2026 +0800

    drivers/ioexpander: release the signal slot when NSIGNALS is 1
    
    With CONFIG_DEV_GPIO_NSIGNALS=1 the previous change compiled out the
    whole slot release in GPIOC_UNREGISTER, so the caller kept receiving
    signals after unregistering.  Only skip the slot compaction in that
    case and still clear gp_pid and cancel the pending notification.
    
    Assisted-by: Kiro:claude-opus-5-5
    Signed-off-by: yangsong8 <[email protected]>
---
 drivers/ioexpander/gpio.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/ioexpander/gpio.c b/drivers/ioexpander/gpio.c
index b1af1eb02cd..c4823759597 100644
--- a/drivers/ioexpander/gpio.c
+++ b/drivers/ioexpander/gpio.c
@@ -902,10 +902,10 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
               {
                 if (pid == dev->gp_signals[i].gp_pid)
                   {
-#   if CONFIG_DEV_GPIO_NSIGNALS > 1
-#     ifdef CONFIG_SIG_EVTHREAD
+#  ifdef CONFIG_SIG_EVTHREAD
                     FAR struct sigwork_s *work;
-#     endif
+#  endif
+#  if CONFIG_DEV_GPIO_NSIGNALS > 1
                     int j;
 
                     for (j = i + 1; j < CONFIG_DEV_GPIO_NSIGNALS; j++)
@@ -921,16 +921,18 @@ static int gpio_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
                         memcpy(&dev->gp_signals[i], &dev->gp_signals[j],
                                sizeof(dev->gp_signals[i]));
                       }
+#  else
+                    int j = i;
+#  endif
 
                     dev->gp_signals[j].gp_pid = 0;
-#     ifdef CONFIG_SIG_EVTHREAD
+#  ifdef CONFIG_SIG_EVTHREAD
                     work = &dev->gp_signals[j].gp_work;
                     spin_unlock_irqrestore(&dev->lock, flags);
                     nxsig_cancel_notification(work);
                     flags = spin_lock_irqsave(&dev->lock);
-#     endif
-                    break;
 #  endif
+                    break;
                   }
               }
 

Reply via email to