From patchwork Tue Sep 10 12:49:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19889 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 AB19A25EA3 for ; Tue, 10 Sep 2013 12:50:25 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id k10sf9529975iea.11 for ; Tue, 10 Sep 2013 05:50:25 -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=pd+XfzwCIuYOM527ejd7w8hwOY/QrDxL4go/LxIZO9g=; b=Kg0sTHjiUlQWL6UqMaAoKdh39lh6NShGMTVZPN+D6ZGm1QslqrSxRyoeTl4fmJ+6f4 xevjR70VLsRbXv7wAjm/HscvS7FgoNkOoogGvQ3S1UnBXMO5gF1rX0Kxbeg1F1C1k/kL 5QljibcsY5rGFM4WOAEHo0ZrIaJQ1RWJlz7EJdylV28l+yhmOqzAgsGwrO0SlgYnyBuu 56hjS1r0ijTjU3UeAUONv0815edhEQC2Rnbs8UdwfigjRACIocpYNWKZvQkwlUIqBR2i UDKrAOmJ/H2DtW4tpu8Y053biXv3nAMptdTONMpHNxL4GsdVHjRit3rSl3OBYH9eHgS/ s5qQ== X-Received: by 10.182.66.137 with SMTP id f9mr4542865obt.3.1378817425276; Tue, 10 Sep 2013 05:50:25 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.244 with SMTP id u20ls2041761qeq.74.gmail; Tue, 10 Sep 2013 05:50:25 -0700 (PDT) X-Received: by 10.220.91.16 with SMTP id k16mr1649857vcm.21.1378817425028; Tue, 10 Sep 2013 05:50:25 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id zw10si4390096vdb.70.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 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.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so4686801veb.9 for ; Tue, 10 Sep 2013 05:50:25 -0700 (PDT) X-Gm-Message-State: ALoCoQneJHVkKHdqf2DH9fC/z4Hjivq+MjA/8X/JgOkoO5JcjlVdYbu8oiFboAM3iuzWudCFXegV X-Received: by 10.52.231.5 with SMTP id tc5mr342220vdc.36.1378817424938; Tue, 10 Sep 2013 05:50:24 -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 u4csp19418vcz; Tue, 10 Sep 2013 05:50:24 -0700 (PDT) X-Received: by 10.14.246.11 with SMTP id p11mr39398481eer.9.1378817420983; Tue, 10 Sep 2013 05:50:20 -0700 (PDT) Received: from mail-ea0-f182.google.com (mail-ea0-f182.google.com [209.85.215.182]) by mx.google.com with ESMTPS id x42si14832975eea.194.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.182; Received: by mail-ea0-f182.google.com with SMTP id o10so3942582eaj.27 for ; Tue, 10 Sep 2013 05:50:20 -0700 (PDT) X-Received: by 10.14.241.74 with SMTP id f50mr39250235eer.29.1378817420459; Tue, 10 Sep 2013 05:50:20 -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:20 -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 34/38] iio: gyro-core: st: Clean up error handling in probe() Date: Tue, 10 Sep 2013 13:49:35 +0100 Message-Id: <1378817379-8238-35-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.178 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/gyro/st_gyro_core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index e13c2b0..09e24f9 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -305,8 +305,9 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = { int st_gyro_common_probe(struct iio_dev *indio_dev, struct st_sensors_platform_data *pdata) { - int err; struct st_sensor_data *gdata = iio_priv(indio_dev); + int irq = gdata->get_irq_data_ready(indio_dev); + int err; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &gyro_info; @@ -314,7 +315,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_gyro_sensors), st_gyro_sensors); if (err < 0) - goto st_gyro_common_probe_error; + return err; gdata->num_data_channels = ST_GYRO_NUMBER_DATA_CHANNELS; gdata->multiread_bit = gdata->sensor->multi_read_bit; @@ -327,12 +328,12 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) - goto st_gyro_common_probe_error; + return err; - if (gdata->get_irq_data_ready(indio_dev) > 0) { + if (irq > 0) { err = st_gyro_allocate_ring(indio_dev); if (err < 0) - goto st_gyro_common_probe_error; + return err; err = st_sensors_allocate_trigger(indio_dev, ST_GYRO_TRIGGER_OPS); @@ -341,18 +342,16 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, } err = iio_device_register(indio_dev); - if (err) + if (err && irq > 0) goto st_gyro_device_register_error; return err; st_gyro_device_register_error: - if (gdata->get_irq_data_ready(indio_dev) > 0) - st_sensors_deallocate_trigger(indio_dev); + st_sensors_deallocate_trigger(indio_dev); st_gyro_probe_trigger_error: - if (gdata->get_irq_data_ready(indio_dev) > 0) - st_gyro_deallocate_ring(indio_dev); -st_gyro_common_probe_error: + st_gyro_deallocate_ring(indio_dev); + return err; } EXPORT_SYMBOL(st_gyro_common_probe);