Fishwaldo commented on code in PR #19878:
URL: https://github.com/apache/nuttx/pull/19878#discussion_r3796309775
##########
drivers/ioexpander/gpio.c:
##########
@@ -75,10 +125,309 @@ static const struct file_operations g_gpio_drvrops =
gpio_poll, /* poll */
};
+#ifdef CONFIG_GPIO_PROCFS
+
+static struct list_node g_gpio_list = LIST_INITIAL_VALUE(g_gpio_list);
+static mutex_t g_gpio_lock = NXMUTEX_INITIALIZER;
+static bool g_gpio_procfs_added;
+
+/* Indexed by enum gpio_pintype_e. The enum's own comment warns that a
+ * table like this has to be extended with it; the assertion below turns
+ * forgetting into a build error rather than a pin type with no name.
+ */
+
+static const FAR char *g_gpio_typename[] =
+{
+ "INPUT", /* GPIO_INPUT_PIN */
+ "INPUT_PU", /* GPIO_INPUT_PIN_PULLUP */
+ "INPUT_PD", /* GPIO_INPUT_PIN_PULLDOWN */
+ "OUTPUT", /* GPIO_OUTPUT_PIN */
+ "OUTPUT_OD", /* GPIO_OUTPUT_PIN_OPENDRAIN */
+ "INT", /* GPIO_INTERRUPT_PIN */
+ "INT_HIGH", /* GPIO_INTERRUPT_HIGH_PIN */
+ "INT_LOW", /* GPIO_INTERRUPT_LOW_PIN */
+ "INT_RISING", /* GPIO_INTERRUPT_RISING_PIN */
+ "INT_FALLING", /* GPIO_INTERRUPT_FALLING_PIN */
+ "INT_BOTH", /* GPIO_INTERRUPT_BOTH_PIN */
+ "INT_WAKE", /* GPIO_INTERRUPT_PIN_WAKEUP */
+ "INT_HIGH_WAKE", /* GPIO_INTERRUPT_HIGH_PIN_WAKEUP */
+ "INT_LOW_WAKE", /* GPIO_INTERRUPT_LOW_PIN_WAKEUP */
+ "INT_RISING_WAKE", /* GPIO_INTERRUPT_RISING_PIN_WAKEUP */
+ "INT_FALLING_WAKE", /* GPIO_INTERRUPT_FALLING_PIN_WAKEUP */
+ "INT_BOTH_WAKE", /* GPIO_INTERRUPT_BOTH_PIN_WAKEUP */
+};
+
+static_assert(nitems(g_gpio_typename) == GPIO_NPINTYPES,
+ "pin type name table does not match enum gpio_pintype_e");
+
+static const struct procfs_operations g_gpio_procfs_ops =
+{
+ gpio_procfs_open, /* open */
+ gpio_procfs_close, /* close */
+ gpio_procfs_read, /* read */
+ NULL, /* write */
+ NULL, /* poll */
+
+ gpio_procfs_dup, /* dup */
+
+ NULL, /* opendir */
+ NULL, /* closedir */
+ NULL, /* readdir */
+ NULL, /* rewinddir */
+
+ gpio_procfs_stat, /* stat */
+};
+
+static const struct procfs_entry_s g_gpio_procfs =
+{
+ "gpio", &g_gpio_procfs_ops, PROCFS_FILE_TYPE
+};
+
+#endif /* CONFIG_GPIO_PROCFS */
+
/****************************************************************************
* Private Functions
****************************************************************************/
+#ifdef CONFIG_GPIO_PROCFS
+
+/****************************************************************************
+ * Name: gpio_procfs_open
Review Comment:
Fixed. Thanks for the review. :)
--
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]