hw_random: bcm63xx-rng: misc cleanups and reorg
Subsystems (3)
cover hw_random: bcm63xx-rng: misc cleanups and reorg
Hi,
This patchset prepares the driver to be built on non-MIPS bcm63xx architectures such as the ARM bcm63xx variants, thanks!
Although patch 3 touches a MIPS header file, there should be little to no conflicts there if all patches went through the hw_random tree (is there one?)
Thanks!
Florian Fainelli (4):
hw_random: bcm63xx-rng: drop bcm_{readl,writel} macros
hw_random: bcm63xx-rng: move register definitions to driver
MIPS: BCM63xx: remove RSET_RNG register definitions
hw_random: bcm63xx-rng: use devm_* helpers
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 14 -------- drivers/char/hw_random/bcm63xx-rng.c | 43 +++++++++++------------ 2 files changed, 21 insertions(+), 36 deletions(-)
Signature · 1 line
2.1.0
PATCH 2/4 hw_random: bcm63xx-rng: move register definitions to driver
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h contains the register definitions for this random number generator block, incorporate these register definitions directly into the bcm63xx-rng driver so we do not rely on this header to be provided.
--- drivers/char/hw_random/bcm63xx-rng.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/char/hw_random/bcm63xx-rng.c +9 -1
@@ -13,7 +13,15 @@#include <linux/platform_device.h> #include <linux/hw_random.h> -#include <bcm63xx_regs.h> +#define RNG_CTRL 0x00 +#define RNG_EN (1 << 0) + +#define RNG_STAT 0x04 +#define RNG_AVAIL_MASK (0xff000000) + +#define RNG_DATA 0x08 +#define RNG_THRES 0x0c +#define RNG_MASK 0x10struct bcm63xx_rng_priv {struct clk *clk;
Signature · 1 line
2.1.0
PATCH 3/4 MIPS: BCM63xx: remove RSET_RNG register definitions
In reply to Florian FainelliNow that these definitions have been moved to drivers/char/hw_random/bcm63xx-rng.c where they belong to make the driver standalone, we can safely remove these definitions from bcm63xx_regs.h.
--- arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 14 -------------- 1 file changed, 14 deletions(-)
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h +0 -14
@@ -1259,20 +1259,6 @@#define M2M_DSTID_REG (x) ((x) * 0x40 + 0x18)/************************************************************************* -* _REG relative to RSET_RNG -*************************************************************************/ - -#define RNG_CTRL 0x00 -#define RNG_EN (1 << 0) - -#define RNG_STAT 0x04 -#define RNG_AVAIL_MASK (0xff000000) - -#define RNG_DATA 0x08 -#define RNG_THRES 0x0c -#define RNG_MASK 0x10 - -/************************************************************************* * _REG relative to RSET_SPI *************************************************************************/
Signature · 1 line
2.1.0
PATCH 4/4 hw_random: bcm63xx-rng: use devm_* helpers
In reply to Florian FainelliSimplify the driver's probe function and error handling by using the device managed allocators, while at it, drop the redundant "out of memory" messages since these are already printed by the allocator.
--- drivers/char/hw_random/bcm63xx-rng.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/char/hw_random/bcm63xx-rng.c +6 -14
@@ -83,18 +83,16 @@ static int bcm63xx_rng_probe(struct platform_device *pdev) goto out; } - priv =kzalloc (sizeof (*priv),GFP_KERNEL ); + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );if (!priv) { -dev_err (&pdev->dev,"no memory for private structure\n" ); ret = -ENOMEM ; goto out; } - rng =kzalloc (sizeof (*rng),GFP_KERNEL ); + rng =devm_kzalloc (&pdev->dev,sizeof (*rng),GFP_KERNEL );if (!rng) { -dev_err (&pdev->dev,"no memory for rng structure\n" ); ret = -ENOMEM ; - goto out_free_priv; + goto out; }platform_set_drvdata (pdev, rng);
@@ -109,7 +107,7 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)if (IS_ERR (clk)) {dev_err (&pdev->dev,"no clock for device\n" ); ret =PTR_ERR (clk); - goto out_free_rng; + goto out; } priv->clk = clk;
@@ -118,7 +116,7 @@ static int bcm63xx_rng_probe(struct platform_device *pdev) resource_size(r), pdev->name)) {dev_err (&pdev->dev,"request mem failed" ); ret = -ENOMEM ; - goto out_free_rng; + goto out; } priv->regs = devm_ioremap_nocache(&pdev->dev, r->start,
@@ -126,7 +124,7 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)if (!priv->regs) {dev_err (&pdev->dev,"ioremap failed" ); ret = -ENOMEM ; - goto out_free_rng; + goto out; }clk_enable (clk);
@@ -143,10 +141,6 @@ static int bcm63xx_rng_probe(struct platform_device *pdev) out_clk_disable:clk_disable (clk); -out_free_rng: -kfree (rng); -out_free_priv: -kfree (priv); out:return ret; }
@@ -158,8 +152,6 @@ static int bcm63xx_rng_remove(struct platform_device *pdev)hwrng_unregister (rng);clk_disable (priv->clk); -kfree (priv); -kfree (rng);return 0 ; }
Signature · 1 line
2.1.0
PATCH 1/4 hw_random: bcm63xx-rng: drop bcm_{readl,writel} macros
In reply to Florian Fainellibcm_{readl,writel} macros expand to __raw_{readl,writel}, use these directly such that we do not rely on the platform to provide these for us. As a result, we no longer use bcm63xx_io.h, so remove that inclusion too.
--- drivers/char/hw_random/bcm63xx-rng.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/char/hw_random/bcm63xx-rng.c +6 -7
@@ -13,7 +13,6 @@#include <linux/platform_device.h> #include <linux/hw_random.h> -#include <bcm63xx_io.h> #include <bcm63xx_regs.h> struct bcm63xx_rng_priv {
@@ -28,9 +27,9 @@ static int bcm63xx_rng_init(struct hwrng *rng)struct bcm63xx_rng_priv *priv =to_rng_priv (rng);u32 val; - val =bcm_readl (priv->regs +RNG_CTRL ); + val =__raw_readl (priv->regs +RNG_CTRL ); val |=RNG_EN ; -bcm_writel (val, priv->regs +RNG_CTRL ); +__raw_writel (val, priv->regs +RNG_CTRL );return 0 ; }
@@ -40,23 +39,23 @@ static void bcm63xx_rng_cleanup(struct hwrng *rng)struct bcm63xx_rng_priv *priv =to_rng_priv (rng);u32 val; - val =bcm_readl (priv->regs +RNG_CTRL ); + val =__raw_readl (priv->regs +RNG_CTRL ); val &= ~RNG_EN ; -bcm_writel (val, priv->regs +RNG_CTRL ); +__raw_writel (val, priv->regs +RNG_CTRL ); }static int bcm63xx_rng_data_present (struct hwrng *rng,int wait) {struct bcm63xx_rng_priv *priv =to_rng_priv (rng); -return bcm_readl (priv->regs +RNG_STAT ) &RNG_AVAIL_MASK ; +return __raw_readl (priv->regs +RNG_STAT ) &RNG_AVAIL_MASK ; }static int bcm63xx_rng_data_read (struct hwrng *rng,u32 *data) {struct bcm63xx_rng_priv *priv =to_rng_priv (rng); - *data =bcm_readl (priv->regs +RNG_DATA ); + *data =__raw_readl (priv->regs +RNG_DATA );return 4 ; }
Signature · 1 line
2.1.0
Re: [PATCH 2/4] hw_random: bcm63xx-rng: move register definitions to driver
In reply to Florian FainelliHello.
Quoted 15 lines · Florian Fainelli
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.hcontains the register definitions for this random number generator block, incorporate these register definitions directly into the bcm63xx-rng driver so we do not rely on this header to be provided.Signed-off-by Florian Fainelli <[email protected]>--- drivers/char/hw_random/bcm63xx-rng.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/char/hw_random/bcm63xx-rng.c +0
-0
drivers/char/hw_random/bcm63xx-rng.c line 20
Quoted 9 lines
drivers/char/hw_random/bcm63xx-rng.c +5
-1@@ -13,7 +13,15 @@#include <linux/platform_device.h> #include <linux/hw_random.h> -#include <bcm63xx_regs.h> +#define RNG_CTRL 0x00 +#define RNG_EN (1 << 0) + +#define RNG_STAT 0x04 +#define RNG_AVAIL_MASK (0xff000000)
Parens not needed here.
WBR, Sergei
Herbert Xu
maintainerQuoted 7 lines · Florian Fainelli
Hi,
This patchset prepares the driver to be built on non-MIPS bcm63xx architectures such as the ARM bcm63xx variants, thanks!
Although patch 3 touches a MIPS header file, there should be little to no conflicts there if all patches went through the
hw_randomtree (is there one?)
All applied. Thanks!
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt