aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2015-02-16 21:09:16 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2015-03-01 05:02:26 -0500
commit0052a65413f006663e0d7fbfc886ea5bbd8f197f (patch)
tree56c854a7afc6487e1a40423cf2e14ea63f5c7aec /drivers/char
parentaeb9624f96581732b1ffd21af967375839ba227d (diff)
hwrng: bcm63xx - use devm_* helpers
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> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/bcm63xx-rng.c20
1 files 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)
83 goto out; 83 goto out;
84 } 84 }
85 85
86 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 86 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
87 if (!priv) { 87 if (!priv) {
88 dev_err(&pdev->dev, "no memory for private structure\n");
89 ret = -ENOMEM; 88 ret = -ENOMEM;
90 goto out; 89 goto out;
91 } 90 }
92 91
93 rng = kzalloc(sizeof(*rng), GFP_KERNEL); 92 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL);
94 if (!rng) { 93 if (!rng) {
95 dev_err(&pdev->dev, "no memory for rng structure\n");
96 ret = -ENOMEM; 94 ret = -ENOMEM;
97 goto out_free_priv; 95 goto out;
98 } 96 }
99 97
100 platform_set_drvdata(pdev, rng); 98 platform_set_drvdata(pdev, rng);
@@ -109,7 +107,7 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
109 if (IS_ERR(clk)) { 107 if (IS_ERR(clk)) {
110 dev_err(&pdev->dev, "no clock for device\n"); 108 dev_err(&pdev->dev, "no clock for device\n");
111 ret = PTR_ERR(clk); 109 ret = PTR_ERR(clk);
112 goto out_free_rng; 110 goto out;
113 } 111 }
114 112
115 priv->clk = clk; 113 priv->clk = clk;
@@ -118,7 +116,7 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
118 resource_size(r), pdev->name)) { 116 resource_size(r), pdev->name)) {
119 dev_err(&pdev->dev, "request mem failed"); 117 dev_err(&pdev->dev, "request mem failed");
120 ret = -ENOMEM; 118 ret = -ENOMEM;
121 goto out_free_rng; 119 goto out;
122 } 120 }
123 121
124 priv->regs = devm_ioremap_nocache(&pdev->dev, r->start, 122 priv->regs = devm_ioremap_nocache(&pdev->dev, r->start,
@@ -126,7 +124,7 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
126 if (!priv->regs) { 124 if (!priv->regs) {
127 dev_err(&pdev->dev, "ioremap failed"); 125 dev_err(&pdev->dev, "ioremap failed");
128 ret = -ENOMEM; 126 ret = -ENOMEM;
129 goto out_free_rng; 127 goto out;
130 } 128 }
131 129
132 clk_enable(clk); 130 clk_enable(clk);
@@ -143,10 +141,6 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
143 141
144out_clk_disable: 142out_clk_disable:
145 clk_disable(clk); 143 clk_disable(clk);
146out_free_rng:
147 kfree(rng);
148out_free_priv:
149 kfree(priv);
150out: 144out:
151 return ret; 145 return ret;
152} 146}
@@ -158,8 +152,6 @@ static int bcm63xx_rng_remove(struct platform_device *pdev)
158 152
159 hwrng_unregister(rng); 153 hwrng_unregister(rng);
160 clk_disable(priv->clk); 154 clk_disable(priv->clk);
161 kfree(priv);
162 kfree(rng);
163 155
164 return 0; 156 return 0;
165} 157}