pkarashchenko commented on code in PR #8799: URL: https://github.com/apache/nuttx/pull/8799#discussion_r1141821990
########## arch/arm64/src/common/arm64_fpu.c: ########## @@ -84,6 +148,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) +{ + struct arm64_fpu_procfs_file_s *attr; + struct arm64_cpu_fpu_context *ctx; + off_t offset; + int linesize; + int ret; + int i; + + uinfo("buffer=%p buflen=%lu\n", buffer, (unsigned long)buflen); Review Comment: ```suggestion uinfo("buffer=%p buflen=%zu\n", buffer, buflen); ``` ########## arch/arm64/src/common/arm64_fpu.c: ########## @@ -84,6 +148,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) Review Comment: ```suggestion if (priv == NULL) ``` -- 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