From patchwork Tue Sep 10 12:49:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19881 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B02B9260BE for ; Tue, 10 Sep 2013 12:50:17 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id i4sf29766339oah.3 for ; Tue, 10 Sep 2013 05:50:17 -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=HVyTT7KvjyFj2roxYPHZ0qF9dkW81BziJnwT4jgiiao=; b=gmKTQNjxthkWLyDv+ejr68NRpRvTF7CjwOO0EzxN9Anyxyj7hYTpTpFgDcLcBcQN80 Q4B2GamFV3hh25jvBrZYbecJxamxCrgGmKEEydHkb+91H6OC0fSpx2fNkcyx1jDxydmw m6n9fRWvmoQ8vU1bYMciMRUA7vX3f2qFRCAo7IOyKF/Lu4i2spm7RmxnzaO3MIytnw7l 0rFxRrTQ7S9X0mdmWTlIM7eboi8RGJLvyaNMwCDEVVcaLpZ6bNXgqDWSCzFBQV/WfYrP WoTgykHr6EOGkv/sJsBj+SzIBS8xKMm1O6zr2A8bE3e/jv2+x301mMaVR5sS7v3/ewiA QIwA== X-Received: by 10.182.32.69 with SMTP id g5mr4330266obi.30.1378817417265; Tue, 10 Sep 2013 05:50:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.39.163 with SMTP id q3ls1082255qek.31.gmail; Tue, 10 Sep 2013 05:50:17 -0700 (PDT) X-Received: by 10.58.118.130 with SMTP id km2mr22551798veb.0.1378817417002; Tue, 10 Sep 2013 05:50:17 -0700 (PDT) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id c11si4404015vej.52.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.51 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.51; Received: by mail-vb0-f51.google.com with SMTP id x16so4836936vbf.24 for ; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Gm-Message-State: ALoCoQn/dmWnsBzfKtG/gEAPj0z/sVR/q7NcR7gmsni1pk4UX6eHNQP2gryYri0oftNLBJ3+QnO4 X-Received: by 10.58.108.74 with SMTP id hi10mr23487909veb.14.1378817416920; Tue, 10 Sep 2013 05:50:16 -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 u4csp19407vcz; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Received: by 10.14.29.67 with SMTP id h43mr39006250eea.7.1378817414005; Tue, 10 Sep 2013 05:50:14 -0700 (PDT) Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by mx.google.com with ESMTPS id x7si14869325eeo.37.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:13 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.48 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.48; Received: by mail-ee0-f48.google.com with SMTP id l10so3812708eei.7 for ; Tue, 10 Sep 2013 05:50:13 -0700 (PDT) X-Received: by 10.15.75.73 with SMTP id k49mr38544430eey.36.1378817413221; Tue, 10 Sep 2013 05:50:13 -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:12 -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 26/38] iio: pressure-core: st: Clean-up probe() function Date: Tue, 10 Sep 2013 13:49:27 +0100 Message-Id: <1378817379-8238-27-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.51 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 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 3abada2..6ffd949 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -232,21 +232,23 @@ static const struct iio_trigger_ops st_press_trigger_ops = { int st_press_common_probe(struct iio_dev *indio_dev, struct st_sensors_platform_data *plat_data) { - 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 *) @@ -261,32 +263,30 @@ int st_press_common_probe(struct iio_dev *indio_dev, err = st_sensors_init_sensor(indio_dev, plat_data); 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); + ST_PRESS_TRIGGER_OPS); if (err < 0) goto st_press_probe_trigger_error; } err = iio_device_register(indio_dev); - if (err) + if (err && irq > 0) goto st_press_device_register_error; return err; st_press_device_register_error: - if (pdata->get_irq_data_ready(indio_dev) > 0) - st_sensors_deallocate_trigger(indio_dev); + 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: + st_press_deallocate_ring(indio_dev); + return err; } EXPORT_SYMBOL(st_press_common_probe);