diff options
author | Johan Hovold <johan@kernel.org> | 2017-10-11 14:03:01 +0200 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2017-10-11 15:25:00 +0200 |
commit | 9eabd28e8baf3bd7cfa729e74c664eed060958bc (patch) | |
tree | aec5085a3d3a63e6c15179f79e12f3f707105a91 | |
parent | c1a357b68614620c976a94260749a979f9c46d29 (diff) | |
download | linux-stable-9eabd28e8baf3bd7cfa729e74c664eed060958bc.tar.gz linux-stable-9eabd28e8baf3bd7cfa729e74c664eed060958bc.tar.bz2 linux-stable-9eabd28e8baf3bd7cfa729e74c664eed060958bc.zip |
USB: serial: garmin_gps: simplify init-session logic
Clean up the somewhat convoluted init-session logic to improve
readability.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r-- | drivers/usb/serial/garmin_gps.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 5f7832adf6af..4f793c86978e 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -877,42 +877,33 @@ static int garmin_clear(struct garmin_data *garmin_data_p) static int garmin_init_session(struct usb_serial_port *port) { struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); - int status = 0; - int i = 0; + int status; + int i; - if (status == 0) { - usb_kill_urb(port->interrupt_in_urb); + usb_kill_urb(port->interrupt_in_urb); - status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); - if (status) { - dev_err(&port->dev, - "failed to submit interrupt urb: %d\n", - status); - } + status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); + if (status) { + dev_err(&port->dev, "failed to submit interrupt urb: %d\n", + status); + return status; } /* * using the initialization method from gpsbabel. See comments in * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() */ - if (status == 0) { - dev_dbg(&port->dev, "%s - starting session ...\n", __func__); - garmin_data_p->state = STATE_ACTIVE; - - for (i = 0; i < 3; i++) { - status = garmin_write_bulk(port, - GARMIN_START_SESSION_REQ, - sizeof(GARMIN_START_SESSION_REQ), 0); - - if (status < 0) - goto err_kill_urbs; - } + dev_dbg(&port->dev, "%s - starting session ...\n", __func__); + garmin_data_p->state = STATE_ACTIVE; - if (status > 0) - status = 0; + for (i = 0; i < 3; i++) { + status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, + sizeof(GARMIN_START_SESSION_REQ), 0); + if (status < 0) + goto err_kill_urbs; } - return status; + return 0; err_kill_urbs: usb_kill_anchored_urbs(&garmin_data_p->write_urbs); |