From 7bbba4527da175e726d6235df33c072f47674021 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 26 Oct 2017 11:01:58 +0200 Subject: cyber: hide internal symbols --- src/cyber_device_device_class.c | 8 +++--- src/cyber_file.c | 56 ++++++++++++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/cyber_device_device_class.c b/src/cyber_device_device_class.c index 56795e3..98e9557 100644 --- a/src/cyber_device_device_class.c +++ b/src/cyber_device_device_class.c @@ -25,17 +25,17 @@ extern struct cyber_device device; -ssize_t available_show(struct class * class, struct class_attribute * attribute, char * __user buffer) +static ssize_t available_show(struct class * class, struct class_attribute * attribute, char * __user buffer) { return sprintf(buffer, "infinite\n"); } -CLASS_ATTR_RO(available); +static CLASS_ATTR_RO(available); -ssize_t storage_technology_show(struct class * class, struct class_attribute * attribute, char * __user buffer) +static ssize_t storage_technology_show(struct class * class, struct class_attribute * attribute, char * __user buffer) { return sprintf(buffer, "condensed di-hydrogen-monoxide\n"); } -CLASS_ATTR_RO(storage_technology); +static CLASS_ATTR_RO(storage_technology); static int cyber_device_handle_uevent(struct device * kernelDevice, struct kobj_uevent_env * environment) { diff --git a/src/cyber_file.c b/src/cyber_file.c index 914e851..6aa08a8 100644 --- a/src/cyber_file.c +++ b/src/cyber_file.c @@ -21,23 +21,31 @@ #include #include -struct file_operations const cyber_operations = { - .owner = THIS_MODULE, - .open = cyber_file_open, - .read = cyber_file_read, - .write = cyber_file_write, - .release = cyber_file_close, -}; - static char const * cyberPattern = "!CYBER! "; static char * cyberSpace; -int cyber_file_open(struct inode * inode, struct file * file) +/** + * Handler for CYBER device open events + * + * @param inode The kernel inode associated with the CYBER device + * @param file The kernel file associated with the CYBER device + * @return zero on success, non-zero otherwise + */ +static int cyber_file_open(struct inode * inode, struct file * file) { return 0; } -ssize_t cyber_file_read(struct file * file, char __user * buffer, size_t size, loff_t * offset) +/** + * Handler for CYBER device read events + * + * @param file The kernel file associated with the CYBER device + * @param buffer The user-space target buffer for all the CYBER + * @param size The size of the user-space buffer + * @param offset The offset into the CYBER + * @return The number of bytes that were read, negative on error + */ +static ssize_t cyber_file_read(struct file * file, char __user * buffer, size_t size, loff_t * offset) { int const cyberChunks = (size + PAGE_SIZE - 1) / PAGE_SIZE; int const cybersPerChunk = (size > PAGE_SIZE ? PAGE_SIZE : size) / 8; @@ -54,16 +62,40 @@ ssize_t cyber_file_read(struct file * file, char __user * buffer, size_t size, l return cyberChunks * cybersPerChunk * 8; } -ssize_t cyber_file_write(struct file * file, char __user const * buffer, size_t size, loff_t * offset) +/** + * Handler for CYBER device write events + * + * @param file The kernel file associated with the CYBER device + * @param buffer The user-space source buffer for all the CYBER + * @param size The size of the user-space buffer + * @param offset The offset into the CYBER + * @param The number of bytes that were written, negative on error + */ +static ssize_t cyber_file_write(struct file * file, char __user const * buffer, size_t size, loff_t * offset) { return size; } -int cyber_file_close(struct inode * inode, struct file * file) +/** + * Handler for CYBER device close events + * + * @param inode The kernel inode associated with the CYBER device + * @param file The kernel file associated with the CYBER device + * @param zero on success, non-zero otherwise + */ +static int cyber_file_close(struct inode * inode, struct file * file) { return 0; } +struct file_operations const cyber_operations = { + .owner = THIS_MODULE, + .open = cyber_file_open, + .read = cyber_file_read, + .write = cyber_file_write, + .release = cyber_file_close, +}; + int cyber_file_init(void) { int i; -- cgit v1.2.3