You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/03 17:21:34 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #3226: syslog: Added multi device support in syslog_device.

xiaoxiang781216 commented on a change in pull request #3226:
URL: https://github.com/apache/incubator-nuttx/pull/3226#discussion_r606688388



##########
File path: include/nuttx/syslog/syslog.h
##########
@@ -82,22 +82,41 @@
  * Public Types
  ****************************************************************************/
 
-/* This structure provides the interface to a SYSLOG device */
+/* Forward declaration */
 
-typedef CODE ssize_t (*syslog_write_t)(FAR const char *buf, size_t buflen);
-typedef CODE int (*syslog_putc_t)(int ch);
-typedef CODE int (*syslog_flush_t)(void);
+struct syslog_channel_s;
 
-struct syslog_channel_s
-{
-  /* I/O redirection methods */
+/* SYSLOG I/O redirection methods */
+
+typedef CODE ssize_t (*syslog_write_t)(FAR struct syslog_channel_s *channel,
+                                       FAR const char *buf, size_t buflen);
+typedef CODE int (*syslog_putc_t)(FAR struct syslog_channel_s *channel,
+                                  int ch);
+typedef CODE int (*syslog_flush_t)(FAR struct syslog_channel_s *channel);
+
+/* SYSLOG device operations */
 
+struct syslog_channel_ops_s
+{
   syslog_putc_t  sc_putc;   /* Normal buffered output */
   syslog_putc_t  sc_force;  /* Low-level output for interrupt handlers */
   syslog_flush_t sc_flush;  /* Flush buffered output (on crash) */
 #ifdef CONFIG_SYSLOG_WRITE
   syslog_write_t sc_write;  /* Write multiple bytes */
 #endif
+};
+
+/* This structure provides the interface to a SYSLOG channel */
+
+struct syslog_channel_s
+{
+  /* Channel operations */
+
+  FAR const struct syslog_channel_ops_s *sc_ops;
+
+  /* Channel device */
+
+  FAR void *sc_dev;

Review comment:
       remove sc_dev, let's driver embed syslog_channel_s into his own struct directly like this:
   ```
   struct my_channel_s
   {
     struct syslog_channel_s;
    /* add more sate here */
   };
   
   static int my_syslog_putc)(FAR struct syslog_channel_s *channel,  int ch)
   {
     FAR struct my_channel_s *my = (FAR struct my_channel_s *)channel;
   
     /* access the state by my->xxx */
   }
   ```
   This is the convention used by many driver.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org