Commit a41e3dc4 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds
Browse files

HWRNG: add possibility to remove hwrng devices during suspend/resume

Make it possible to unregister a Hardware Random Number Generator
device object in a safe way during a suspend/resume cycle.
Signed-off-by: default avatarRafael J. Wysocki <>
Acked-by: default avatarMichael Buesch <>
Cc: Michael Buesch <>
Cc: Pavel Machek <>
Cc: "John W. Linville" <>
Cc: Alan Stern <>
Cc: Len Brown <>
Cc: Greg KH <>
Cc: Kay Sievers <>
Cc: Richard Purdie <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 533354d4
......@@ -234,11 +234,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO,
static void unregister_miscdev(void)
static void unregister_miscdev(bool suspended)
device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
__misc_deregister(&rng_miscdev, suspended);
static int register_miscdev(void)
......@@ -313,7 +313,7 @@ out:
void hwrng_unregister(struct hwrng *rng)
void __hwrng_unregister(struct hwrng *rng, bool suspended)
int err;
......@@ -332,11 +332,11 @@ void hwrng_unregister(struct hwrng *rng)
if (list_empty(&rng_list))
MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
......@@ -44,7 +44,15 @@ struct hwrng {
/** Register a new Hardware Random Number Generator driver. */
extern int hwrng_register(struct hwrng *rng);
/** Unregister a Hardware Random Number Generator driver. */
extern void hwrng_unregister(struct hwrng *rng);
extern void __hwrng_unregister(struct hwrng *rng, bool suspended);
static inline void hwrng_unregister(struct hwrng *rng)
__hwrng_unregister(rng, false);
static inline void hwrng_unregister_suspended(struct hwrng *rng)
__hwrng_unregister(rng, true);
#endif /* __KERNEL__ */
#endif /* LINUX_HWRANDOM_H_ */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment