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

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

char: random: use sdevice_{read,write} for {u}random fops

parent a574ea95
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -300,6 +300,10 @@
#define ENTROPY_SHIFT 3
#define ENTROPY_BITS(r) ((r)->entropy_count >> ENTROPY_SHIFT)

#ifdef CONFIG_SRANDOM
#include <../drivers/char/srandom/srandom.h>
#endif

/*
 * The minimum number of bits of entropy before we wake up a read on
 * /dev/random.  Should be enough to do a significant reseed.
@@ -1853,6 +1857,7 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
	return 0;
}

#ifndef CONFIG_SRANDOM
static ssize_t random_write(struct file *file, const char __user *buffer,
			    size_t count, loff_t *ppos)
{
@@ -1864,6 +1869,7 @@ static ssize_t random_write(struct file *file, const char __user *buffer,

	return (ssize_t)count;
}
#endif

static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
{
@@ -1928,8 +1934,13 @@ static int random_fasync(int fd, struct file *filp, int on)
}

const struct file_operations random_fops = {
	#ifdef CONFIG_SRANDOM
	.read  = sdevice_read,
	.write = sdevice_write,
	#else
	.read  = random_read,
	.write = random_write,
	#endif
	.poll  = random_poll,
	.unlocked_ioctl = random_ioctl,
	.fasync = random_fasync,
@@ -1937,8 +1948,13 @@ const struct file_operations random_fops = {
};

const struct file_operations urandom_fops = {
	#ifdef CONFIG_SRANDOM
	.read  = sdevice_read,
	.write = sdevice_write,
	#else
	.read  = urandom_read,
	.write = random_write,
	#endif
	.unlocked_ioctl = random_ioctl,
	.fasync = random_fasync,
	.llseek = noop_llseek,