Skip to content

Commit

Permalink
hw_random: timeriomem_rng: Allow setting RNG quality from platform data
Browse files Browse the repository at this point in the history
When a hw_random device's quality is non-zero, it will automatically be
used to fill the kernel's entropy pool.  Since timeriomem_rng is used by
many different devices, the quality needs to be provided by platform
data or device tree.

Signed-off-by: Rick Altherr <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
mx-shift authored and herbertx committed Jun 1, 2017
1 parent b14c534 commit 284e763
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/char/hw_random/timeriomem-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,15 @@ static int timeriomem_rng_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "missing period\n");
return -EINVAL;
}

if (!of_property_read_u32(pdev->dev.of_node,
"quality", &i))
priv->rng_ops.quality = i;
else
priv->rng_ops.quality = 0;
} else {
period = pdata->period;
priv->rng_ops.quality = pdata->quality;
}

priv->period = ns_to_ktime(period * NSEC_PER_USEC);
Expand Down
3 changes: 3 additions & 0 deletions include/linux/timeriomem-rng.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ struct timeriomem_rng_data {

/* measures in usecs */
unsigned int period;

/* bits of entropy per 1024 bits read */
unsigned int quality;
};

0 comments on commit 284e763

Please sign in to comment.