Skip to content

Conversation

@Kaben123
Copy link

Add handling for the FIONREAD ioctl in noteram_ioctl to return the number of unread bytes in the circular note buffer (noteram_unread_length()). Validate the argument pointer and return -EINVAL if it is NULL.

Note: Please adhere to Contributing Guidelines.

Summary

This patch adds support for the FIONREAD ioctl command in the noteram driver to allow user-space to query the number of unread bytes in the circular note buffer.

Motivation

User-space consumers of /dev/note/ram can benefit from being able to query the available unread size for efficient reads without blocking or to size buffers appropriately.

What was changed

  • drivers/note/noteram_driver.c
    • Added handling for FIONREAD in noteram_ioctl() to return the result of noteram_unread_length() when a valid pointer is passed.

Impact

  • Functional behavior: Adds a new ioctl handler; no behavior change to existing functionality.
  • API/ABI: Adds support for a commonly used ioctl (FIONREAD) on the device node.
  • Risks: Minimal. The added code verifies arg and returns -EINVAL for null pointer.

Testing

  • Compiled and ran on development board. Verified ioctl(fd, FIONREAD, &size) returns expected available bytes.

Add handling for the FIONREAD ioctl in noteram_ioctl to return the
number of unread bytes in the circular note buffer (noteram_unread_length()).
Validate the argument pointer and return -EINVAL if it is NULL.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
@github-actions github-actions bot added the Area: Drivers Drivers issues label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants