From patchwork Mon Sep 9 10:10:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19832 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95BA425A57 for ; Mon, 9 Sep 2013 10:10:37 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id jy13sf6041070veb.8 for ; Mon, 09 Sep 2013 03:10:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=qYrXuX9Lla1DAQHqQGP86QjrxGEUrdAqeSTJ55JX3Jk=; b=jPsnm4izW95a4PEz6fSWaY2K004KMmwZX12cUJpM5IY6UO4scHG5FrJccWfbmEuyp+ G7LsPCKqmpWy74q1MNOwRUQ04QTpvMpBeGa6doGZU9VhPbkbweAjqOiPbI8tAPnFaK5j Jtz3/KsY5Zc1crleFBe1IqYmZMLU/B4/+5tb1RyiHOy5jgIMXrOJgRXdOeWOcICHW3LW ICYwGRl5Pkena/kiNzd05rWmfdakitSZhBXIcxzrqw31IHUCyWiTwCQVOSLmDTVobIGb okcU2BMk/pYN1WildoQsk82k7mFdEJgcGEpmi57Pnn8gSYcO73ytyAlagsC3hdF0xNyz byjA== X-Received: by 10.236.26.202 with SMTP id c50mr5996454yha.14.1378721437226; Mon, 09 Sep 2013 03:10:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.104 with SMTP id lj8ls1897931qeb.11.gmail; Mon, 09 Sep 2013 03:10:37 -0700 (PDT) X-Received: by 10.220.174.200 with SMTP id u8mr16861486vcz.6.1378721437137; Mon, 09 Sep 2013 03:10:37 -0700 (PDT) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id s17si2980144vcu.14.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id p13so3794232vbe.33 for ; Mon, 09 Sep 2013 03:10:37 -0700 (PDT) X-Gm-Message-State: ALoCoQmZufJ4hljS6boHvCQD22UvZINcQu1gpqYrqwCZqIeKqmbHgKnBGFneHrUEm/6rxCUVZBZ8 X-Received: by 10.52.227.6 with SMTP id rw6mr14132311vdc.19.1378721437067; Mon, 09 Sep 2013 03:10:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp78979vcz; Mon, 9 Sep 2013 03:10:36 -0700 (PDT) X-Received: by 10.14.183.130 with SMTP id q2mr29313350eem.5.1378721436165; Mon, 09 Sep 2013 03:10:36 -0700 (PDT) Received: from mail-ea0-f175.google.com (mail-ea0-f175.google.com [209.85.215.175]) by mx.google.com with ESMTPS id x7si9519150eeo.307.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.175 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.175; Received: by mail-ea0-f175.google.com with SMTP id m14so2993085eaj.6 for ; Mon, 09 Sep 2013 03:10:35 -0700 (PDT) X-Received: by 10.14.224.7 with SMTP id w7mr183813eep.82.1378721435560; Mon, 09 Sep 2013 03:10:35 -0700 (PDT) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginmedia.com. [92.233.57.238]) by mx.google.com with ESMTPSA id m54sm20768068eex.2.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:35 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jic23@cam.ac.uk Cc: arnd@arndb.de, linus.walleij@linaro.org, denis.ciocca@st.com, linux-iio@vger.kernel.org, Lee Jones Subject: [PATCH 13/14] iio: sensors-core: st: Clean-up error handling in st_sensors_init_sensor() Date: Mon, 9 Sep 2013 11:10:09 +0100 Message-Id: <1378721410-30937-14-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378721410-30937-1-git-send-email-lee.jones@linaro.org> References: <1378721410-30937-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Strip out all those unnecessary gotos and just return the error right away. Aids to simplicity and reduces code. Signed-off-by: Lee Jones --- drivers/iio/common/st_sensors/st_sensors_core.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index eb261a5..05030e4 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -211,8 +211,7 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, if (sdata->sensor->drdy_irq.mask_int1 == 0) { dev_err(&indio_dev->dev, "DRDY on INT1 not available.\n"); - err = -EINVAL; - goto init_error; + return -EINVAL; } sdata->drdy_int_pin = 1; break; @@ -220,42 +219,39 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, if (sdata->sensor->drdy_irq.mask_int2 == 0) { dev_err(&indio_dev->dev, "DRDY on INT2 not available.\n"); - err = -EINVAL; - goto init_error; + return -EINVAL; } sdata->drdy_int_pin = 2; break; default: dev_err(&indio_dev->dev, "DRDY on pdata not valid.\n"); - err = -EINVAL; - goto init_error; + return -EINVAL; } err = st_sensors_set_enable(indio_dev, false); if (err < 0) - goto init_error; + return err; if (sdata->current_fullscale) { err = st_sensors_set_fullscale(indio_dev, sdata->current_fullscale->num); if (err < 0) - goto init_error; + return err; } else dev_info(&indio_dev->dev, "Full-scale not possible\n"); err = st_sensors_set_odr(indio_dev, sdata->odr); if (err < 0) - goto init_error; + return err; /* set BDU */ err = st_sensors_write_data_with_mask(indio_dev, sdata->sensor->bdu.addr, sdata->sensor->bdu.mask, true); if (err < 0) - goto init_error; + return err; err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS); -init_error: return err; } EXPORT_SYMBOL(st_sensors_init_sensor);