Skip to contentSkip to conversation

backlight: lp855x: remove goto err_dev

PATCH Superseded Jingoo Han 2 participants 3 messages Aug 6, 2012 – Aug 7, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 3/3 backlight: lp855x: remove goto err_dev

This patch removes goto err_dev, which makes code a bit smaller.

Cc Milo(Woogyom) Kim <[email protected]>
Cc Richard Purdie <[email protected]>
---
 drivers/video/backlight/lp855x_bl.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/video/backlight/lp855x_bl.c +2 -3
index aa6d4f7..c629fa8 100644
@@ -272,14 +272,14 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
 	if (ret) {
 		dev_err(lp->dev, "i2c communication err: %d", ret);
 		if (mode == REGISTER_BASED)
-			goto err_dev;
+			return ret;
 	}
 
 	ret = lp855x_backlight_register(lp);
 	if (ret) {
 		dev_err(lp->dev,
 			"failed to register backlight. err: %d\n", ret);
-		goto err_dev;
+		return ret;
 	}
 
 	ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
@@ -293,7 +293,6 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
 
 err_sysfs:
 	lp855x_backlight_unregister(lp);
-err_dev:
 	return ret;
 }
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 1 line

This patch removes goto err_dev, which makes code a bit smaller.

Thanks !
IMO, goto statements are meaningful on _probe().
However, 'goto err_sysfs' also can be removed if the size of code is critical.

drivers/video/backlight/lp855x_bl.c | 12 ++++--------

 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/video/backlight/lp855x_bl.c +4 -8
index 72a0e0c..7e4198c 100644
@@ -268,29 +268,25 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
 	if (ret) {
 		dev_err(lp->dev, "i2c communication err: %d", ret);
 		if (mode == REGISTER_BASED)
-			goto err_dev;
+			return ret;
 	}
 
 	ret = lp855x_backlight_register(lp);
 	if (ret) {
 		dev_err(lp->dev,
 			"failed to register backlight. err: %d\n", ret);
-		goto err_dev;
+		return ret;
 	}
 
 	ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
 	if (ret) {
 		dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret);
-		goto err_sysfs;
+		lp855x_backlight_unregister(lp);
+		return ret;
 	}
 
 	backlight_update_status(lp->bl);
 	return 0;
-
-err_sysfs:
-	lp855x_backlight_unregister(lp);
-err_dev:
-	return ret;
 }
 
 static int __devexit lp855x_remove(struct i2c_client *cl)
Signature · 4 lines
1.7.2.5

Best Regards,
Milo
author
#2 lore raw
Quoted 6 lines · Milo
Quoted 2 lines

This patch removes goto err_dev, which makes code a bit smaller.

Thanks !
IMO, goto statements are meaningful on _probe().
However, 'goto err_sysfs' also can be removed if the size of code is critical.

OK, I will send v2 patch.

Best regards,
Jingoo Han

Quoted 47 lines

drivers/video/backlight/lp855x_bl.c | 12 ++++--------

 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/video/backlight/lp855x_bl.c +4 -9
index 72a0e0c..7e4198c 100644
@@ -268,29 +268,25 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
 	if (ret) {
 		dev_err(lp->dev, "i2c communication err: %d", ret);
 		if (mode == REGISTER_BASED)
-			goto err_dev;
+			return ret;
 	}
 
 	ret = lp855x_backlight_register(lp);
 	if (ret) {
 		dev_err(lp->dev,
 			"failed to register backlight. err: %d\n", ret);
-		goto err_dev;
+		return ret;
 	}
 
 	ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
 	if (ret) {
 		dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret);
-		goto err_sysfs;
+		lp855x_backlight_unregister(lp);
+		return ret;
 	}
 
 	backlight_update_status(lp->bl);
 	return 0;
-
-err_sysfs:
-	lp855x_backlight_unregister(lp);
-err_dev:
-	return ret;
 }
 
 static int __devexit lp855x_remove(struct i2c_client *cl)
--

1.7.2.5

Best Regards,
Milo