From patchwork Tue Sep 10 12:49:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19886 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 27EC826116 for ; Tue, 10 Sep 2013 12:50:23 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id k10sf9553472iea.3 for ; Tue, 10 Sep 2013 05:50:22 -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=STHcEglKQMmyUluMRRKYr4VtYaB0sL1JOZPx3+UG1Lk=; b=HGsFpBtuxGea1p2WAbqInpERQPij8dmnv1qLKnDhPyShWkVABkmI4CYxIyRXiZyd5x Oh2fho6X2Yj1jiHR6k9B+ZwGmQTh+TgzuRaZicsoP0Xf7uICnu7aU1zs9xifBoOIgWcu Fwn6LhmLkka/q9wEJVbl6KSOH5FVgOaY7thKVN2siE6WUmFcYWMv46d9CEg2/JjSzaNC 4UEuaXuDOSEcX3+BNA/DlefSBZKmZpf45ygxxp54BH/2vs0HQnTUrDQO05hCMQHOPFMX Yiu0yN3e6ggdgXzCt+l1nQvKEpcBERrPAf5VYRF0GAmqp3ly4t6kIp/ttRJW3iSFAb0c /gmQ== X-Received: by 10.182.95.68 with SMTP id di4mr4465036obb.4.1378817422698; Tue, 10 Sep 2013 05:50:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.209 with SMTP id x17ls243886qeu.83.gmail; Tue, 10 Sep 2013 05:50:22 -0700 (PDT) X-Received: by 10.220.164.202 with SMTP id f10mr1133454vcy.25.1378817422348; Tue, 10 Sep 2013 05:50:22 -0700 (PDT) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id f8si4404027vec.47.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: 209.85.212.54 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.54; Received: by mail-vb0-f54.google.com with SMTP id q14so5027616vbe.13 for ; Tue, 10 Sep 2013 05:50:22 -0700 (PDT) X-Gm-Message-State: ALoCoQnB3u4pd6y3Ul2rvkVlVYGYerg115FIHqsgPH6p5WxjPsEQ8XVa6paypPL8ZlOGdiBXY9W3 X-Received: by 10.58.211.227 with SMTP id nf3mr7164103vec.20.1378817422244; Tue, 10 Sep 2013 05:50:22 -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 u4csp19413vcz; Tue, 10 Sep 2013 05:50:21 -0700 (PDT) X-Received: by 10.14.99.193 with SMTP id x41mr4116971eef.52.1378817418569; Tue, 10 Sep 2013 05:50:18 -0700 (PDT) Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com [74.125.83.52]) by mx.google.com with ESMTPS id x42si14844460eel.146.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:18 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.52 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.52; Received: by mail-ee0-f52.google.com with SMTP id c41so3805224eek.39 for ; Tue, 10 Sep 2013 05:50:18 -0700 (PDT) X-Received: by 10.14.172.133 with SMTP id t5mr38469116eel.35.1378817417992; Tue, 10 Sep 2013 05:50:17 -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:17 -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 31/38] iio: accel-core: st: Clean up error handling in probe() Date: Tue, 10 Sep 2013 13:49:32 +0100 Message-Id: <1378817379-8238-32-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.212.54 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/accel/st_accel_core.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 1458343..ea62291 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -452,8 +452,9 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { int st_accel_common_probe(struct iio_dev *indio_dev, struct st_sensors_platform_data *plat_data) { - int err; struct st_sensor_data *adata = iio_priv(indio_dev); + int irq = adata->get_irq_data_ready(indio_dev); + int err; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &accel_info; @@ -461,7 +462,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev, err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_accel_sensors), st_accel_sensors); if (err < 0) - goto st_accel_common_probe_error; + return err; adata->num_data_channels = ST_ACCEL_NUMBER_DATA_CHANNELS; adata->multiread_bit = adata->sensor->multi_read_bit; @@ -478,12 +479,12 @@ int st_accel_common_probe(struct iio_dev *indio_dev, err = st_sensors_init_sensor(indio_dev, plat_data); if (err < 0) - goto st_accel_common_probe_error; + return err; - if (adata->get_irq_data_ready(indio_dev) > 0) { + if (irq > 0) { err = st_accel_allocate_ring(indio_dev); if (err < 0) - goto st_accel_common_probe_error; + return err; err = st_sensors_allocate_trigger(indio_dev, ST_ACCEL_TRIGGER_OPS); @@ -492,18 +493,16 @@ int st_accel_common_probe(struct iio_dev *indio_dev, } err = iio_device_register(indio_dev); - if (err) + if (err && irq > 0) goto st_accel_device_register_error; return err; st_accel_device_register_error: - if (adata->get_irq_data_ready(indio_dev) > 0) - st_sensors_deallocate_trigger(indio_dev); + st_sensors_deallocate_trigger(indio_dev); st_accel_probe_trigger_error: - if (adata->get_irq_data_ready(indio_dev) > 0) - st_accel_deallocate_ring(indio_dev); -st_accel_common_probe_error: + st_accel_deallocate_ring(indio_dev); + return err; } EXPORT_SYMBOL(st_accel_common_probe);