From patchwork Mon Sep 16 16:02:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 20368 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EAF9328E9B for ; Mon, 16 Sep 2013 16:02:59 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hf12sf4471051vcb.11 for ; Mon, 16 Sep 2013 09:02:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version: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=OfOypgX6J/fbdO2PnG6+klqaWqJrO6UW0W36sC14rDw=; b=LJ19z94yaxfUj2Cp5j0kjqAj5y9dnk6YLDEGwGimTGwM1pG5Byag+12EqZ0XIblT7d LM19xMppk+v1OQmYOMzOYG5Gf51NNtdJgIpxTt6HAL1BQce1LCuuTXjHkT9cnQvirlvt KwtR8aS1QdWKhWVEQdf+LX+Z3pdg/WpzmIOnIsBb7jnDoUV3Fx0869CUxInXgPZtA384 Nv4f1ugMnKULbAPcfQ5zxEAd7PeFnZ1GoGaIjxtGx/soV04NEx3QAweneFmlEXBEUB58 u1+0yiU94/0bitrdD377lpP0GDYxXJMNfFVk9a+y2K6IVj4+2Xqwm7ZR+9INQ9x+jnJy 1QOQ== X-Gm-Message-State: ALoCoQkGCdxbRjz4OAu7R7H/CGsHROphUDB/Y+cCCvofD1dK4Z4MhiXvlE3VZSw3E5v1ZPjb2thc X-Received: by 10.236.189.37 with SMTP id b25mr1098113yhn.48.1379347379715; Mon, 16 Sep 2013 09:02:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.200 with SMTP id i8ls2362492qed.65.gmail; Mon, 16 Sep 2013 09:02:59 -0700 (PDT) X-Received: by 10.220.16.73 with SMTP id n9mr1437890vca.24.1379347379514; Mon, 16 Sep 2013 09:02:59 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id ta3si7271529vcb.71.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.181 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.181; Received: by mail-ve0-f181.google.com with SMTP id oy12so3056829veb.26 for ; Mon, 16 Sep 2013 09:02:59 -0700 (PDT) X-Received: by 10.52.103.35 with SMTP id ft3mr23654753vdb.5.1379347379442; Mon, 16 Sep 2013 09:02:59 -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 u4csp104958vcz; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) X-Received: by 10.14.104.199 with SMTP id i47mr1440968eeg.85.1379347378505; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by mx.google.com with ESMTPS id x42si16802476eea.14.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:58 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.54 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.54; Received: by mail-ee0-f54.google.com with SMTP id e53so2172105eek.27 for ; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) X-Received: by 10.14.241.74 with SMTP id f50mr44317589eer.29.1379347377882; Mon, 16 Sep 2013 09:02:57 -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 z12sm43061275eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:57 -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/20] iio: magn-core: st: Clean up error handling in probe() Date: Mon, 16 Sep 2013 17:02:26 +0100 Message-Id: <1379347346-823-21-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1379347346-823-1-git-send-email-lee.jones@linaro.org> References: <1379347346-823-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.181 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: , Reduce the amount of those unnecessary goto calls, as in most cases we can simply return immediately. We also only call for the IRQ number once and use that value throughout. Signed-off-by: Lee Jones --- drivers/iio/magnetometer/st_magn_core.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index e8d2849..729c71a 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -348,8 +348,9 @@ static const struct iio_info magn_info = { int st_magn_common_probe(struct iio_dev *indio_dev, struct st_sensors_platform_data *pdata) { - int err; struct st_sensor_data *mdata = iio_priv(indio_dev); + int irq = mdata->get_irq_data_ready(indio_dev); + int err; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &magn_info; @@ -357,7 +358,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev, err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_magn_sensors), st_magn_sensors); if (err < 0) - goto st_magn_common_probe_error; + return err; mdata->num_data_channels = ST_MAGN_NUMBER_DATA_CHANNELS; mdata->multiread_bit = mdata->sensor->multi_read_bit; @@ -370,12 +371,12 @@ int st_magn_common_probe(struct iio_dev *indio_dev, err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) - goto st_magn_common_probe_error; + return err; - if (mdata->get_irq_data_ready(indio_dev) > 0) { + if (irq > 0) { err = st_magn_allocate_ring(indio_dev); if (err < 0) - goto st_magn_common_probe_error; + return err; err = st_sensors_allocate_trigger(indio_dev, NULL); if (err < 0) goto st_magn_probe_trigger_error; @@ -385,15 +386,15 @@ int st_magn_common_probe(struct iio_dev *indio_dev, if (err) goto st_magn_device_register_error; - return err; + return 0; st_magn_device_register_error: - if (mdata->get_irq_data_ready(indio_dev) > 0) + if (irq > 0) st_sensors_deallocate_trigger(indio_dev); st_magn_probe_trigger_error: - if (mdata->get_irq_data_ready(indio_dev) > 0) + if (irq > 0) st_magn_deallocate_ring(indio_dev); -st_magn_common_probe_error: + return err; } EXPORT_SYMBOL(st_magn_common_probe);