From patchwork Mon Sep 16 16:02:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 20367 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C2907248D3 for ; Mon, 16 Sep 2013 16:02:58 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf4481078qcx.0 for ; Mon, 16 Sep 2013 09:02:58 -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=pV25vx2UALiXK0ECAkwU6O8DZ2z1Wy3+pdf3JZ9PA0E=; b=K5fEuUZ2eAY+V4Rm4vv1F5yffLCVtBjJguTIvJb0bgSLYDpOdmuXDslf7D3Slgvzeh 1SHhFUAm/dpo6LWDyI5RXfqtJVd1lfqurWloVCv2R4+O0Ue1pFzT7S2JV1cLNCp3n3AB UbHsOXxZtusq89/52qPMLSUau7GyTcwwfNn9eawSpfl6CazO7n/xJvvZ6vBpSp4+2VUv 6y5YHzD4uGMikZJpfvc+bWLL+SpQgaN53U7J/tGv5sztVpZQ5H5fiaqhSBXlpyPtUC+v yTX6PxLKoTKaNtLwD/sj2XbcmKkIaA6CzMxziH/gdd3J0ELPlxJRmUNNYhN9RVBTFQzw PslQ== X-Gm-Message-State: ALoCoQm5ad8AhagYw15Hom8rqFOAEuG72gEYKrdioTAFynBPL/JLqOrVt4LQPu3FrDzN0dZVu7gK X-Received: by 10.236.53.70 with SMTP id f46mr10769828yhc.17.1379347378463; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.244 with SMTP id u20ls2292317qeq.74.gmail; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) X-Received: by 10.52.118.41 with SMTP id kj9mr4494vdb.44.1379347378238; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id gq10si7237645vdc.147.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: 209.85.212.45 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.45; Received: by mail-vb0-f45.google.com with SMTP id e15so2987028vbg.18 for ; Mon, 16 Sep 2013 09:02:58 -0700 (PDT) X-Received: by 10.52.166.200 with SMTP id zi8mr707743vdb.38.1379347378138; Mon, 16 Sep 2013 09:02:58 -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 u4csp104955vcz; Mon, 16 Sep 2013 09:02:57 -0700 (PDT) X-Received: by 10.14.211.4 with SMTP id v4mr1438428eeo.81.1379347377205; Mon, 16 Sep 2013 09:02:57 -0700 (PDT) Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by mx.google.com with ESMTPS id l4si16794971eew.281.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:57 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.44 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.44; Received: by mail-ee0-f44.google.com with SMTP id b47so2140828eek.31 for ; Mon, 16 Sep 2013 09:02:56 -0700 (PDT) X-Received: by 10.14.246.11 with SMTP id p11mr44519036eer.9.1379347376665; Mon, 16 Sep 2013 09:02:56 -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:56 -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 19/20] iio: gyro-core: st: Clean up error handling in probe() Date: Mon, 16 Sep 2013 17:02:25 +0100 Message-Id: <1379347346-823-20-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.212.45 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 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index e13c2b0..9f80817 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); @@ -344,15 +345,15 @@ int st_gyro_common_probe(struct iio_dev *indio_dev, if (err) goto st_gyro_device_register_error; - return err; + return 0; st_gyro_device_register_error: - if (gdata->get_irq_data_ready(indio_dev) > 0) + if (irq > 0) st_sensors_deallocate_trigger(indio_dev); st_gyro_probe_trigger_error: - if (gdata->get_irq_data_ready(indio_dev) > 0) + if (irq > 0) st_gyro_deallocate_ring(indio_dev); -st_gyro_common_probe_error: + return err; } EXPORT_SYMBOL(st_gyro_common_probe);