xiaoxiang781216 commented on code in PR #20842:
URL: https://github.com/apache/nuttx/pull/20842#discussion_r4336463367


##########
drivers/serial/uart_16550.c:
##########
@@ -983,23 +983,30 @@ static int u16550_attach(struct uart_dev_s *dev)
 
   /* Attach and enable the IRQ */
 
-  ret = irq_attach(priv->irq, priv->ops->isr, dev);
-#ifndef CONFIG_ARCH_NOINTC
-  if (ret == OK)
+  if (priv->ops->attach != NULL)
     {
-      /* Enable the interrupt (RX and TX interrupts are still disabled
-       * in the UART
-       */
-
-      up_enable_irq(priv->irq);
-
-#ifdef HAVE_16550_UART_DMA
-      if (priv->chanrx)
+      ret = priv->ops->attach(priv, dev);
+    }
+  else
+    {
+      ret = irq_attach(priv->irq, priv->ops->isr, dev);
+#ifndef CONFIG_ARCH_NOINTC
+      if (ret == OK)
         {
-          DMA_RESUME(priv->chanrx);
+          /* Enable the interrupt (RX and TX interrupts are still disabled
+           * in the UART
+           */
+
+          up_enable_irq(priv->irq);
         }
 #endif
     }
+
+#if defined(HAVE_16550_UART_DMA) && !defined(CONFIG_ARCH_NOINTC)

Review Comment:
   `#ifde HAVE_16550_UART_DMA`



##########
drivers/serial/uart_16550.c:
##########
@@ -53,6 +53,19 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
+/* Optional per-port hooks.  Without CONFIG_16550_PORT_HOOKS every port has
+ * an interrupt and the default attach/detach, which lets the compiler drop
+ * the code that handles the hooks.
+ */
+
+#ifdef CONFIG_16550_PORT_HOOKS

Review Comment:
   but how much code we can save?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to