From patchwork Tue Sep 10 12:49:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19890 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 93C9E246A4 for ; Tue, 10 Sep 2013 12:50:27 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id k10sf9553860iea.3 for ; Tue, 10 Sep 2013 05:50:27 -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=Iy+8m+dirQjVl7kQNLVQp0KZPF8Pjkzzb5EUJo+rZ18=; b=eERwviEQySZddFZLPBJjZSgFFUsNj/QuWgRrVv8bYSBnWx8N+NNQ/5uMn2rTJh67gX W2/nZuyfMVjcD9xyGbZehuRPSsZ1wD7uR8vh0cqxZsqEEoz3Ihr08X/rmVjv/M9XP2y7 q+FfbWIy2FeqLj+M1zhxn0atq89PQxhRa7d2+IxsGYhpivHXHyMsaJ5EuIJOiRF1rbTO aP3UhmFx7qL6EoV0Clkf9gFapWA7eLHDKvTmMl/1ZyXmb+EbHEdZ4yWH+VOIA8DceBUo UrMqTKqD+6VrM60QFwTl3ZsP8bDOoHISdNfOLj3ULTyYdBA8SHNDK4hpQZYBj4+5Jr2D TExw== X-Received: by 10.182.98.230 with SMTP id el6mr4309806obb.25.1378817427091; Tue, 10 Sep 2013 05:50:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.161 with SMTP id kv1ls2269667qeb.10.gmail; Tue, 10 Sep 2013 05:50:26 -0700 (PDT) X-Received: by 10.221.32.133 with SMTP id sk5mr698570vcb.27.1378817426869; Tue, 10 Sep 2013 05:50:26 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id b5si4401914vel.62.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id gf12so4858828vcb.8 for ; Tue, 10 Sep 2013 05:50:26 -0700 (PDT) X-Gm-Message-State: ALoCoQlnkSrM6+9uAg04o4bl/aleX+vkATSzstF3kbScXqrt7Tcu0T4c+tpz5RdWv3IaBNA9Lhg3 X-Received: by 10.58.108.74 with SMTP id hi10mr23488563veb.14.1378817426798; Tue, 10 Sep 2013 05:50:26 -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 u4csp19421vcz; Tue, 10 Sep 2013 05:50:26 -0700 (PDT) X-Received: by 10.15.75.73 with SMTP id k49mr38545526eey.36.1378817422877; Tue, 10 Sep 2013 05:50:22 -0700 (PDT) Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by mx.google.com with ESMTPS id x7si14842097eeo.157.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:22 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.46 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.46; Received: by mail-ee0-f46.google.com with SMTP id c13so3436696eek.33 for ; Tue, 10 Sep 2013 05:50:22 -0700 (PDT) X-Received: by 10.14.172.133 with SMTP id t5mr38469587eel.35.1378817422226; Tue, 10 Sep 2013 05:50:22 -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:21 -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 36/38] iio: magn-core: st: Clean up error handling in probe() Date: Tue, 10 Sep 2013 13:49:37 +0100 Message-Id: <1378817379-8238-37-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.220.177 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 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index e8d2849..c252659 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,30 +371,28 @@ 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; } err = iio_device_register(indio_dev); - if (err) + if (err && irq > 0) goto st_magn_device_register_error; return err; st_magn_device_register_error: - if (mdata->get_irq_data_ready(indio_dev) > 0) - st_sensors_deallocate_trigger(indio_dev); + st_sensors_deallocate_trigger(indio_dev); st_magn_probe_trigger_error: - if (mdata->get_irq_data_ready(indio_dev) > 0) - st_magn_deallocate_ring(indio_dev); -st_magn_common_probe_error: + st_magn_deallocate_ring(indio_dev); + return err; } EXPORT_SYMBOL(st_magn_common_probe);