aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Mackall <mpm@selenic.com>2008-04-29 04:02:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:24 -0400
commit90b75ee54666fe615ebcacfc8d8540b80afdedd5 (patch)
treeb1bedeaacb7011ba8280a6f84660574536e587da
parent0302190411c2ba79819303503999cc839d600704 (diff)
random: clean up checkpatch complaints
Signed-off-by: Matt Mackall <mpm@selenic.com> Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/random.c80
1 files changed, 35 insertions, 45 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index f43c89f7c44..32118598a71 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -272,7 +272,7 @@ static int random_write_wakeup_thresh = 128;
272 272
273static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28; 273static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28;
274 274
275static DEFINE_PER_CPU(int, trickle_count) = 0; 275static DEFINE_PER_CPU(int, trickle_count);
276 276
277/* 277/*
278 * A pool of size .poolwords is stirred with a primitive polynomial 278 * A pool of size .poolwords is stirred with a primitive polynomial
@@ -372,15 +372,16 @@ static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
372static DECLARE_WAIT_QUEUE_HEAD(random_write_wait); 372static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
373 373
374#if 0 374#if 0
375static int debug = 0; 375static int debug;
376module_param(debug, bool, 0644); 376module_param(debug, bool, 0644);
377#define DEBUG_ENT(fmt, arg...) do { if (debug) \ 377#define DEBUG_ENT(fmt, arg...) do { \
378 printk(KERN_DEBUG "random %04d %04d %04d: " \ 378 if (debug) \
379 fmt,\ 379 printk(KERN_DEBUG "random %04d %04d %04d: " \
380 input_pool.entropy_count,\ 380 fmt,\
381 blocking_pool.entropy_count,\ 381 input_pool.entropy_count,\
382 nonblocking_pool.entropy_count,\ 382 blocking_pool.entropy_count,\
383 ## arg); } while (0) 383 nonblocking_pool.entropy_count,\
384 ## arg); } while (0)
384#else 385#else
385#define DEBUG_ENT(fmt, arg...) do {} while (0) 386#define DEBUG_ENT(fmt, arg...) do {} while (0)
386#endif 387#endif
@@ -551,7 +552,7 @@ static void credit_entropy_store(struct entropy_store *r, int nbits)
551/* There is one of these per entropy source */ 552/* There is one of these per entropy source */
552struct timer_rand_state { 553struct timer_rand_state {
553 cycles_t last_time; 554 cycles_t last_time;
554 long last_delta,last_delta2; 555 long last_delta, last_delta2;
555 unsigned dont_count_entropy:1; 556 unsigned dont_count_entropy:1;
556}; 557};
557 558
@@ -624,7 +625,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
624 min_t(int, fls(delta>>1), 11)); 625 min_t(int, fls(delta>>1), 11));
625 } 626 }
626 627
627 if(input_pool.entropy_count >= random_read_wakeup_thresh) 628 if (input_pool.entropy_count >= random_read_wakeup_thresh)
628 wake_up_interruptible(&random_read_wait); 629 wake_up_interruptible(&random_read_wait);
629 630
630out: 631out:
@@ -677,7 +678,7 @@ void add_disk_randomness(struct gendisk *disk)
677 * 678 *
678 *********************************************************************/ 679 *********************************************************************/
679 680
680static ssize_t extract_entropy(struct entropy_store *r, void * buf, 681static ssize_t extract_entropy(struct entropy_store *r, void *buf,
681 size_t nbytes, int min, int rsvd); 682 size_t nbytes, int min, int rsvd);
682 683
683/* 684/*
@@ -704,8 +705,8 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
704 "(%d of %d requested)\n", 705 "(%d of %d requested)\n",
705 r->name, bytes * 8, nbytes * 8, r->entropy_count); 706 r->name, bytes * 8, nbytes * 8, r->entropy_count);
706 707
707 bytes=extract_entropy(r->pull, tmp, bytes, 708 bytes = extract_entropy(r->pull, tmp, bytes,
708 random_read_wakeup_thresh / 8, rsvd); 709 random_read_wakeup_thresh / 8, rsvd);
709 add_entropy_words(r, tmp, (bytes + 3) / 4); 710 add_entropy_words(r, tmp, (bytes + 3) / 4);
710 credit_entropy_store(r, bytes*8); 711 credit_entropy_store(r, bytes*8);
711 } 712 }
@@ -744,7 +745,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
744 if (r->limit && nbytes + reserved >= r->entropy_count / 8) 745 if (r->limit && nbytes + reserved >= r->entropy_count / 8)
745 nbytes = r->entropy_count/8 - reserved; 746 nbytes = r->entropy_count/8 - reserved;
746 747
747 if(r->entropy_count / 8 >= nbytes + reserved) 748 if (r->entropy_count / 8 >= nbytes + reserved)
748 r->entropy_count -= nbytes*8; 749 r->entropy_count -= nbytes*8;
749 else 750 else
750 r->entropy_count = reserved; 751 r->entropy_count = reserved;
@@ -802,7 +803,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
802 memset(buf, 0, sizeof(buf)); 803 memset(buf, 0, sizeof(buf));
803} 804}
804 805
805static ssize_t extract_entropy(struct entropy_store *r, void * buf, 806static ssize_t extract_entropy(struct entropy_store *r, void *buf,
806 size_t nbytes, int min, int reserved) 807 size_t nbytes, int min, int reserved)
807{ 808{
808 ssize_t ret = 0, i; 809 ssize_t ret = 0, i;
@@ -872,7 +873,6 @@ void get_random_bytes(void *buf, int nbytes)
872{ 873{
873 extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); 874 extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0);
874} 875}
875
876EXPORT_SYMBOL(get_random_bytes); 876EXPORT_SYMBOL(get_random_bytes);
877 877
878/* 878/*
@@ -940,7 +940,7 @@ void rand_initialize_disk(struct gendisk *disk)
940#endif 940#endif
941 941
942static ssize_t 942static ssize_t
943random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) 943random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
944{ 944{
945 ssize_t n, retval = 0, count = 0; 945 ssize_t n, retval = 0, count = 0;
946 946
@@ -1002,8 +1002,7 @@ random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
1002} 1002}
1003 1003
1004static ssize_t 1004static ssize_t
1005urandom_read(struct file * file, char __user * buf, 1005urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
1006 size_t nbytes, loff_t *ppos)
1007{ 1006{
1008 return extract_entropy_user(&nonblocking_pool, buf, nbytes); 1007 return extract_entropy_user(&nonblocking_pool, buf, nbytes);
1009} 1008}
@@ -1045,9 +1044,8 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1045 return 0; 1044 return 0;
1046} 1045}
1047 1046
1048static ssize_t 1047static ssize_t random_write(struct file *file, const char __user *buffer,
1049random_write(struct file * file, const char __user * buffer, 1048 size_t count, loff_t *ppos)
1050 size_t count, loff_t *ppos)
1051{ 1049{
1052 size_t ret; 1050 size_t ret;
1053 struct inode *inode = file->f_path.dentry->d_inode; 1051 struct inode *inode = file->f_path.dentry->d_inode;
@@ -1064,9 +1062,8 @@ random_write(struct file * file, const char __user * buffer,
1064 return (ssize_t)count; 1062 return (ssize_t)count;
1065} 1063}
1066 1064
1067static int 1065static int random_ioctl(struct inode *inode, struct file *file,
1068random_ioctl(struct inode * inode, struct file * file, 1066 unsigned int cmd, unsigned long arg)
1069 unsigned int cmd, unsigned long arg)
1070{ 1067{
1071 int size, ent_count; 1068 int size, ent_count;
1072 int __user *p = (int __user *)arg; 1069 int __user *p = (int __user *)arg;
@@ -1157,7 +1154,6 @@ void generate_random_uuid(unsigned char uuid_out[16])
1157 /* Set the UUID variant to DCE */ 1154 /* Set the UUID variant to DCE */
1158 uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; 1155 uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80;
1159} 1156}
1160
1161EXPORT_SYMBOL(generate_random_uuid); 1157EXPORT_SYMBOL(generate_random_uuid);
1162 1158
1163/******************************************************************** 1159/********************************************************************
@@ -1339,7 +1335,7 @@ ctl_table random_table[] = {
1339 1335
1340#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1336#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1341 1337
1342static __u32 twothirdsMD4Transform (__u32 const buf[4], __u32 const in[12]) 1338static __u32 twothirdsMD4Transform(__u32 const buf[4], __u32 const in[12])
1343{ 1339{
1344 __u32 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; 1340 __u32 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
1345 1341
@@ -1487,8 +1483,8 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
1487 */ 1483 */
1488 1484
1489 memcpy(hash, saddr, 16); 1485 memcpy(hash, saddr, 16);
1490 hash[4]=((__force u16)sport << 16) + (__force u16)dport; 1486 hash[4] = ((__force u16)sport << 16) + (__force u16)dport;
1491 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); 1487 memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
1492 1488
1493 seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; 1489 seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
1494 seq += keyptr->count; 1490 seq += keyptr->count;
@@ -1538,10 +1534,10 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
1538 * Note that the words are placed into the starting vector, which is 1534 * Note that the words are placed into the starting vector, which is
1539 * then mixed with a partial MD4 over random data. 1535 * then mixed with a partial MD4 over random data.
1540 */ 1536 */
1541 hash[0]=(__force u32)saddr; 1537 hash[0] = (__force u32)saddr;
1542 hash[1]=(__force u32)daddr; 1538 hash[1] = (__force u32)daddr;
1543 hash[2]=((__force u16)sport << 16) + (__force u16)dport; 1539 hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
1544 hash[3]=keyptr->secret[11]; 1540 hash[3] = keyptr->secret[11];
1545 1541
1546 seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK; 1542 seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK;
1547 seq += keyptr->count; 1543 seq += keyptr->count;
@@ -1556,10 +1552,7 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
1556 * Choosing a clock of 64 ns period is OK. (period of 274 s) 1552 * Choosing a clock of 64 ns period is OK. (period of 274 s)
1557 */ 1553 */
1558 seq += ktime_to_ns(ktime_get_real()) >> 6; 1554 seq += ktime_to_ns(ktime_get_real()) >> 6;
1559#if 0 1555
1560 printk("init_seq(%lx, %lx, %d, %d) = %d\n",
1561 saddr, daddr, sport, dport, seq);
1562#endif
1563 return seq; 1556 return seq;
1564} 1557}
1565 1558
@@ -1582,14 +1575,15 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
1582} 1575}
1583 1576
1584#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1577#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1585u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, __be16 dport) 1578u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
1579 __be16 dport)
1586{ 1580{
1587 struct keydata *keyptr = get_keyptr(); 1581 struct keydata *keyptr = get_keyptr();
1588 u32 hash[12]; 1582 u32 hash[12];
1589 1583
1590 memcpy(hash, saddr, 16); 1584 memcpy(hash, saddr, 16);
1591 hash[4] = (__force u32)dport; 1585 hash[4] = (__force u32)dport;
1592 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); 1586 memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
1593 1587
1594 return twothirdsMD4Transform((const __u32 *)daddr, hash); 1588 return twothirdsMD4Transform((const __u32 *)daddr, hash);
1595} 1589}
@@ -1617,13 +1611,9 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
1617 1611
1618 seq += ktime_to_ns(ktime_get_real()); 1612 seq += ktime_to_ns(ktime_get_real());
1619 seq &= (1ull << 48) - 1; 1613 seq &= (1ull << 48) - 1;
1620#if 0 1614
1621 printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n",
1622 saddr, daddr, sport, dport, seq);
1623#endif
1624 return seq; 1615 return seq;
1625} 1616}
1626
1627EXPORT_SYMBOL(secure_dccp_sequence_number); 1617EXPORT_SYMBOL(secure_dccp_sequence_number);
1628#endif 1618#endif
1629 1619