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);
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;
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,
if (!priv->regs) {
dev_err(&pdev->dev, "ioremap failed");
ret = -ENOMEM;
- goto out_free_rng;
+ goto out;
}
clk_enable(clk);
out_clk_disable:
clk_disable(clk);
-out_free_rng:
- kfree(rng);
-out_free_priv:
- kfree(priv);
out:
return ret;
}
hwrng_unregister(rng);
clk_disable(priv->clk);
- kfree(priv);
- kfree(rng);
return 0;
}