From patchwork Tue Sep 10 12:49:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19875 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 29E5C246A4 for ; Tue, 10 Sep 2013 12:50:12 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id i4sf29749940oah.11 for ; Tue, 10 Sep 2013 05:50:11 -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=23fAlckeFnLp9Z0krTfO79DrT94SAHliQr9RmZIOrTM=; b=ZXt9Aea4d5oULgk7q/xzMPnLMnnKVyo15TSEjUwTLKFLSDEwdPkbDGOd9eqOHdzzse 1Xn6mGLFmNjSbfkfEDfka0Opu5YZn84t9bqtIXpE79+nH/2IfRKZWmJ3g3LtVScw6obo Tdh6cINXMuhvd20nbIEVqRUPoSEWTPVeZSJ7h6FXF8JV5cUiV+a3M6pOB6b0tcc2PPTB FVl8sWGliKvsB2am+QeGPzGbeSmWUZ0yEoadnM4Q4zeQG4UNep8JLfn6boLE1hjhB5Nr I3maFupy2hwb63KU94Vz6/sLFFeh8+91Tz6tiuDtzfKZ9OVYOry3QFGqsg80I+EviXUZ IwXQ== X-Received: by 10.182.16.199 with SMTP id i7mr632727obd.42.1378817411692; Tue, 10 Sep 2013 05:50:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.244 with SMTP id l20ls507971qej.98.gmail; Tue, 10 Sep 2013 05:50:11 -0700 (PDT) X-Received: by 10.58.207.103 with SMTP id lv7mr69999vec.33.1378817411344; Tue, 10 Sep 2013 05:50:11 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id tj1si4384766vdc.105.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jx11so4442168veb.7 for ; Tue, 10 Sep 2013 05:50:11 -0700 (PDT) X-Gm-Message-State: ALoCoQnli70E7YY5fLGmFYlvZuZ9ukzKjjGfYiP9AUOjgtzzJ+XVdBkIAQCvYuexGn6tvZiHC6Q8 X-Received: by 10.220.74.69 with SMTP id t5mr10466536vcj.18.1378817411261; Tue, 10 Sep 2013 05:50:11 -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 u4csp19399vcz; Tue, 10 Sep 2013 05:50:10 -0700 (PDT) X-Received: by 10.15.67.131 with SMTP id u3mr38610007eex.34.1378817407897; Tue, 10 Sep 2013 05:50:07 -0700 (PDT) Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by mx.google.com with ESMTPS id t9si14821251eeh.243.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:07 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.49 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.49; Received: by mail-ee0-f49.google.com with SMTP id d41so3826863eek.22 for ; Tue, 10 Sep 2013 05:50:07 -0700 (PDT) X-Received: by 10.14.183.2 with SMTP id p2mr13060999eem.44.1378817407107; Tue, 10 Sep 2013 05:50:07 -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 z12sm31123277eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:06 -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 20/38] iio: sensors-core: st: Clean-up error handling in st_sensors_init_sensor() Date: Tue, 10 Sep 2013 13:49:21 +0100 Message-Id: <1378817379-8238-21-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378817379-8238-1-git-send-email-lee.jones@linaro.org> References: <1378817379-8238-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.128.176 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 b86cad2..8c4c54c 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -208,8 +208,7 @@ int st_sensors_set_drdy_int_pin(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; @@ -217,15 +216,13 @@ int st_sensors_set_drdy_int_pin(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; } return 0; @@ -244,29 +241,28 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, 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);