From patchwork Fri Jul 5 10:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13724925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1C42C30658 for ; Fri, 5 Jul 2024 10:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mPUGB6WWLvSgcH0G9Q4p2N02Tp+SMaWAilQNUIzP9x8=; b=T4r3kVOyxDiZfxaTtWWuUscB5d uvdamH0iRizWy1V3ReKlSEoi/6eg9W6HufkXEzV2vPkYNDHfGiZfIKTVgALBPEU2x1tsKWI9hETXq W4TqpDoVG5armSWJv82XULG93YU5wPOyIFBIn4drJP7C2/9OSGsjqh88gOOwr0UmXwGvi1iZzjGvY ec5/B0CSrDlLZjEaqBRro8bM2HzT5LvG7E9qzMvCxPcsDvaw+ENGSjAwdYE+R3NcI7pOylszo1tvw O0/4Petv3gI8yQM2uOv/fhKuj7OHZHbYXdjeSAFgEQgUhGjL+/8PbxzNu5idpDz6lIGVox2TdbtiC 6id6C3mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPgNT-0000000FfpV-4Aff; Fri, 05 Jul 2024 10:41:19 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPgN6-0000000Ffjh-2pWG for linux-arm-kernel@lists.infradead.org; Fri, 05 Jul 2024 10:40:58 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42562fde108so10077535e9.0 for ; Fri, 05 Jul 2024 03:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720176055; x=1720780855; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mPUGB6WWLvSgcH0G9Q4p2N02Tp+SMaWAilQNUIzP9x8=; b=kCdo+1u+gv+ww7FdIexnEk0pnFIBK8k4YkU6N8EF9T1k8NGA6+8GNnIEJZar/oz/S3 BSUVT/WMPinbhcEgWoNeosKBSc2lj+MudKY91a3oQbHwKvV/1M/wYp7POR+F+U2WHtBe cTZVxbsLDrhsZN3ceslwO022PKpP0briuw/d4W58eenejlFRTO2ANoxZq/lqtjfd4XHT 8MBicUu6wIClGyNsohuNc3TTaydj58KK3PrBT5GklYUgmaRHniGv2tb9kMSNtmnlyptr HQetIvYQcAoWmRieTy98pQFitYSmrSw9yrTzAW573SB410qO7iJ5WERT73AO/OXaFw9D OPRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720176055; x=1720780855; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mPUGB6WWLvSgcH0G9Q4p2N02Tp+SMaWAilQNUIzP9x8=; b=jtZ1GkbqnngDvI2quViCzK3T0F1Q5yPrn27upA5llG419fbGUVcEFtUIpZIWOpHbSv lQCQMt9xPS0pN352q4cUzY2uF812TIGtR6Fo/Cl5f9fHUrXZZ61Om0zqVSOFM7qt5psO Z6rf3rPN9rH3GdLCkVRyWCz6GINk5+kUvmP4efkXqaqvQESvNSopaHznPUnukaxu1clm zeNTJRU8k8j4GK2EorSJXIg04DnIEMQnYQ8M4NvwJAGjqNnmAA7oXSKhK0yi5zNYhaoJ 94Y50jMOXJx7NYLcb8qtRuL9hTq0FjfaYOcLuMd8FX9pLW9dP3CkVhicIsyRDa4WNkGR kINg== X-Forwarded-Encrypted: i=1; AJvYcCX+KfwzvjuSUiTJnmj3dCVzciN5VYGBHT5iaoXRaqFiM2hyrW5sPJ/t9mMayWT/EMp1hobPdWThWBFzVXWmJpYDTSer1etwh7TeUWYK9lsx2Msubfs= X-Gm-Message-State: AOJu0Yw6BL8Nydv8gJXxOnklTuG1LpohPHPd/t+779ZI21fEwJsVs4nh mF0Gun3Ox837t6j9LhY2Aq2H4aOobj9N06MK7bYn0fDPu/xPnZoGkOODCF4lTlg= X-Google-Smtp-Source: AGHT+IG91L1QiQgNWqSWoacLRT/4TO/Dx2hLrfRAQx3fZ6Bx/+xCR5Xz6K+GVEbHWRxKNEP2hp8MbA== X-Received: by 2002:a05:600c:3b87:b0:425:6bea:8554 with SMTP id 5b1f17b1804b1-4264a44dd7emr27116585e9.27.1720176055057; Fri, 05 Jul 2024 03:40:55 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789d5ec1csm8680446f8f.37.2024.07.05.03.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 03:40:54 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 05 Jul 2024 12:40:44 +0200 Subject: [PATCH 1/6] iio: accel: bma400: simplify with cleanup.h MIME-Version: 1.0 Message-Id: <20240705-cleanup-h-iio-v1-1-77114c7e84c5@linaro.org> References: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> In-Reply-To: <20240705-cleanup-h-iio-v1-0-77114c7e84c5@linaro.org> To: Dan Robertson , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Oleksij Rempel , kernel@pengutronix.de Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1335; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=2JNEEDT0yqg0ZpezS+vJkAIFphubIucu2CrwWdLhExA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmh82t2yoLgw7U/d/3WF1lw6Sbpe0R3WznQ7bXQ zvidEQNGzqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZofNrQAKCRDBN2bmhouD 18eFD/99kCbJW7rMBIrokTGQp+teP0OMxk9HEiucDrZMQqy964A/H6w6db7bxlu/FqpIge6xQfZ pgShtD2t06mxtvYqI8U7yZJgNkkNoOY8Mzy1NJncQrBuEXHf66NEGrsoMYwpPl31WIGH7LN6EsI Ghx3oPDxEmtAAuHBGsEhdCdDzuartmIyR0WnmgMSBT43VYTwVglMAg0Ep48AuxCZnm4PDQD89zo bPvUgyFgchmkNQEFwAByBkrlygUVTQ+IPLRa2TlVN+gsau951q2k5VgHgWhtzwqk+5uEWLZHYf6 wc6adZUHqX43cgbEfSaINs2Mszebw7ONrWbCMLyJLtJsYEAo/UyDrSk8AwM3CXeCzFjkKUE0gem N4LryYcpQ0eZ+PKKK/2HL50uDBF+MoMhmJQyOrb5MWFCTQ4Yo54ImehbKCayJSNQg6wx+0fE1OY I5KBjLZbj579jh2iLHlCdWNuDwDG6JugmcbLsnJt9D/ZxzDLrGWU3nphOqADk6rOpFUARMuc3ms ZLcIPlDzNFu0ntch5S3pAJ5mSW8zKSv65ZGz4qcHkVlVysAPcs4/pKU2ewf0L4x8LOano98sgKg /Wp5hbOhQDKwhrdvno18IAYmmFh+9K4rLxikmurZbqTx43Y1luTowQ57+5oh4A5yl4L8c6+DW6P 7AiqGyaPLAdiiwA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240705_034056_852288_A8B191FE X-CRM114-Status: GOOD ( 12.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/iio/accel/bma400_core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c index e90e2f01550a..89db242f06e0 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -795,21 +796,19 @@ static int bma400_enable_steps(struct bma400_data *data, int val) static int bma400_get_steps_reg(struct bma400_data *data, int *val) { - u8 *steps_raw; int ret; - steps_raw = kmalloc(BMA400_STEP_RAW_LEN, GFP_KERNEL); + u8 *steps_raw __free(kfree) = kmalloc(BMA400_STEP_RAW_LEN, GFP_KERNEL); if (!steps_raw) return -ENOMEM; ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG, steps_raw, BMA400_STEP_RAW_LEN); - if (ret) { - kfree(steps_raw); + if (ret) return ret; - } + *val = get_unaligned_le24(steps_raw); - kfree(steps_raw); + return IIO_VAL_INT; }