Skip to contentSkip to conversation

hwrng: mxc-rnga - Remove unneeded goto label

PATCH In review Fabio Estevam 2 participants 5 messages Sep 12, 2015 – Sep 18, 2015

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/4 hwrng: mxc-rnga - Remove unneeded goto label

From: Fabio Estevam <[email protected]>

We can simplify the code by returning the error code immediately instead of jumping to a goto label.

---
 drivers/char/hw_random/mxc-rnga.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/char/hw_random/mxc-rnga.c +2 -5
index 6cbb72e..8803126 100644
@@ -160,13 +160,12 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 	mxc_rng->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(mxc_rng->clk)) {
 		dev_err(&pdev->dev, "Could not get rng_clk!\n");
-		err = PTR_ERR(mxc_rng->clk);
-		goto out;
+		return PTR_ERR(mxc_rng->clk);
 	}
 
 	err = clk_prepare_enable(mxc_rng->clk);
 	if (err)
-		goto out;
+		return err;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res);
@@ -187,8 +186,6 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 
 err_ioremap:
 	clk_disable_unprepare(mxc_rng->clk);
-
-out:
 	return err;
 }
 
Signature · 1 line
1.9.1
author reviewer
#1 lore raw

PATCH 2/4 hwrng: mxc-rnga - Remove uneeded initialization

From: Fabio Estevam <[email protected]>

There is no need to pre-initialize variable 'err' as this initial value will be overwritten later on.

---
 drivers/char/hw_random/mxc-rnga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/mxc-rnga.c +1 -1
index 8803126..c7380b8 100644
@@ -141,7 +141,7 @@ static void mxc_rnga_cleanup(struct hwrng *rng)
 
 static int __init mxc_rnga_probe(struct platform_device *pdev)
 {
-	int err = -ENODEV;
+	int err;
 	struct resource *res;
 	struct mxc_rng *mxc_rng;
 
Signature · 1 line
1.9.1
author reviewer
#2 lore raw

PATCH 3/4 hwrng: mxc-rnga - Remove unnecessary dev_info message

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

There is no need to print a message simply saying that a kernel driver has been registered, so remove it.

---
 drivers/char/hw_random/mxc-rnga.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/hw_random/mxc-rnga.c +0 -2
index c7380b8..ed2e3ef 100644
@@ -180,8 +180,6 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 		goto err_ioremap;
 	}
 
-	dev_info(&pdev->dev, "MXC RNGA Registered.\n");
-
 	return 0;
 
 err_ioremap:
Signature · 1 line
1.9.1
author reviewer
#3 lore raw

PATCH 4/4 hwrng: mxc-rnga - Use the preferred format for kzalloc

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

According to Documentation/CodingStyle:

"The preferred form for passing a size of a struct is the following:

	p = kmalloc(sizeof(*p), ...);"

,so do as suggested.

---
 drivers/char/hw_random/mxc-rnga.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/hw_random/mxc-rnga.c +1 -2
index ed2e3ef..4673622 100644
@@ -145,8 +145,7 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct mxc_rng *mxc_rng;
 
-	mxc_rng = devm_kzalloc(&pdev->dev, sizeof(struct mxc_rng),
-					GFP_KERNEL);
+	mxc_rng = devm_kzalloc(&pdev->dev, sizeof(*mxc_rng), GFP_KERNEL);
 	if (!mxc_rng)
 		return -ENOMEM;
 
Signature · 1 line
1.9.1