From patchwork Wed Sep 4 09:31:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19749 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2C6724869 for ; Wed, 4 Sep 2013 09:32:08 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id hu16sf168615qab.6 for ; Wed, 04 Sep 2013 02:32:08 -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=TmI9/SIMp49eDabrojPSQPHbJNgtvl2MT5YGtWGTy8c=; b=ErtDzQW+GuhCq28hTV2Va6g4Y8HvkicKFFEnD6NMavApEAgCyut/L2QQjmudf9AK5w VcowCEgVZgSvbw5IB3tjzIkyAEEETiShhcgEdhX+OrtrXc6XXUqRX484uQK5N0YREq+t XRELR+3z7+x/nqG+zk58ZVhI8tmAKiqlUXW7j+fVAmOB26RpxGWvjch66vNIKX+rtdd6 m99xAkbVOfet52KpBoQpHCiHc0RjYxQxI12XZhFdPYT2BgeXzOAYPqK2zzIO52JxPG+L oggdZu+aK5ax3DlrXsRGzjKJt4jhSbSABOHxdnoyPMKXriz9JNhjCMzq9EkLy/4Jak3K PCzw== X-Received: by 10.224.223.198 with SMTP id il6mr2107290qab.7.1378287128713; Wed, 04 Sep 2013 02:32:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.53.103 with SMTP id a7ls25173qep.90.gmail; Wed, 04 Sep 2013 02:32:08 -0700 (PDT) X-Received: by 10.52.23.113 with SMTP id l17mr1539136vdf.23.1378287128624; Wed, 04 Sep 2013 02:32:08 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id ee8si2878044vdc.119.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 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.50; Received: by mail-vb0-f50.google.com with SMTP id x14so40163vbb.9 for ; Wed, 04 Sep 2013 02:32:08 -0700 (PDT) X-Gm-Message-State: ALoCoQlCCEy9Yd3oB74df4HWDzv00uVvd4xDrNuVpHjtMJ73l4symjY/DUsyBwriIN+y9FJXwTjp X-Received: by 10.52.232.165 with SMTP id tp5mr1506122vdc.11.1378287128527; Wed, 04 Sep 2013 02:32:08 -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 u4csp223891vcz; Wed, 4 Sep 2013 02:32:07 -0700 (PDT) X-Received: by 10.15.94.201 with SMTP id bb49mr3353909eeb.23.1378287127521; Wed, 04 Sep 2013 02:32:07 -0700 (PDT) Received: from mail-ea0-f180.google.com (mail-ea0-f180.google.com [209.85.215.180]) by mx.google.com with ESMTPS id c49si18311927eeg.327.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.180 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.180; Received: by mail-ea0-f180.google.com with SMTP id h10so34653eaj.11 for ; Wed, 04 Sep 2013 02:32:07 -0700 (PDT) X-Received: by 10.14.109.201 with SMTP id s49mr2073731eeg.54.1378287127010; Wed, 04 Sep 2013 02:32:07 -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 p5sm38475700eeg.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:06 -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 09/11] iio: pressure-core: st: Clean-up error handling in probe function Date: Wed, 4 Sep 2013 10:31:41 +0100 Message-Id: <1378287103-21765-10-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378287103-21765-1-git-send-email-lee.jones@linaro.org> References: <1378287103-21765-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.50 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: , This patch contains some pretty basic clean-ups in probe() pertaining to the simplification of error handling and a couple of readability adaptions. Signed-off-by: Lee Jones --- drivers/iio/pressure/st_pressure_core.c | 41 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 3cf54ed..2893d08 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -224,21 +224,23 @@ static const struct iio_trigger_ops st_press_trigger_ops = { int st_press_common_probe(struct iio_dev *indio_dev) { - int err; struct st_sensor_data *pdata = iio_priv(indio_dev); + int irq = pdata->get_irq_data_ready(indio_dev); + int err; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &press_info; err = st_sensors_check_device_support(indio_dev, - ARRAY_SIZE(st_press_sensors), st_press_sensors); + ARRAY_SIZE(st_press_sensors), + st_press_sensors); if (err < 0) - goto st_press_common_probe_error; + return err; pdata->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; - pdata->multiread_bit = pdata->sensor->multi_read_bit; - indio_dev->channels = pdata->sensor->ch; - indio_dev->num_channels = pdata->sensor->num_ch; + pdata->multiread_bit = pdata->sensor->multi_read_bit; + indio_dev->channels = pdata->sensor->ch; + indio_dev->num_channels = pdata->sensor->num_ch; if (pdata->sensor->fs.addr != 0) pdata->current_fullscale = (struct st_sensor_fullscale_avl *) @@ -248,32 +250,27 @@ int st_press_common_probe(struct iio_dev *indio_dev) err = st_sensors_init_sensor(indio_dev); if (err < 0) - goto st_press_common_probe_error; + return err; - if (pdata->get_irq_data_ready(indio_dev) > 0) { + if (irq > 0) { err = st_press_allocate_ring(indio_dev); if (err < 0) - goto st_press_common_probe_error; + return err; err = st_sensors_allocate_trigger(indio_dev, - ST_PRESS_TRIGGER_OPS); - if (err < 0) - goto st_press_probe_trigger_error; + ST_PRESS_TRIGGER_OPS); + if (err < 0) { + st_press_deallocate_ring(indio_dev); + return err; + } } err = iio_device_register(indio_dev); - if (err) - goto st_press_device_register_error; - - return err; - -st_press_device_register_error: - if (pdata->get_irq_data_ready(indio_dev) > 0) + if (err && irq > 0) { st_sensors_deallocate_trigger(indio_dev); -st_press_probe_trigger_error: - if (pdata->get_irq_data_ready(indio_dev) > 0) st_press_deallocate_ring(indio_dev); -st_press_common_probe_error: + } + return err; } EXPORT_SYMBOL(st_press_common_probe);