pkarashchenko commented on code in PR #8799:
URL: https://github.com/apache/nuttx/pull/8799#discussion_r1133772588


##########
arch/arm64/src/common/arm64_fpu.c:
##########
@@ -54,6 +80,45 @@
 static struct fpu_reg g_idle_thread_fpu[CONFIG_SMP_NCPUS];
 static struct arm64_cpu_fpu_context g_cpu_fpu_ctx[CONFIG_SMP_NCPUS];
 
+#ifdef CONFIG_FS_PROCFS_REGISTER
+
+/* procfs methods */
+
+static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
+                             int oflags, mode_t mode);
+static int arm64_fpu_procfs_close(struct file *filep);
+static ssize_t arm64_fpu_procfs_read(struct file *filep, char *buffer,
+                                 size_t buflen);
+static int arm64_fpu_procfs_stat(const char *relpath, struct stat *buf);
+
+/* See include/nutts/fs/procfs.h
+ * We use the old-fashioned kind of initializers so that this will compile
+ * with any compiler.
+ */
+
+const struct procfs_operations arm64_fpu_procfs_operations =
+{
+  arm64_fpu_procfs_open,  /* open */
+  arm64_fpu_procfs_close, /* close */
+  arm64_fpu_procfs_read,  /* read */
+  NULL,                   /* write */
+  NULL,                   /* dup */
+  NULL,                   /* opendir */
+  NULL,                   /* closedir */
+  NULL,                   /* readdir */
+  NULL,                   /* rewinddir */
+
+  arm64_fpu_procfs_stat   /* stat */
+};

Review Comment:
   I think we can use designated initialiser here and remove a couple of 
explicitly NULL-ed items



##########
arch/arm64/src/common/arm64_fpu.c:
##########
@@ -84,6 +149,120 @@ static void arm64_fpu_access_trap_disable(void)
   ARM64_ISB();
 }
 
+#ifdef CONFIG_FS_PROCFS_REGISTER
+
+static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
+                             int oflags, mode_t mode)
+{
+  struct arm64_fpu_procfs_file_s *priv;
+
+  uinfo("Open '%s'\n", relpath);
+
+  /* PROCFS is read-only.  Any attempt to open with any kind of write
+   * access is not permitted.
+   *
+   * REVISIT:  Write-able proc files could be quite useful.
+   */
+
+  if (((oflags & O_WRONLY) != 0 || (oflags & O_RDONLY) == 0))
+    {
+      uerr("ERROR: Only O_RDONLY supported\n");
+      return -EACCES;
+    }
+
+  /* Allocate the open file structure */
+
+  priv = (struct arm64_fpu_procfs_file_s *)kmm_zalloc(
+    sizeof(struct arm64_fpu_procfs_file_s));
+  if (!priv)
+    {
+      uerr("ERROR: Failed to allocate file attributes\n");
+      return -ENOMEM;
+    }
+
+  /* Save the open file structure as the open-specific state in
+   * filep->f_priv.
+   */
+
+  filep->f_priv = (void *)priv;
+  return OK;
+}
+
+static int arm64_fpu_procfs_close(struct file *filep)
+{
+  struct arm64_fpu_procfs_file_s *priv;
+
+  /* Recover our private data from the struct file instance */
+
+  priv = (struct arm64_fpu_procfs_file_s *)filep->f_priv;
+  DEBUGASSERT(priv);
+
+  /* Release the file attributes structure */
+
+  kmm_free(priv);
+  filep->f_priv = NULL;
+  return OK;
+}
+
+static ssize_t arm64_fpu_procfs_read(struct file *filep, char *buffer,
+                                 size_t buflen)

Review Comment:
   ```suggestion
   static ssize_t arm64_fpu_procfs_read(struct file *filep, char *buffer,
                                        size_t buflen)
   ```



##########
arch/arm64/src/common/arm64_fpu.c:
##########
@@ -54,6 +80,45 @@
 static struct fpu_reg g_idle_thread_fpu[CONFIG_SMP_NCPUS];
 static struct arm64_cpu_fpu_context g_cpu_fpu_ctx[CONFIG_SMP_NCPUS];
 
+#ifdef CONFIG_FS_PROCFS_REGISTER
+
+/* procfs methods */
+
+static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
+                             int oflags, mode_t mode);

Review Comment:
   ```suggestion
   static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
                                    int oflags, mode_t mode);
   ```



##########
arch/arm64/src/common/arm64_fpu.c:
##########
@@ -84,6 +149,120 @@ static void arm64_fpu_access_trap_disable(void)
   ARM64_ISB();
 }
 
+#ifdef CONFIG_FS_PROCFS_REGISTER
+
+static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
+                             int oflags, mode_t mode)

Review Comment:
   ```suggestion
   static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
                                    int oflags, mode_t mode)
   ```



##########
arch/arm64/src/common/arm64_fpu.c:
##########
@@ -54,6 +80,45 @@
 static struct fpu_reg g_idle_thread_fpu[CONFIG_SMP_NCPUS];
 static struct arm64_cpu_fpu_context g_cpu_fpu_ctx[CONFIG_SMP_NCPUS];
 
+#ifdef CONFIG_FS_PROCFS_REGISTER
+
+/* procfs methods */
+
+static int arm64_fpu_procfs_open(struct file *filep, const char *relpath,
+                             int oflags, mode_t mode);
+static int arm64_fpu_procfs_close(struct file *filep);
+static ssize_t arm64_fpu_procfs_read(struct file *filep, char *buffer,
+                                 size_t buflen);

Review Comment:
   ```suggestion
   static ssize_t arm64_fpu_procfs_read(struct file *filep, char *buffer,
                                        size_t buflen);
   ```



-- 
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: commits-unsubscr...@nuttx.apache.org

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

Reply via email to