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

hwrng: omap - reorder OMAP TRNG driver code

The newly added omap4 support in the driver was added without
consideration for building older configs. When building omap1_defconfig,
it resulted in:

drivers/char/hw_random/omap-rng.c:190:12: warning: 'omap4_rng_init' defined but not used [-Wunused-function]
drivers/char/hw_random/omap-rng.c:215:13: warning: 'omap4_rng_cleanup' defined but not used [-Wunused-function]
drivers/char/hw_random/omap-rng.c:251:20: warning: 'omap4_rng_irq' defined but not used [-Wunused-function]

Move the code around so it is grouped with its operations struct, which
for the omap4 case means also under the #ifdef CONFIG_OF, where it needs
to be.

Signed-off-by: Olof Johansson <olof@lixom.net>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Olof Johansson and committed by
Herbert Xu
a246968e f5e46260

+54 -54
+54 -54
drivers/char/hw_random/omap-rng.c
··· 140 140 __raw_writel(val, priv->base + priv->pdata->regs[reg]); 141 141 } 142 142 143 - static inline u32 omap2_rng_data_present(struct omap_rng_dev *priv) 144 - { 145 - return omap_rng_read(priv, RNG_STATUS_REG) ? 0 : 1; 146 - } 147 - 148 - static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv) 149 - { 150 - return omap_rng_read(priv, RNG_STATUS_REG) & RNG_REG_STATUS_RDY; 151 - } 152 - 153 143 static int omap_rng_data_present(struct hwrng *rng, int wait) 154 144 { 155 145 struct omap_rng_dev *priv; ··· 177 187 return data_size; 178 188 } 179 189 190 + static int omap_rng_init(struct hwrng *rng) 191 + { 192 + struct omap_rng_dev *priv; 193 + 194 + priv = (struct omap_rng_dev *)rng->priv; 195 + return priv->pdata->init(priv); 196 + } 197 + 198 + static void omap_rng_cleanup(struct hwrng *rng) 199 + { 200 + struct omap_rng_dev *priv; 201 + 202 + priv = (struct omap_rng_dev *)rng->priv; 203 + priv->pdata->cleanup(priv); 204 + } 205 + 206 + static struct hwrng omap_rng_ops = { 207 + .name = "omap", 208 + .data_present = omap_rng_data_present, 209 + .data_read = omap_rng_data_read, 210 + .init = omap_rng_init, 211 + .cleanup = omap_rng_cleanup, 212 + }; 213 + 214 + static inline u32 omap2_rng_data_present(struct omap_rng_dev *priv) 215 + { 216 + return omap_rng_read(priv, RNG_STATUS_REG) ? 0 : 1; 217 + } 218 + 219 + static int omap2_rng_init(struct omap_rng_dev *priv) 220 + { 221 + omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x1); 222 + return 0; 223 + } 224 + 225 + static void omap2_rng_cleanup(struct omap_rng_dev *priv) 226 + { 227 + omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x0); 228 + } 229 + 230 + static struct omap_rng_pdata omap2_rng_pdata = { 231 + .regs = (u16 *)reg_map_omap2, 232 + .data_size = OMAP2_RNG_OUTPUT_SIZE, 233 + .data_present = omap2_rng_data_present, 234 + .init = omap2_rng_init, 235 + .cleanup = omap2_rng_cleanup, 236 + }; 237 + 238 + #if defined(CONFIG_OF) 239 + static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv) 240 + { 241 + return omap_rng_read(priv, RNG_STATUS_REG) & RNG_REG_STATUS_RDY; 242 + } 243 + 180 244 static int omap4_rng_init(struct omap_rng_dev *priv) 181 245 { 182 246 u32 val; ··· 265 221 omap_rng_write(priv, RNG_CONFIG_REG, val); 266 222 } 267 223 268 - static int omap2_rng_init(struct omap_rng_dev *priv) 269 - { 270 - omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x1); 271 - return 0; 272 - } 273 - 274 - static void omap2_rng_cleanup(struct omap_rng_dev *priv) 275 - { 276 - omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x0); 277 - } 278 - 279 - static int omap_rng_init(struct hwrng *rng) 280 - { 281 - struct omap_rng_dev *priv; 282 - 283 - priv = (struct omap_rng_dev *)rng->priv; 284 - return priv->pdata->init(priv); 285 - } 286 - 287 - static void omap_rng_cleanup(struct hwrng *rng) 288 - { 289 - struct omap_rng_dev *priv; 290 - 291 - priv = (struct omap_rng_dev *)rng->priv; 292 - priv->pdata->cleanup(priv); 293 - } 294 - 295 224 static irqreturn_t omap4_rng_irq(int irq, void *dev_id) 296 225 { 297 226 struct omap_rng_dev *priv = dev_id; ··· 292 275 return IRQ_HANDLED; 293 276 } 294 277 295 - static struct hwrng omap_rng_ops = { 296 - .name = "omap", 297 - .data_present = omap_rng_data_present, 298 - .data_read = omap_rng_data_read, 299 - .init = omap_rng_init, 300 - .cleanup = omap_rng_cleanup, 301 - }; 302 - 303 - static struct omap_rng_pdata omap2_rng_pdata = { 304 - .regs = (u16 *)reg_map_omap2, 305 - .data_size = OMAP2_RNG_OUTPUT_SIZE, 306 - .data_present = omap2_rng_data_present, 307 - .init = omap2_rng_init, 308 - .cleanup = omap2_rng_cleanup, 309 - }; 310 - 311 - #if defined(CONFIG_OF) 312 278 static struct omap_rng_pdata omap4_rng_pdata = { 313 279 .regs = (u16 *)reg_map_omap4, 314 280 .data_size = OMAP4_RNG_OUTPUT_SIZE,