Skip to content

Commit

Permalink
nvmem: sunxi_sid: Read out SID for randomness without looping
Browse files Browse the repository at this point in the history
Since the reg_read callbacks already support arbitrary, but 4-byte
aligned. offsets and lengths into the SID, there is no need for another
for loop just to use it to read 1 byte at a time.

Read out the whole SID block in one go.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Chen-Yu Tsai authored and Greg Kroah-Hartman committed Apr 25, 2019
1 parent dd4c104 commit 9c4adfb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/nvmem/sunxi_sid.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
struct resource *res;
struct nvmem_device *nvmem;
struct sunxi_sid *sid;
int i, size;
int size;
char *randomness;
const struct sunxi_sid_cfg *cfg;

Expand Down Expand Up @@ -189,8 +189,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
if (!randomness)
return -ENOMEM;

for (i = 0; i < size; i++)
econfig.reg_read(sid, i, &randomness[i], 1);
econfig.reg_read(sid, 0, randomness, size);

add_device_randomness(randomness, size);
kfree(randomness);
Expand Down

0 comments on commit 9c4adfb

Please sign in to comment.