From patchwork Mon Sep 9 10:10:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19827 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4E83C25A57 for ; Mon, 9 Sep 2013 10:10:32 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ht10sf6923787vcb.1 for ; Mon, 09 Sep 2013 03:10:32 -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=Gj/ypYX1VzdGELqoKQF3eJ2SAihvgloirBonC6mCoeM=; b=mzWHBLx7abqeIzPD9ruCoT1fIwmEF3bqvfo08iEyQljw23vsNsUDUs+Q9TAmK8ieuO rpNb+R4N70zDIeeQhh6C1dNhKuzLYFgy/Pm81hGntxKekrss4Vd1v1lp7A6ctC3yPqUN 2gUmYzuEuCQztdej0idGBhQnwEqSAv4vywATRyIroUyMzHhXFSI3jB9HpVBAgeTnSmSQ wJfp2GayvHkh8lvqfjJIZuMUTPY/g/UBXw/AgFHJJMPVxCF7YofsE4nmrR3oE8X7qQLl Lcx+GDHnmkaNpFwEQsOH2poLtMz2qxxf2BvYVRNwk6yu4hoUCoUJOXg18zhUXMjatkJx I5HQ== X-Received: by 10.236.108.233 with SMTP id q69mr6026347yhg.11.1378721432143; Mon, 09 Sep 2013 03:10:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.59.14 with SMTP id v14ls1726441qeq.87.gmail; Mon, 09 Sep 2013 03:10:32 -0700 (PDT) X-Received: by 10.220.1.203 with SMTP id 11mr16749241vcg.15.1378721432030; Mon, 09 Sep 2013 03:10:32 -0700 (PDT) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id b6si2964419veo.98.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.49 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.49; Received: by mail-vb0-f49.google.com with SMTP id w16so3710534vbb.36 for ; Mon, 09 Sep 2013 03:10:31 -0700 (PDT) X-Gm-Message-State: ALoCoQmiPEDC+ml6s9mFQ9iIBSsNPL4P1awZrTs2gRbHQ9l3uTyJNQzspWcNlGW9lAv/rmM3ntvl X-Received: by 10.52.101.166 with SMTP id fh6mr346598vdb.30.1378721431917; Mon, 09 Sep 2013 03:10:31 -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 u4csp78974vcz; Mon, 9 Sep 2013 03:10:31 -0700 (PDT) X-Received: by 10.14.38.14 with SMTP id z14mr56087eea.89.1378721430719; Mon, 09 Sep 2013 03:10:30 -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 h5si9536386eeg.230.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:30 -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 h10so2979103eaj.39 for ; Mon, 09 Sep 2013 03:10:30 -0700 (PDT) X-Received: by 10.14.174.8 with SMTP id w8mr54962eel.84.1378721430167; Mon, 09 Sep 2013 03:10:30 -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 m54sm20768068eex.2.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:29 -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 08/14] iio: pressure-core: st: Clean-up probe() function Date: Mon, 9 Sep 2013 11:10:04 +0100 Message-Id: <1378721410-30937-9-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378721410-30937-1-git-send-email-lee.jones@linaro.org> References: <1378721410-30937-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.49 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 93bff9b..d918e76 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 *) @@ -260,32 +262,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);