提交 ff77c150 编写于 作者: H Herbert Xu

hwrng: core - Drop current rng in set_current_rng

Rather than having callers of set_current_rng call drop_current_rng,
we can do it directly in set_current_rng.
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
上级 ac3a497f
...@@ -70,6 +70,7 @@ module_param(default_quality, ushort, 0644); ...@@ -70,6 +70,7 @@ module_param(default_quality, ushort, 0644);
MODULE_PARM_DESC(default_quality, MODULE_PARM_DESC(default_quality,
"default entropy content of hwrng per mill"); "default entropy content of hwrng per mill");
static void drop_current_rng(void);
static void start_khwrngd(void); static void start_khwrngd(void);
static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size, static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size,
...@@ -105,6 +106,7 @@ static inline void cleanup_rng(struct kref *kref) ...@@ -105,6 +106,7 @@ static inline void cleanup_rng(struct kref *kref)
static void set_current_rng(struct hwrng *rng) static void set_current_rng(struct hwrng *rng)
{ {
BUG_ON(!mutex_is_locked(&rng_mutex)); BUG_ON(!mutex_is_locked(&rng_mutex));
drop_current_rng();
current_rng = rng; current_rng = rng;
} }
...@@ -315,7 +317,6 @@ static ssize_t hwrng_attr_current_store(struct device *dev, ...@@ -315,7 +317,6 @@ static ssize_t hwrng_attr_current_store(struct device *dev,
err = hwrng_init(rng); err = hwrng_init(rng);
if (err) if (err)
break; break;
drop_current_rng();
set_current_rng(rng); set_current_rng(rng);
err = 0; err = 0;
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册