[2/2] i2c-tiny-usb: Return an error code only as a constant in i2c_tiny_usb_probe()

Message ID b6a54fdf-eb83-cf33-b3f9-d26d9be14d03@users.sourceforge.net
State New
Headers show
Series
  • i2c-tiny-usb: Adjustments for i2c_tiny_usb_probe()
Related show

Commit Message

SF Markus Elfring Feb. 1, 2018, 4:58 p.m.
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Feb 2018 17:45:21 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/busses/i2c-tiny-usb.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Patch

diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index e210e36df123..2416bb0d8a88 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -223,7 +223,6 @@  static int i2c_tiny_usb_probe(struct usb_interface *interface,
 			      const struct usb_device_id *id)
 {
 	struct i2c_tiny_usb *dev;
-	int retval = -ENOMEM;
 	u16 version;
 
 	dev_dbg(&interface->dev, "probing usb device\n");
@@ -231,7 +230,7 @@  static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	/* allocate memory for our device state and initialize it */
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
 	dev->interface = interface;
@@ -257,8 +256,8 @@  static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	if (usb_write(&dev->adapter, CMD_SET_DELAY, delay, 0, NULL, 0) != 0) {
 		dev_err(&dev->adapter.dev,
 			"failure setting delay to %dus\n", delay);
-		retval = -EIO;
-		goto error;
+		i2c_tiny_usb_free(dev);
+		return -EIO;
 	}
 
 	dev->adapter.dev.parent = &dev->interface->dev;
@@ -270,12 +269,6 @@  static int i2c_tiny_usb_probe(struct usb_interface *interface,
 	dev_info(&dev->adapter.dev, "connected i2c-tiny-usb device\n");
 
 	return 0;
-
- error:
-	if (dev)
-		i2c_tiny_usb_free(dev);
-
-	return retval;
 }
 
 static void i2c_tiny_usb_disconnect(struct usb_interface *interface)