From patchwork Tue Sep 10 12:49:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19876 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A3D1025E85 for ; Tue, 10 Sep 2013 12:50:12 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id c14sf7905934vea.5 for ; Tue, 10 Sep 2013 05:50:12 -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=E+WpX9mZviswltJQamLrSFbbD9OxZKhmOiltxElRQLc=; b=OvwR8yMWaTQgYtYaxVgOvg87o7TLkO8pRbNso9Jqrsp6vL1eAWCVAO96hMjOFTPN2F To4P990tLAdX1sbbau05TSS8B2Mjbpgn30dpMQC/dj79sB+hN10wlYRfEq5EJo1FoK2V xw24MX8Dp/UARIzDo7iG/ClinKYRkWoyiVBI79Q8e9tqtVsCx5hQuaY9yBHWbmGxGOdo RCXwhOa1C+ld8wQOCbPfzpQPsFgfOAImTHcCzS5HcEHhLtyZx54OT0vpxNmsI9IAS+k9 lXVDxDH432hjyTTNXsuPCjXxGrdtS2MCHF2vUd1RC/2w/ZyvG2i80UOxCNVkpZNF5Oq3 TJyQ== X-Received: by 10.236.142.38 with SMTP id h26mr442764yhj.57.1378817412392; Tue, 10 Sep 2013 05:50:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.231 with SMTP id n7ls2090977qen.14.gmail; Tue, 10 Sep 2013 05:50:12 -0700 (PDT) X-Received: by 10.58.198.13 with SMTP id iy13mr22892111vec.11.1378817412137; Tue, 10 Sep 2013 05:50:12 -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 ya5si4409127vec.19.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:12 -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 x14so5151028vbb.9 for ; Tue, 10 Sep 2013 05:50:12 -0700 (PDT) X-Gm-Message-State: ALoCoQlPY4ZX3SM6rKfk3Sauaa7cneDjxraJvQv66GoPBPNzwsfu3XiHwunD1Ay8AOEhmFu+gYyV X-Received: by 10.220.88.13 with SMTP id y13mr7214183vcl.20.1378817412060; Tue, 10 Sep 2013 05:50:12 -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 u4csp19401vcz; Tue, 10 Sep 2013 05:50:11 -0700 (PDT) X-Received: by 10.15.98.9 with SMTP id bi9mr2859777eeb.67.1378817408681; Tue, 10 Sep 2013 05:50:08 -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 x42si14832137eea.194.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:08 -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 k11so3905245eaj.28 for ; Tue, 10 Sep 2013 05:50:08 -0700 (PDT) X-Received: by 10.15.102.71 with SMTP id bq47mr2856737eeb.66.1378817408020; Tue, 10 Sep 2013 05:50:08 -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:07 -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 21/38] iio: sensors-core: st: Clean-up error handling in st_sensors_read_axis_data() Date: Tue, 10 Sep 2013 13:49:22 +0100 Message-Id: <1378817379-8238-22-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.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: , Gets rid of those unnecessary gotos. Signed-off-by: Lee Jones --- drivers/iio/common/st_sensors/st_sensors_core.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 8c4c54c..148f0e5 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -331,26 +331,23 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev, unsigned int byte_for_channel = ch->scan_type.storagebits >> 3; outdata = kmalloc(byte_for_channel, GFP_KERNEL); - if (!outdata) { - err = -EINVAL; - goto st_sensors_read_axis_data_error; - } + if (!outdata) + return -ENOMEM; err = sdata->tf->read_multiple_byte(&sdata->tb, sdata->dev, ch->address, byte_for_channel, outdata, sdata->multiread_bit); - if (err < 0) - goto st_sensors_free_memory; + if (err < 0) { + kfree(outdata); + return err; + } if (byte_for_channel == 2) *data = (s16)get_unaligned_le16(outdata); else if (byte_for_channel == 3) *data = (s32)st_sensors_get_unaligned_le24(outdata); -st_sensors_free_memory: - kfree(outdata); -st_sensors_read_axis_data_error: - return err; + return 0; } int st_sensors_read_info_raw(struct iio_dev *indio_dev,