* [PATCH 1/4] hw_random: bcm63xx-rng: drop bcm_{readl,writel} macros
2015-02-17 2:09 [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Florian Fainelli
@ 2015-02-17 2:09 ` Florian Fainelli
2015-02-17 2:09 ` [PATCH 2/4] hw_random: bcm63xx-rng: move register definitions to driver Florian Fainelli
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2015-02-17 2:09 UTC (permalink / raw)
To: linux-mips
Cc: linux-crypto, linux-kernel, mpm, herbert, wsa, cernekee,
Florian Fainelli
bcm_{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.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/char/hw_random/bcm63xx-rng.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/char/hw_random/bcm63xx-rng.c b/drivers/char/hw_random/bcm63xx-rng.c
index ba6a65ac023b..ed9b28b35a39 100644
--- a/drivers/char/hw_random/bcm63xx-rng.c
+++ b/drivers/char/hw_random/bcm63xx-rng.c
@@ -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;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] hw_random: bcm63xx-rng: move register definitions to driver
2015-02-17 2:09 [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Florian Fainelli
2015-02-17 2:09 ` [PATCH 1/4] hw_random: bcm63xx-rng: drop bcm_{readl,writel} macros Florian Fainelli
@ 2015-02-17 2:09 ` Florian Fainelli
2015-02-17 11:35 ` Sergei Shtylyov
2015-02-17 2:09 ` [PATCH 3/4] MIPS: BCM63xx: remove RSET_RNG register definitions Florian Fainelli
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Florian Fainelli @ 2015-02-17 2:09 UTC (permalink / raw)
To: linux-mips
Cc: linux-crypto, linux-kernel, mpm, herbert, wsa, cernekee,
Florian Fainelli
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.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/char/hw_random/bcm63xx-rng.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/char/hw_random/bcm63xx-rng.c b/drivers/char/hw_random/bcm63xx-rng.c
index ed9b28b35a39..c7f3af852599 100644
--- a/drivers/char/hw_random/bcm63xx-rng.c
+++ b/drivers/char/hw_random/bcm63xx-rng.c
@@ -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 0x10
struct bcm63xx_rng_priv {
struct clk *clk;
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] hw_random: bcm63xx-rng: move register definitions to driver
2015-02-17 2:09 ` [PATCH 2/4] hw_random: bcm63xx-rng: move register definitions to driver Florian Fainelli
@ 2015-02-17 11:35 ` Sergei Shtylyov
0 siblings, 0 replies; 7+ messages in thread
From: Sergei Shtylyov @ 2015-02-17 11:35 UTC (permalink / raw)
To: Florian Fainelli, linux-mips
Cc: linux-crypto, linux-kernel, mpm, herbert, wsa, cernekee
Hello.
On 2/17/2015 5:09 AM, Florian Fainelli wrote:
> 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.
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> drivers/char/hw_random/bcm63xx-rng.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
> diff --git a/drivers/char/hw_random/bcm63xx-rng.c b/drivers/char/hw_random/bcm63xx-rng.c
> index ed9b28b35a39..c7f3af852599 100644
> --- a/drivers/char/hw_random/bcm63xx-rng.c
> +++ b/drivers/char/hw_random/bcm63xx-rng.c
> @@ -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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/4] MIPS: BCM63xx: remove RSET_RNG register definitions
2015-02-17 2:09 [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Florian Fainelli
2015-02-17 2:09 ` [PATCH 1/4] hw_random: bcm63xx-rng: drop bcm_{readl,writel} macros Florian Fainelli
2015-02-17 2:09 ` [PATCH 2/4] hw_random: bcm63xx-rng: move register definitions to driver Florian Fainelli
@ 2015-02-17 2:09 ` Florian Fainelli
2015-02-17 2:09 ` [PATCH 4/4] hw_random: bcm63xx-rng: use devm_* helpers Florian Fainelli
2015-03-01 10:03 ` [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Herbert Xu
4 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2015-02-17 2:09 UTC (permalink / raw)
To: linux-mips
Cc: linux-crypto, linux-kernel, mpm, herbert, wsa, cernekee,
Florian Fainelli
Now 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.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
index 4794067cb5a7..5035f09c5427 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
@@ -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
*************************************************************************/
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] hw_random: bcm63xx-rng: use devm_* helpers
2015-02-17 2:09 [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Florian Fainelli
` (2 preceding siblings ...)
2015-02-17 2:09 ` [PATCH 3/4] MIPS: BCM63xx: remove RSET_RNG register definitions Florian Fainelli
@ 2015-02-17 2:09 ` Florian Fainelli
2015-03-01 10:03 ` [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Herbert Xu
4 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2015-02-17 2:09 UTC (permalink / raw)
To: linux-mips
Cc: linux-crypto, linux-kernel, mpm, herbert, wsa, cernekee,
Florian Fainelli
Simplify 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.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/char/hw_random/bcm63xx-rng.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/drivers/char/hw_random/bcm63xx-rng.c b/drivers/char/hw_random/bcm63xx-rng.c
index c7f3af852599..27da00f68c8f 100644
--- a/drivers/char/hw_random/bcm63xx-rng.c
+++ b/drivers/char/hw_random/bcm63xx-rng.c
@@ -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;
}
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg
2015-02-17 2:09 [PATCH 0/4] hw_random: bcm63xx-rng: misc cleanups and reorg Florian Fainelli
` (3 preceding siblings ...)
2015-02-17 2:09 ` [PATCH 4/4] hw_random: bcm63xx-rng: use devm_* helpers Florian Fainelli
@ 2015-03-01 10:03 ` Herbert Xu
4 siblings, 0 replies; 7+ messages in thread
From: Herbert Xu @ 2015-03-01 10:03 UTC (permalink / raw)
To: Florian Fainelli
Cc: linux-mips, linux-crypto, linux-kernel, mpm, wsa, cernekee
On Mon, Feb 16, 2015 at 06:09:12PM -0800, Florian Fainelli wrote:
> 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?)
All applied. Thanks!
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 7+ messages in thread