aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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}