aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2008-05-12 17:01:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-05-13 11:02:22 -0400
commit3d88958e01e71bb14a367db75f12f7a59c068f02 (patch)
tree7af7e560e3f35b672537839de6e38038c654e876 /arch
parent5d33e4d7fd9a52d2673e5c730eab81856e100a74 (diff)
uml: style fixes in the random driver
Give random.c a style workover while I'm changing it. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/um/drivers/random.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index f92b7c81eb00..4949044773ba 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -1,4 +1,5 @@
1/* Copyright (C) 2005 Jeff Dike <jdike@addtoit.com> */ 1/* Copyright (C) 2005 - 2008 Jeff Dike <jdike@{linux.intel,addtoit}.com> */
2
2/* Much of this ripped from drivers/char/hw_random.c, see there for other 3/* Much of this ripped from drivers/char/hw_random.c, see there for other
3 * copyright. 4 * copyright.
4 * 5 *
@@ -35,7 +36,7 @@ static int rng_dev_open (struct inode *inode, struct file *filp)
35 /* enforce read-only access to this chrdev */ 36 /* enforce read-only access to this chrdev */
36 if ((filp->f_mode & FMODE_READ) == 0) 37 if ((filp->f_mode & FMODE_READ) == 0)
37 return -EINVAL; 38 return -EINVAL;
38 if (filp->f_mode & FMODE_WRITE) 39 if ((filp->f_mode & FMODE_WRITE) != 0)
39 return -EINVAL; 40 return -EINVAL;
40 41
41 return 0; 42 return 0;
@@ -44,31 +45,31 @@ static int rng_dev_open (struct inode *inode, struct file *filp)
44static atomic_t host_sleep_count = ATOMIC_INIT(0); 45static atomic_t host_sleep_count = ATOMIC_INIT(0);
45 46
46static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, 47static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
47 loff_t * offp) 48 loff_t *offp)
48{ 49{
49 u32 data; 50 u32 data;
50 int n, ret = 0, have_data; 51 int n, ret = 0, have_data;
51 52
52 while(size){ 53 while (size) {
53 n = os_read_file(random_fd, &data, sizeof(data)); 54 n = os_read_file(random_fd, &data, sizeof(data));
54 if(n > 0){ 55 if (n > 0) {
55 have_data = n; 56 have_data = n;
56 while (have_data && size) { 57 while (have_data && size) {
57 if (put_user((u8)data, buf++)) { 58 if (put_user((u8) data, buf++)) {
58 ret = ret ? : -EFAULT; 59 ret = ret ? : -EFAULT;
59 break; 60 break;
60 } 61 }
61 size--; 62 size--;
62 ret++; 63 ret++;
63 have_data--; 64 have_data--;
64 data>>=8; 65 data >>= 8;
65 } 66 }
66 } 67 }
67 else if(n == -EAGAIN){ 68 else if (n == -EAGAIN) {
68 DECLARE_WAITQUEUE(wait, current); 69 DECLARE_WAITQUEUE(wait, current);
69 70
70 if (filp->f_flags & O_NONBLOCK) 71 if (filp->f_flags & O_NONBLOCK)
71 return ret ? : -EAGAIN; 72 return ret ? : -EAGAIN;
72 73
73 atomic_inc(&host_sleep_count); 74 atomic_inc(&host_sleep_count);
74 reactivate_fd(random_fd, RANDOM_IRQ); 75 reactivate_fd(random_fd, RANDOM_IRQ);
@@ -85,8 +86,10 @@ static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
85 ignore_sigio_fd(random_fd); 86 ignore_sigio_fd(random_fd);
86 deactivate_fd(random_fd, RANDOM_IRQ); 87 deactivate_fd(random_fd, RANDOM_IRQ);
87 } 88 }
88 } 89 }
89 else return n; 90 else
91 return n;
92
90 if (signal_pending (current)) 93 if (signal_pending (current))
91 return ret ? : -ERESTARTSYS; 94 return ret ? : -ERESTARTSYS;
92 } 95 }
@@ -120,33 +123,33 @@ static int __init rng_init (void)
120{ 123{
121 int err; 124 int err;
122 125
123 err = os_open_file("/dev/random", of_read(OPENFLAGS()), 0); 126 err = os_open_file("/dev/random", of_read(OPENFLAGS()), 0);
124 if(err < 0) 127 if (err < 0)
125 goto out; 128 goto out;
126 129
127 random_fd = err; 130 random_fd = err;
128 131
129 err = um_request_irq(RANDOM_IRQ, random_fd, IRQ_READ, random_interrupt, 132 err = um_request_irq(RANDOM_IRQ, random_fd, IRQ_READ, random_interrupt,
130 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "random", 133 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "random",
131 NULL); 134 NULL);
132 if(err) 135 if (err)
133 goto err_out_cleanup_hw; 136 goto err_out_cleanup_hw;
134 137
135 sigio_broken(random_fd, 1); 138 sigio_broken(random_fd, 1);
136 139
137 err = misc_register (&rng_miscdev); 140 err = misc_register (&rng_miscdev);
138 if (err) { 141 if (err) {
139 printk (KERN_ERR RNG_MODULE_NAME ": misc device register failed\n"); 142 printk (KERN_ERR RNG_MODULE_NAME ": misc device register "
143 "failed\n");
140 goto err_out_cleanup_hw; 144 goto err_out_cleanup_hw;
141 } 145 }
146out:
147 return err;
142 148
143 out: 149err_out_cleanup_hw:
144 return err;
145
146 err_out_cleanup_hw:
147 os_close_file(random_fd); 150 os_close_file(random_fd);
148 random_fd = -1; 151 random_fd = -1;
149 goto out; 152 goto out;
150} 153}
151 154
152/* 155/*