From patchwork Mon Sep 16 16:02:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 20362 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D68EA2486B for ; Mon, 16 Sep 2013 16:02:52 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id oy12sf4583838veb.7 for ; Mon, 16 Sep 2013 09:02:52 -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=VKJ35pCGyk+y1YHGEliJkcXBgQqOBnzNdY2oVEMHwQI=; b=RW32eXcN4Sx9Y0FYfUbRHoQ4kTYoEzb9h05dg/7sk/lXmnTEUaL/UBk1K55fQKT9+T UhZ052XMImAuHIOTxEBNjSbl01jPJa4Mnz6oXap2mHDqxU47qfIDoIde3oxx3Z2g41Bs 6weBFy9tZ+rPLbs0UxhBs7nS5zScRkjWiXNHGGjuwOyXzh2xP5rWq0spY6KMTZfw0joc DL5hiVhP8Ry+S2w5DhlhJ3tOTs53oHynj+E3hXV0KTBVEa6ZhLcweCzrX2VGUwv0L9BI z9Mid4geDpWh3gt0EvWbYoi4qwdzpKan2+LdXEczQrlU5x7Uyescq243eGfaiHa0Ealo G3Eg== X-Gm-Message-State: ALoCoQkmr6b+PplG4iewAR4R1q4/q6KoI7m8Unb3LnYB8Zlpgm8svHDMpzNxf1H5kqZ6iNXibNDg X-Received: by 10.236.180.2 with SMTP id i2mr5782884yhm.4.1379347372617; Mon, 16 Sep 2013 09:02:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.53.103 with SMTP id a7ls2247124qep.90.gmail; Mon, 16 Sep 2013 09:02:52 -0700 (PDT) X-Received: by 10.58.235.193 with SMTP id uo1mr27287804vec.6.1379347372546; Mon, 16 Sep 2013 09:02:52 -0700 (PDT) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id j6si7276064vet.55.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.43 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.43; Received: by mail-vb0-f43.google.com with SMTP id h11so2959828vbh.2 for ; Mon, 16 Sep 2013 09:02:52 -0700 (PDT) X-Received: by 10.58.208.130 with SMTP id me2mr27688880vec.13.1379347372391; Mon, 16 Sep 2013 09:02:52 -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 u4csp104944vcz; Mon, 16 Sep 2013 09:02:51 -0700 (PDT) X-Received: by 10.14.216.201 with SMTP id g49mr2803436eep.77.1379347371195; Mon, 16 Sep 2013 09:02:51 -0700 (PDT) Received: from mail-ea0-f169.google.com (mail-ea0-f169.google.com [209.85.215.169]) by mx.google.com with ESMTPS id e46si16799715eeo.162.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:51 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.169 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.169; Received: by mail-ea0-f169.google.com with SMTP id k11so2137763eaj.14 for ; Mon, 16 Sep 2013 09:02:50 -0700 (PDT) X-Received: by 10.14.246.11 with SMTP id p11mr44518523eer.9.1379347370697; Mon, 16 Sep 2013 09:02:50 -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:50 -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 14/20] iio: pressure-core: st: Clean-up probe() function Date: Mon, 16 Sep 2013 17:02:20 +0100 Message-Id: <1379347346-823-15-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.43 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 | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 3abada2..4539953 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,15 +263,15 @@ 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; } @@ -281,12 +283,12 @@ int st_press_common_probe(struct iio_dev *indio_dev, return err; st_press_device_register_error: - if (pdata->get_irq_data_ready(indio_dev) > 0) + if (irq > 0) st_sensors_deallocate_trigger(indio_dev); st_press_probe_trigger_error: - if (pdata->get_irq_data_ready(indio_dev) > 0) + if (irq > 0) st_press_deallocate_ring(indio_dev); -st_press_common_probe_error: + return err; } EXPORT_SYMBOL(st_press_common_probe);