Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[HWRNG] omap: Minor updates

Minor cleanups to the OMAP RNG:

- Comment update re RNG status:
* yes, it works on 16xx; "rngtest" is quite happy
* it's fast enough that polling vs IRQ is a non-issue
- Get rid of BUG_ON
- Help GCC not be stupid about inlining (object code shrink)
- Remove "sparse" warning
- Cope with new hotplug rule requiring "platform:" modalias

And make the file header match kernel conventions.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

David Brownell and committed by
Herbert Xu
c49a7f18 584fffc8

+13 -13
+13 -13
drivers/char/hw_random/omap-rng.c
··· 1 1 /* 2 - * drivers/char/hw_random/omap-rng.c 3 - * 4 - * RNG driver for TI OMAP CPU family 2 + * omap-rng.c - RNG driver for TI OMAP CPU family 5 3 * 6 4 * Author: Deepak Saxena <dsaxena@plexity.net> 7 5 * ··· 13 15 * This file is licensed under the terms of the GNU General Public 14 16 * License version 2. This program is licensed "as is" without any 15 17 * warranty of any kind, whether express or implied. 16 - * 17 - * TODO: 18 - * 19 - * - Make status updated be interrupt driven so we don't poll 20 - * 21 18 */ 22 19 23 20 #include <linux/module.h> ··· 48 55 static struct clk *rng_ick; 49 56 static struct platform_device *rng_dev; 50 57 51 - static u32 omap_rng_read_reg(int reg) 58 + static inline u32 omap_rng_read_reg(int reg) 52 59 { 53 60 return __raw_readl(rng_base + reg); 54 61 } 55 62 56 - static void omap_rng_write_reg(int reg, u32 val) 63 + static inline void omap_rng_write_reg(int reg, u32 val) 57 64 { 58 65 __raw_writel(val, rng_base + reg); 59 66 } 60 67 61 - /* REVISIT: Does the status bit really work on 16xx? */ 62 68 static int omap_rng_data_present(struct hwrng *rng, int wait) 63 69 { 64 70 int data, i; ··· 66 74 data = omap_rng_read_reg(RNG_STAT_REG) ? 0 : 1; 67 75 if (data || !wait) 68 76 break; 77 + /* RNG produces data fast enough (2+ MBit/sec, even 78 + * during "rngtest" loads, that these delays don't 79 + * seem to trigger. We *could* use the RNG IRQ, but 80 + * that'd be higher overhead ... so why bother? 81 + */ 69 82 udelay(10); 70 83 } 71 84 return data; ··· 98 101 * A bit ugly, and it will never actually happen but there can 99 102 * be only one RNG and this catches any bork 100 103 */ 101 - BUG_ON(rng_dev); 104 + if (rng_dev) 105 + return -EBUSY; 102 106 103 107 if (cpu_is_omap24xx()) { 104 108 rng_ick = clk_get(NULL, "rng_ick"); ··· 122 124 return -EBUSY; 123 125 124 126 dev_set_drvdata(&pdev->dev, mem); 125 - rng_base = (u32 __iomem *)io_p2v(res->start); 127 + rng_base = (u32 __force __iomem *)io_p2v(res->start); 126 128 127 129 ret = hwrng_register(&omap_rng_ops); 128 130 if (ret) { ··· 180 182 181 183 #endif 182 184 185 + /* work with hotplug and coldplug */ 186 + MODULE_ALIAS("platform:omap_rng"); 183 187 184 188 static struct platform_driver omap_rng_driver = { 185 189 .driver = {