Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba87f678 authored by Jebaitedneko's avatar Jebaitedneko Committed by Gagan Malvi
Browse files

char: srandom: expose sdevice_{read,write} and sfops for treewide usage



* de-staticify, externify and move the prototypes to srandom.h
* constify sfops
* also export sdevice_read and sdevice_write as symbols

Signed-off-by: default avatarJebaitedneko <jebaitedneko@gmail.com>
parent 344a9d57
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include "srandom.h"

#define DRIVER_AUTHOR "Jonathan Senkerik <josenk@jintegrate.co>"
#define DRIVER_DESC   "Improved random number generator."
@@ -57,8 +58,6 @@
 */
static int device_open(struct inode *, struct file *);
static int device_release(struct inode *, struct file *);
static ssize_t sdevice_read(struct file *, char *, size_t, loff_t *);
static ssize_t sdevice_write(struct file *, const char *, size_t, loff_t *);
static uint64_t xorshft64(void);
static uint64_t xorshft128(void);
static int nextbuffer(void);
@@ -74,7 +73,7 @@ static int work_thread(void *data);
/*
 * Global variables are declared as static, so are global within the file.
 */
static struct file_operations sfops = {
const struct file_operations sfops = {
        .owner   = THIS_MODULE,
        .open    = device_open,
        .read    = sdevice_read,
@@ -279,7 +278,7 @@ static int device_release(struct inode *inode, struct file *file)
/*
 * Called when a process reads from the device.
 */
static ssize_t sdevice_read(struct file * file, char * buf, size_t count, loff_t *ppos)
ssize_t sdevice_read(struct file * file, char * buf, size_t count, loff_t *ppos)
{
        char *new_buf;                 /* Buffer to hold numbers to send */
        int ret, counter;
@@ -425,11 +424,12 @@ static ssize_t sdevice_read(struct file * file, char * buf, size_t count, loff_t
        return count;
}

EXPORT_SYMBOL(sdevice_read);

/*
 * Called when someone tries to write to /dev/srandom device
 */
static ssize_t sdevice_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
ssize_t sdevice_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{

        char *newdata;
@@ -461,6 +461,7 @@ static ssize_t sdevice_write(struct file *file, const char __user *buf, size_t c
        return count;
}

EXPORT_SYMBOL(sdevice_write);


/*
+4 −0
Original line number Diff line number Diff line
#include <linux/fs.h>
extern const struct file_operations sfops;
extern ssize_t sdevice_read(struct file *, char *, size_t, loff_t *);
extern ssize_t sdevice_write(struct file *, const char *, size_t, loff_t *);