Accoriding to the kernel style guide, having `extern` on functions in headers is old school and deprecated, and doesn't add anything. So remove them from random.h, and tidy up the file a little bit too.
Unified · Split
| @@ -12,13 +12,12 @@ · 11 unmodified lines | |||
| 12 | 12 | ||
| 13 | struct notifier_block; | 13 | struct notifier_block; |
| 14 | 14 | ||
| 15 | extern void add_device_randomness(const void *, size_t); | 15 | void add_device_randomness(const void *, size_t); |
| 16 | extern void add_bootloader_randomness(const void *, size_t); | 16 | void add_bootloader_randomness(const void *, size_t); |
| 17 | extern void add_input_randomness(unsigned int type, unsigned int code, | 17 | void add_input_randomness(unsigned int type, unsigned int code, |
| 18 | unsigned int value) __latent_entropy; | 18 | unsigned int value) __latent_entropy; |
| 19 | extern void add_interrupt_randomness(int irq) __latent_entropy; | 19 | void add_interrupt_randomness(int irq) __latent_entropy; |
| 20 | extern void add_hwgenerator_randomness(const void *buffer, size_t count, | 20 | void add_hwgenerator_randomness(const void *buffer, size_t count, size_t entropy); |
| 21 | size_t entropy); | ||
| 22 | 21 | ||
| 23 | #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) | 22 | #if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) |
| 24 | static inline void add_latent_entropy(void) | 23 | static inline void add_latent_entropy(void) |
| @@ -26,30 +25,20 @@ static inline void add_latent_entropy(void) · 1 unmodified line | |||
| 26 | add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy)); | 25 | add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy)); |
| 27 | } | 26 | } |
| 28 | #else | 27 | #else |
| 29 | static inline void add_latent_entropy(void) {} | 28 | static inline void add_latent_entropy(void) { } |
| 30 | #endif | 29 | #endif |
| 31 | 30 | ||
| 32 | #if IS_ENABLED(CONFIG_VMGENID) | 31 | #if IS_ENABLED(CONFIG_VMGENID) |
| 33 | extern void add_vmfork_randomness(const void *unique_vm_id, size_t size); | 32 | void add_vmfork_randomness(const void *unique_vm_id, size_t size); |
| 34 | extern int register_random_vmfork_notifier(struct notifier_block *nb); | 33 | int register_random_vmfork_notifier(struct notifier_block *nb); |
| 35 | extern int unregister_random_vmfork_notifier(struct notifier_block *nb); | 34 | int unregister_random_vmfork_notifier(struct notifier_block *nb); |
| 36 | #else | 35 | #else |
| 37 | static inline int register_random_vmfork_notifier(struct notifier_block *nb) { return 0; } | 36 | static inline int register_random_vmfork_notifier(struct notifier_block *nb) { return 0; } |
| 38 | static inline int unregister_random_vmfork_notifier(struct notifier_block *nb) { return 0; } | 37 | static inline int unregister_random_vmfork_notifier(struct notifier_block *nb) { return 0; } |
| 39 | #endif | 38 | #endif |
| 40 | 39 | ||
| 41 | extern void get_random_bytes(void *buf, size_t nbytes); | 40 | void get_random_bytes(void *buf, size_t nbytes); |
| 42 | extern int wait_for_random_bytes(void); | 41 | size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes); |
| 43 | extern int __init random_init(const char *command_line); | ||
| 44 | extern bool rng_is_initialized(void); | ||
| 45 | extern int register_random_ready_notifier(struct notifier_block *nb); | ||
| 46 | extern int unregister_random_ready_notifier(struct notifier_block *nb); | ||
| 47 | extern size_t __must_check get_random_bytes_arch(void *buf, size_t nbytes); | ||
| 48 | |||
| 49 | #ifndef MODULE | ||
| 50 | extern const struct file_operations random_fops, urandom_fops; | ||
| 51 | #endif | ||
| 52 | |||
| 53 | u32 get_random_u32(void); | 42 | u32 get_random_u32(void); |
| 54 | u64 get_random_u64(void); | 43 | u64 get_random_u64(void); |
| 55 | static inline unsigned int get_random_int(void) | 44 | static inline unsigned int get_random_int(void) |
| @@ -81,11 +70,17 @@ static inline unsigned long get_random_long(void) · 25 unmodified lines | |||
| 81 | 70 | ||
| 82 | static inline unsigned long get_random_canary(void) | 71 | static inline unsigned long get_random_canary(void) |
| 83 | { | 72 | { |
| 84 | unsigned long val = get_random_long(); | 73 | return get_random_long() & CANARY_MASK; |
| 85 | |||
| 86 | return val & CANARY_MASK; | ||
| 87 | } | 74 | } |
| 88 | 75 | ||
| 76 | unsigned long randomize_page(unsigned long start, unsigned long range); | ||
| 77 | |||
| 78 | int __init random_init(const char *command_line); | ||
| 79 | bool rng_is_initialized(void); | ||
| 80 | int wait_for_random_bytes(void); | ||
| 81 | int register_random_ready_notifier(struct notifier_block *nb); | ||
| 82 | int unregister_random_ready_notifier(struct notifier_block *nb); | ||
| 83 | |||
| 89 | /* Calls wait_for_random_bytes() and then calls get_random_bytes(buf, nbytes). | 84 | /* Calls wait_for_random_bytes() and then calls get_random_bytes(buf, nbytes). |
| 90 | * Returns the result of the call to wait_for_random_bytes. */ | 85 | * Returns the result of the call to wait_for_random_bytes. */ |
| 91 | static inline int get_random_bytes_wait(void *buf, size_t nbytes) | 86 | static inline int get_random_bytes_wait(void *buf, size_t nbytes) |
| @@ -109,8 +104,6 @@ declare_get_random_var_wait(int) · 17 unmodified lines | |||
| 109 | declare_get_random_var_wait(long) | 104 | declare_get_random_var_wait(long) |
| 110 | #undef declare_get_random_var | 105 | #undef declare_get_random_var |
| 111 | 106 | ||
| 112 | unsigned long randomize_page(unsigned long start, unsigned long range); | ||
| 113 | |||
| 114 | /* | 107 | /* |
| 115 | * This is designed to be standalone for just prandom | 108 | * This is designed to be standalone for just prandom |
| 116 | * users, but for now we include it from <linux/random.h> | 109 | * users, but for now we include it from <linux/random.h> |
| @@ -121,22 +114,10 @@ unsigned long randomize_page(unsigned long start, unsigned long range); · 4 unmodified lines | |||
| 121 | #ifdef CONFIG_ARCH_RANDOM | 114 | #ifdef CONFIG_ARCH_RANDOM |
| 122 | # include <asm/archrandom.h> | 115 | # include <asm/archrandom.h> |
| 123 | #else | 116 | #else |
| 124 | static inline bool __must_check arch_get_random_long(unsigned long *v) | 117 | static inline bool __must_check arch_get_random_long(unsigned long *v) { return false; } |
| 125 | { | 118 | static inline bool __must_check arch_get_random_int(unsigned int *v) { return false; } |
| 126 | return false; | 119 | static inline bool __must_check arch_get_random_seed_long(unsigned long *v) { return false; } |
| 127 | } | 120 | static inline bool __must_check arch_get_random_seed_int(unsigned int *v) { return false; } |
| 128 | static inline bool __must_check arch_get_random_int(unsigned int *v) | ||
| 129 | { | ||
| 130 | return false; | ||
| 131 | } | ||
| 132 | static inline bool __must_check arch_get_random_seed_long(unsigned long *v) | ||
| 133 | { | ||
| 134 | return false; | ||
| 135 | } | ||
| 136 | static inline bool __must_check arch_get_random_seed_int(unsigned int *v) | ||
| 137 | { | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | #endif | 121 | #endif |
| 141 | 122 | ||
| 142 | /* | 123 | /* |
| @@ -160,8 +141,12 @@ static inline bool __init arch_get_random_long_early(unsigned long *v) · 17 unmodified lines | |||
| 160 | #endif | 141 | #endif |
| 161 | 142 | ||
| 162 | #ifdef CONFIG_SMP | 143 | #ifdef CONFIG_SMP |
| 163 | extern int random_prepare_cpu(unsigned int cpu); | 144 | int random_prepare_cpu(unsigned int cpu); |
| 164 | extern int random_online_cpu(unsigned int cpu); | 145 | int random_online_cpu(unsigned int cpu); |
| 146 | #endif | ||
| 147 | |||
| 148 | #ifndef MODULE | ||
| 149 | extern const struct file_operations random_fops, urandom_fops; | ||
| 165 | #endif | 150 | #endif |
| 166 | 151 | ||
| 167 | #endif /* _LINUX_RANDOM_H */ | 152 | #endif /* _LINUX_RANDOM_H */ |