From patchwork Wed Jul 3 09:42:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721594 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDFE513D630 for ; Wed, 3 Jul 2024 09:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999779; cv=none; b=loQnIC1fVsnRnH2bES6ca4QoCdrtQqhilNnFUgafkKz2XDZJvkd6lzDjtUmmxiceE1GzT+nBgcsfwQLMA97OM3VQzJO/XPGb6cYVLJ6gHNc0WV2sIYxiqZhgT+Jkm6SaeE/js+w4VEZdyfj9pWsHWB+rra4cAl2FJaW3NcawTws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999779; c=relaxed/simple; bh=lKPHxJzTfCgHYSDX1B5tpKsTNzm2ZtiK5HSUDsGmOlY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FntLc3lrEAxgp46gNh02MSGv7I3KAyO4MER1j+gAmyND3K+lNNnNXVofiUWc32O40QiUlfItbDv+pvY0H7S2vBWbkJS7geRQuCPYlAshkuTtDoYmj4uM2X5kROFyqmZWdumWaaBHvNu4p4fWoF5qEwhSStURwxMoT8ryXD3RABQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Oy8AhyVH; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Oy8AhyVH" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4255fc43f1cso36307215e9.0 for ; Wed, 03 Jul 2024 02:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719999776; x=1720604576; darn=vger.kernel.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=BRPUglwHx6wx9ZA8hR4jlun3U4RFQIJjJ+cyxQAC65s=; b=Oy8AhyVHpz4ntn72FSHOJ0F8ZXlwBuZwQE9PocrnKpytHtH6fH8aCApYtzjtK4hmoA UZwzlhGbF+Ourtj14sHC3v1ZFa6ZmyDZrKj1haVRa9VG0AS1n3UVHpK9p0BQ+1N5XVOw uM/Za3v4x1aaSN9LyhwbVJG64+J9kLao23BwcKUHwXndUxsSHd7CnFTBDTiHnX9/6BSk i70/fdpwOFEZcCrUUKO9DhsAbNpWdEM4JedPpLjnWfhwPIsCVK98Tt40n2cxdu13gzZ2 VM45VdUvdYVBnAlvp+HGnZqApnwXp7R0iuRZ8HaTe2C1JZceRe33mHqp7I+dlmTkOFgk OLeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719999776; x=1720604576; 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=BRPUglwHx6wx9ZA8hR4jlun3U4RFQIJjJ+cyxQAC65s=; b=O8TSR60Al8QONFS3IC6ic93R1CQYZnmnW5m10f4UqX1jy0oTidCW4/O8h/3FZM4s9l Usj3DfizEmZmwKdfEGxp0mLxw9wDQjOYI1zK5EaovOWFyzLlfaOgyJtjAdA2sWCKerQD +mTSMzIuS/cBKjWBKnB9AFVYWsZBobFcAYAzWDLhCAlwnD6nVt/U7emSjV6eGkxbw77M jT8MRTcZx4HNpM3X//zKp8lWaybRj8r7tvg99rqRxlzCH4uuKsdMlDET2FFjmMpXPniX +7esbkX8CH6HOzZySWMD95FPDDvlcfIHbGcZLx5VPdl47Zw9v9DRcajjqHwHPOBsFycN 0mew== X-Gm-Message-State: AOJu0YyXdSl+12PUJIDBhpgYfRDm0cQhlVTE51DZTCgAAxM9wNVpnzW/ I5EbOFUlI9VeOgWJP4TNwISRg4e4l49vFgmOBZ2TJ4Hs+TNzX7vLmjpEd73UtQk= X-Google-Smtp-Source: AGHT+IEcbA6e7/zY8dqMp+pN+4R9NA9nKBH5uQ/Ya/wGE5aHNYG8uaxx5oqrUjLx2nI7UUhdrDqNAQ== X-Received: by 2002:a05:6000:18a5:b0:366:e991:b9b7 with SMTP id ffacd0b85a97d-367756cf2e8mr9811108f8f.30.1719999776016; Wed, 03 Jul 2024 02:42:56 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm15341394f8f.100.2024.07.03.02.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 02:42:54 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 11:42:36 +0200 Subject: [PATCH 1/5] soc: qcom: llcc: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-thermal-const-v1-1-6e59e139c65d@linaro.org> References: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> In-Reply-To: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1280; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=lKPHxJzTfCgHYSDX1B5tpKsTNzm2ZtiK5HSUDsGmOlY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhR0X/MScy/ZctVKAegPdD7Al+xg25RBrO3ZpZ 9cQta4rMNCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUdFwAKCRDBN2bmhouD 116kEACEYb5vNbZAyBa7igQO4bpGyx/2MWanL+nROyPM+WLhPflDTQSk+7ee4fBrBrd8JohrhQH xOtldUKP0b4Jry2QeYRvvpEq2hf7VowY2mr0l+olzyAs6oJs/K3xrrsGzCIs8jbB6MfXJLsDibF IUVGaPjiVVFV8wz2zWQzh6EaEMZmNnIBUTrmFBk89vSQoqkMp/SOlBSdZ5Ir2F2d9JpmHbnThWy zjjf6nsxFhGPK1+rgEZvYOnv/z1OaN4hJVjTIbggfG+qUftFmwXKGfPQFwMu/Wrt4MvWCnQCoVf ZQo8zht+QUcfbdx4vWg/73axZU1iv1GiMW/neU22CNov8PIQof56kchisTRcDlsrsi5CSbkE7MV +UFYhcMp3In+mqwv2NtYAEee/IgVM1kbLHsHvPy4TT3OBmek7BAJu8+kOG22HvNstN12SKqXG/U e9BEYdQvpxkCq6h4yy8CEdxFfnGv2FwU/VVx1lTz/NFiqjixQaJt9VixKTLOu4DHhPLrYqx4GfW iwpONs/mJg21MZJk9TzzShaiIRWblsDPhBsMvmCQHqAxLJiUtQOpOZtLbyBHz01ilE40AUneQiO T4XZobCIy0fSdKQ4YxGZhqduP5Vzr+l71Om07ei7x2z+N6MtgY0bWl/E4VQ6MqIhjFG26jO9+5l w1xbluR0xizKhtw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/llcc-qcom.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/soc/qcom/llcc-qcom.c b/drivers/soc/qcom/llcc-qcom.c index 110b1f89aa59..37e11e501728 100644 --- a/drivers/soc/qcom/llcc-qcom.c +++ b/drivers/soc/qcom/llcc-qcom.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1294,16 +1295,13 @@ static int qcom_llcc_probe(struct platform_device *pdev) /* Initialize rest of LLCC bank regmaps */ for (i = 1; i < num_banks; i++) { - char *base = kasprintf(GFP_KERNEL, "llcc%d_base", i); + char *base __free(kfree) = kasprintf(GFP_KERNEL, "llcc%d_base", i); drv_data->regmaps[i] = qcom_llcc_init_mmio(pdev, i, base); if (IS_ERR(drv_data->regmaps[i])) { ret = PTR_ERR(drv_data->regmaps[i]); - kfree(base); goto err; } - - kfree(base); } drv_data->bcast_regmap = qcom_llcc_init_mmio(pdev, i, "llcc_broadcast_base"); From patchwork Wed Jul 3 09:42:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721595 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0278813DB9F for ; Wed, 3 Jul 2024 09:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999780; cv=none; b=Xl0sDm8wM+MZTSGIZmMGGNFF8YkBTOKdaHThsiSbBzh0KyAR7gMNBk3dzTYc9ZAKLlpV6d/PMnC+ow2Ap23CfeAjpvuLn43uSl2Z7T1cX9KfOrS9Og+NGuDlIgBusS7DF8JBtBTOmilZJdsiSTACGlPuAr249ltjQv7FlzTy90o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999780; c=relaxed/simple; bh=69S8VVQH6jBMjq2wWaMDevdT9Jq5+NLiRt2FAcxu+ug=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YxPXzHbhqD0KkOdxOwpZeY88hIqwqP0UDXO1PISxL0ZuJro95TjvsgEPFM0xblLK8zTaM62MrFgtDbq5iambux7+AmnM9Zcz42l83DVfVH3nZSudcX9kuRKiEvPmAWxnTQlXAcxtyQSFRlTti2Rx8U+p2PWC/v0dHZwePsGZCyA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Ni/OSS/p; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ni/OSS/p" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so29816035e9.2 for ; Wed, 03 Jul 2024 02:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719999777; x=1720604577; darn=vger.kernel.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=DSfOCAVt0bY+fqoFGSVQNvowRrX3jzlSptxCIMvtd6I=; b=Ni/OSS/pIl408/IlaGrfgB+Xkc9ojifVTJZBNw7TscPOxGcX5eM7AvajLZLXukWIVF Rkh6GBTPWGQdoZ2j1AXIGJHVm1X9tnOOi0gsYOToqRFqHZwFoOweD6mYwMETwTIZugnG Ks+C3rthAfqCkaUWYKbf0fZ++rDgPGhszp+QPp9ICAlvT4wCPjVINWJikz5qj+r0TWNA 18D7686FpSybA5YIdqzpvGZ3gruacZg0w56mabWAV+KlPhUME/EeHYHN6i639UWx3mmK tV6WikBosuY6RulmvYiMK2jzOs+mo61QAZKVixbRdbw/MLXD/fx8sN7U72SMx3hYAXzx yglQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719999777; x=1720604577; 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=DSfOCAVt0bY+fqoFGSVQNvowRrX3jzlSptxCIMvtd6I=; b=qmcEzt+CqZEckofT3jfB5y6+f1IU4GZjUZL6BlJ4ovKbr6i503DszZN4bT6014kPry biFiVdC8MfBz0ojOoKFMCnybE/YQEtcei8tnWJpUOaWtDmXkVEJr5yUqo7HOLWnMt8+m WKATwERE6icpRyz3UZXe2qu2sT0G+dPDD8dwoOT1PwPiZalgAMekPcI+EBMS/XDXQV5R rWDuEnmjKdsWWra6Z9NIpSmjZL2Q+S+NqVgoXavHR23tvlCYfJjaXkSw6wmoUQ/n0f+F /mkI12sxKk+aujWp6FsF2jfiS1hzhmHr88dqK+sMrS70if+pDr/wcPyDixpOF34DL5Tq d7CQ== X-Gm-Message-State: AOJu0YwsTIr1RukLDY1GyZlAnVBOBIItZvaldH68ovzSalNNccvAwLTq ydgXKqCycxPTuIxPCHeafvuecDRq5RiyXGyf0rzIden+ePkrESuZ3g7WlsjH9C5puwB66mW6evt VzcM= X-Google-Smtp-Source: AGHT+IF+Csk0/r4TTYC0yJ0HEwR7LHJUXwkCep8r6woD9QJ4S3iLowEnlT3nsy9pVzJ7OHKg7Bg27A== X-Received: by 2002:a05:600c:4804:b0:425:7784:56e6 with SMTP id 5b1f17b1804b1-4257a007729mr95529115e9.11.1719999777514; Wed, 03 Jul 2024 02:42:57 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm15341394f8f.100.2024.07.03.02.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 02:42:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 11:42:37 +0200 Subject: [PATCH 2/5] soc: qcom: mdt_loader: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-thermal-const-v1-2-6e59e139c65d@linaro.org> References: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> In-Reply-To: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1546; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=69S8VVQH6jBMjq2wWaMDevdT9Jq5+NLiRt2FAcxu+ug=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhR0YOOfP8ePx5Tn0Yv/47Shv5rANBKvKuhrRT LCg2FEuP6+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUdGAAKCRDBN2bmhouD 16JBD/4sDgUB70ZhGLI3lo6v/ZHoFxM2NToEX4OIZ6RZvxbVksW9CnhoNxbYC1b39qjhRT+p032 +l2/sp2WItgL0TW9eras+iZs19N1qapDaO5coYLmT21Zs9C5VawZ0tzzc9ASHabtigeHOyBWTre yWoZZFVNOTM0hpGB3xcVy/E8tEvFB+exgN1dg0fOsI6kFvW+k3HLGhvRir9Nhbr4bFaJZmoKalk NO6bRl0rU2DtOY9LsDkyE2T1eLtpjwPfKvqkhl9fZ/djcmS+2D38SuxYEcLkevC2ZjBVfdJGDsE k5KndtwafZD/FUPMnQthg/U7VJpb5Oqiage1Dm06rrBRPZlNVxQxj/X8LRPxlOQ+Z1HH/WKF32+ LXtkKnP3x8+d8T6uFR0fj6/6nXbP4tjg921xIoFMXowqfzxUmFxJviIAmR60xloY1xYHRjErnXU nwDOxOWhBuhl16dT47ALQoLa9jBiiQwGqTutSVjV5N7xOWLt4Xby1wU9Arz0zHiNwpi44MGk5CU pklILdRXug0utH4TIyYrm6uyU9sKh5fkavRzsb9PV88H0GnPB8t1nGsfWvMxpoP7k85zyYxg/Lv vZYeZJ5IlaTXpQFU48zW8UBbhFul0la4z9SqRHUawIkhcUhfHEA6mr+/2q0SW9Q+otctNGX/7vB wkXYy3ULsbS++6w== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/mdt_loader.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 6f177e46fa0f..b2c0fb55d4ae 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -7,6 +7,7 @@ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -37,13 +38,12 @@ static ssize_t mdt_load_split_segment(void *ptr, const struct elf32_phdr *phdrs, { const struct elf32_phdr *phdr = &phdrs[segment]; const struct firmware *seg_fw; - char *seg_name; ssize_t ret; if (strlen(fw_name) < 4) return -EINVAL; - seg_name = kstrdup(fw_name, GFP_KERNEL); + char *seg_name __free(kfree) = kstrdup(fw_name, GFP_KERNEL); if (!seg_name) return -ENOMEM; @@ -52,7 +52,6 @@ static ssize_t mdt_load_split_segment(void *ptr, const struct elf32_phdr *phdrs, ptr, phdr->p_filesz); if (ret) { dev_err(dev, "error %zd loading %s\n", ret, seg_name); - kfree(seg_name); return ret; } @@ -64,7 +63,6 @@ static ssize_t mdt_load_split_segment(void *ptr, const struct elf32_phdr *phdrs, } release_firmware(seg_fw); - kfree(seg_name); return ret; } From patchwork Wed Jul 3 09:42:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721596 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B99113F01A for ; Wed, 3 Jul 2024 09:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999782; cv=none; b=Xri5yB84Y+RaAn8nBzIFJVNaOg2al3WvvDm0wFwFf2MZFt8k/jBszgkogupdZbsNZB47yCLXRokVRD6wWCCpkUZSRBZ18Mim+NWcUt/DStCrCrR7/BO9cthCAonRjFX2LT5c4O4fgbViNEJffBSdIgn4RcRagnSrU1R3lgKoqMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999782; c=relaxed/simple; bh=xi1mYXDi2Ujb+2Jpd3mF9lwbKV+pBoSnnqh1EQ2jopo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=orJIYJoNCebcoy6zAvaXvUrXBK8cvgBC3pjYND8vCSViL2FzyO4nA7PsZeAYnh8pqvi0tB3nOPMEHDRiajwYSNbp1qed1Mmo1bFT+hWy1LRHdKrtPYoxYadHPTE629NS+485Ehd1OBfjyUVITIm6WNNqwhLnTbCTvbc9ECVdoPo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jYN6Dsf/; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jYN6Dsf/" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42573d3f7e4so34613255e9.0 for ; Wed, 03 Jul 2024 02:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719999779; x=1720604579; darn=vger.kernel.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=tJ9yEubK6nQZcmF1Fd1PJ7crkziQ0G5lQAl3Cg7RXd4=; b=jYN6Dsf/vIiO2atDfVGjubJM//i3YXUf2W99sZ/mX0XVteMpNHhLD1x80/SC0R7vsz cgT+dOnpQhnsNqp35Fg17cHp7e+8M0mZfb+zpRZ8lKfVjEg3roTGR9AXGYIVZu0IC0lS rZzskuoyLOXoUeG8G8S0vbXWJTRnj854YxW1RY80eMGd23ePJCUPAJXWaxvqt1oXL28W GDYi22RH3mzV7Yc69GfC1kr/OOVQuoVKcgOH4awB10B0gyRA/YE0yWy8HJnT83w/HCJ4 DCszkJNEwsUOvXsfIW0pluQknF0SpDPYWXYQ9D0RQRs43pgYnIy1Ws3stLGgLUUF7o0h WmIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719999779; x=1720604579; 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=tJ9yEubK6nQZcmF1Fd1PJ7crkziQ0G5lQAl3Cg7RXd4=; b=lu3vjWkptJL1uYWdHx/9Jefd6o1vygcrCUcjHnNuCVQBFKIqGaf4N8rnKcNpb00Oyl ySqzWJrmLPWPvC3DL6+M35owwmAIeX0q20+SBq5krnxuRLXZ0eaBo8PzqmJPLRXA7FVE /kBBkB0U0kGN7GEjb0Gp6vJYxANHUP7mSVXCmsDl9y84L0nH6pNeHE+Y3JABnX7b4N8U TMm2DJpRqTvppA5VcM6BjWKSkA4FB7dSGEsVCBnfQEsOOQGNS/kNe+DY6piRLiQQzGZK 92RdpSIsDH4TXsKludKXGBfpvmXkqz2vAw3agJmC9ExP5D1dcTrhUxNKVw0xjYg1LXeZ yMNQ== X-Gm-Message-State: AOJu0YxbhKtgpcV4AT20qdql80DAHK7DdkMUnArG7hhKoQfYRppyMDsn PY5SSPxflKVQJxcXmqOgK2pwU0cqJfMUaSTYnIXGAVjjXa+UiSahdZD7br5VqLU= X-Google-Smtp-Source: AGHT+IEz/oufuXWx2hMPprHshGaK+rfrUD2zHGYrpR2jyMXO/HMOcgcTp7mp8IYi68R36onkTLyYPw== X-Received: by 2002:a05:600c:33a8:b0:424:a6ae:a25d with SMTP id 5b1f17b1804b1-4257a03aa57mr80741845e9.24.1719999778638; Wed, 03 Jul 2024 02:42:58 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm15341394f8f.100.2024.07.03.02.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 02:42:58 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 11:42:38 +0200 Subject: [PATCH 3/5] soc: qcom: ocmem: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-thermal-const-v1-3-6e59e139c65d@linaro.org> References: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> In-Reply-To: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1950; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=xi1mYXDi2Ujb+2Jpd3mF9lwbKV+pBoSnnqh1EQ2jopo=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhR0Z8FIA+vE9wJWcgTbRn9pBuP8u4C9VMI7Dq hQTgI9y9XiJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUdGQAKCRDBN2bmhouD 13ziD/9XiwMQphwEh0MSBUOKdtCYETK/7KQlCOmDHrxh5UTQExKpzpA88LBrC0WVNPzC+ar7kYH J38kU6lO3XjwsQ8cJoDOUw6mgma3ayOF8gWMU7RjjyEwjZERO81cLgRGaZHtG7MVrTbaTWv2Z7Q 6PCOBfHWJxQYslLPQoUX/PV64xWn94AUq71qDFDULrX56L+5dkSK5EFc9+71p0gRRlYPbSaKG+u Fn+debhtWgFXrG3M15IUS0dLtTqyrwO8f7rUxPw6cvZcXY7SXwstw/eE6bBrINOkCSr0r7NY/q8 MkdvQdMkTfNDNv/IdOTmHYUGVeMOQNNaF8m3dWvUG822wSPEpGzL9W0DnmwgoT53fRHFTmLD9ct BySL9MCzQ/I7JU6Pq21OLI8jaxoxhq7xzyWy+YhaOrhTA4A6IY+hV9NxpfqoAScVFsiEogneusc xP0m7f7/YJuTtCEtjonUmYKrD9OPlICZPGMSwwRmk7kUgEh+rjKtY8ngHL2KVNrG6SsT5UFq+NI h4z+ObLdY3GcoTs2q6jwtSVkBqLZE53BjP1ek9akpD5T1B3V/gDgdlG0Ii63v7U2eDE5bu7ONyU 7ZuzLiO7mhkyVu0tp+pz3+eEJsxsmD1OxSPFhoJYkv/zg01bjwhkBrQ/BSviGnSLN+dsWAk55If K2P6WqZ0r22Xm+g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/ocmem.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c index e8841d247953..6b6dd80cbc0f 100644 --- a/drivers/soc/qcom/ocmem.c +++ b/drivers/soc/qcom/ocmem.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -216,7 +217,6 @@ EXPORT_SYMBOL_GPL(of_get_ocmem); struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client, unsigned long size) { - struct ocmem_buf *buf; int ret; /* TODO: add support for other clients... */ @@ -229,7 +229,7 @@ struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client, if (test_and_set_bit_lock(BIT(client), &ocmem->active_allocations)) return ERR_PTR(-EBUSY); - buf = kzalloc(sizeof(*buf), GFP_KERNEL); + struct ocmem_buf *buf __free(kfree) = kzalloc(sizeof(*buf), GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto err_unlock; @@ -247,7 +247,7 @@ struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client, if (ret) { dev_err(ocmem->dev, "could not lock: %d\n", ret); ret = -EINVAL; - goto err_kfree; + goto err_unlock; } } else { ocmem_write(ocmem, OCMEM_REG_GFX_MPU_START, buf->offset); @@ -258,10 +258,8 @@ struct ocmem_buf *ocmem_allocate(struct ocmem *ocmem, enum ocmem_client client, dev_dbg(ocmem->dev, "using %ldK of OCMEM at 0x%08lx for client %d\n", size / 1024, buf->addr, client); - return buf; + return_ptr(buf); -err_kfree: - kfree(buf); err_unlock: clear_bit_unlock(BIT(client), &ocmem->active_allocations); From patchwork Wed Jul 3 09:42:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721597 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 834471411E0 for ; Wed, 3 Jul 2024 09:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999783; cv=none; b=bOqnojIBy7s09M5kmQlEUDwK/cxOLtGkh+ww++UKbI5XNNlFY5RdXYo6w8OmFD/uzQ2X82d3JcknwPx2Ax1koWey66ZSgq/tTq5Lx7ZGDYEgtuX2tGTFo/MSF0U8MoBKZk9wUYi2lycGqprn6H5Ukj23aVZjMrlY8n2NMAlTp30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999783; c=relaxed/simple; bh=qpxrmTREuNaHHrdQzgu1e/L+P9VsCpf8GWp7U06TfTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TcVeqXqQtR3THCSU6SmJmj4L6JtKxnapSBh0aFTyXHoF9qYk077JIZACHs94ddQoS6SzVsVQN+SoKyzITkAKM9ie5v6pRJ+/3mt6Z7xw/fogUHHEhhXm9MNmeI61I/lDaXUn9b5xz7M7phcGJa4sH4hiT4HKCVQsqOAW4vXHlrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fAeYcvXG; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fAeYcvXG" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-367940c57ddso250506f8f.3 for ; Wed, 03 Jul 2024 02:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719999780; x=1720604580; darn=vger.kernel.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=KS5iVDe1obLhEwpLoT+EWyyGo/TPfbyIkExLZDp79p4=; b=fAeYcvXGdiruT1GG2fnhiqGzviJIfwruiv6Ie/rwTiSp/wWz+p4oJbULIrqLe1QFQe 30Z5+5sc12KBjJOonNbgHsGMHbb0MjkNY9W08LGH8kcseO3mMQcebGp3Dt5/ZWYSIXP9 YCg1hWcOgiT6Fkj0boC7at91fIeQla7n+cytwZW9N1V6YtysC6j69wz19zPdkbjBN0qD WktVsa3PI7MP3b8S+z6p2tz0CUhNBcEEMQ8qiawQezH+xdTSd0zMsdrNYpHJAx4C0meQ HcZeG2yVnrP1XnC6YIzaWuFebpW1w4Uv9BrGDOrvqG7yyuH5HzUt/2Hm6pZ+nN3pdnVB DMdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719999780; x=1720604580; 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=KS5iVDe1obLhEwpLoT+EWyyGo/TPfbyIkExLZDp79p4=; b=QotR9UhBiJvrqPVDvveRjVggt872ruDcIQCIbFW2fCXe2ljx0jQCeqC3BSjkUkg3qV nw11Lznans2t2ryOlmb+Z+MJmacBnocJJaPG0dwXPBNtaBnDn6CoMg8y/F2ngxx4Ky0G I/Vc/kFLIRPmkcF25GQCJeeS/nadgwL3gFymJVbqNTAN/YfH0uBmgLHkvHYVbkhe78op +CPRz7COathfoXljok5507dSrwN83t/VNxFE7s3BN+tDabH39iQBpTz2dRR6j7HtGAvK 63Oc7iZapoda/F3bo5a/tlD4g6Fl+MdcYpEqP5zHs1PSITIxqO0vl7DARtF0TTHJXK6y AtYg== X-Gm-Message-State: AOJu0YxoWWst9tth1OQtoZ2QzuEF47wL+KsK6aw7FRAU5x5ZhoORqszv gIfWiCCEFVkQI+7l/x5guoYLg0I6713DTpJ5XZgQvcIDTQpcQfJprdeH8CSk76o= X-Google-Smtp-Source: AGHT+IGxe93V1JY+FgRSUXokHtoTw1Cnd90wqvUvteioTByC5F3kobDqHNkUL6qu4wdsVi0h/tayjA== X-Received: by 2002:a5d:47af:0:b0:367:434f:caa2 with SMTP id ffacd0b85a97d-36775627d4dmr9358064f8f.0.1719999779823; Wed, 03 Jul 2024 02:42:59 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm15341394f8f.100.2024.07.03.02.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 02:42:59 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 11:42:39 +0200 Subject: [PATCH 4/5] soc: qcom: pdr: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-thermal-const-v1-4-6e59e139c65d@linaro.org> References: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> In-Reply-To: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4629; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=qpxrmTREuNaHHrdQzgu1e/L+P9VsCpf8GWp7U06TfTg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhR0agPr2ydUI703BLOJm92MpT5P4Ug9p19B4/ V2j5arr6aCJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUdGgAKCRDBN2bmhouD 15HkD/4mPJtxbfduWCVlQ2Ud2+O/dfZBP1x5bFZbyQ1RIm01TwvHVpLPmzGTZPrwLaUcY/5CTIG t6x/P/bfHbewKwehMh+SPSydHRLs3eW4V/4HFx11hl2tOL8q7n+uzzfdp2ENOAWRrH4ZCt89BlD 3LgSjqt+lvljDUh/Y1+Mn4DV3SJi8CmNPLparB899ityH6K45PNkipxKAAH6/s7H/78o4U+hdY7 ulSNfkZBDbKEGrwwpFRMAfxzOebedteO14WgirJZf/wdOGFFEda5WmxlL1R0FDWg60S5omxi3iM bjf6rGVsE0hzeSP1S6c4JXQWrZI56rrNLsLQ7MWyqaRSaIf8JIGm5hi40q2Ltp6Syz+/cMSjQnu DOFH+cSTryBenzx+KHFrux+IQ8Mlo39jADLjGrAQBur4Hy6BmXbZbp5iRIEeuTSZla4ogjVrUQW wlajOYWXQkcv4/lzklWA7jAplf16b7Zkna6TpIC2z0XL8/N8wO99IQZV2khEsqGTixdxKBS2bVq LsoM+tPR3Uwxa216shRoNjAs64sgqEJKT3kij947i5vpCI1OlfsR/spQpcjHwpGkr2t8+ZR1Usn +d4l61vzAdn84/6/BlSnHiLcAOvtDqPCsRKp9r7XqY5P5F+zQ50bNHI0oo1T14aaFLf6LdzOIOH Wkx+gT6U9DC4gwA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/pdr_interface.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c index 216166e98fae..328b6153b2be 100644 --- a/drivers/soc/qcom/pdr_interface.c +++ b/drivers/soc/qcom/pdr_interface.c @@ -3,6 +3,7 @@ * Copyright (C) 2020 The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -396,13 +397,13 @@ static int pdr_get_domain_list(struct servreg_get_domain_list_req *req, static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds) { - struct servreg_get_domain_list_resp *resp; struct servreg_get_domain_list_req req; struct servreg_location_entry *entry; int domains_read = 0; int ret, i; - resp = kzalloc(sizeof(*resp), GFP_KERNEL); + struct servreg_get_domain_list_resp *resp __free(kfree) = kzalloc(sizeof(*resp), + GFP_KERNEL); if (!resp) return -ENOMEM; @@ -415,7 +416,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds) req.domain_offset = domains_read; ret = pdr_get_domain_list(&req, resp, pdr); if (ret < 0) - goto out; + return ret; for (i = 0; i < resp->domain_list_len; i++) { entry = &resp->domain_list[i]; @@ -427,7 +428,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds) pds->service_data_valid = entry->service_data_valid; pds->service_data = entry->service_data; pds->instance = entry->instance; - goto out; + return 0; } } @@ -440,8 +441,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds) domains_read += resp->domain_list_len; } while (domains_read < resp->total_domains); -out: - kfree(resp); + return ret; } @@ -517,8 +517,7 @@ struct pdr_service *pdr_add_lookup(struct pdr_handle *pdr, const char *service_name, const char *service_path) { - struct pdr_service *pds, *tmp; - int ret; + struct pdr_service *tmp; if (IS_ERR_OR_NULL(pdr)) return ERR_PTR(-EINVAL); @@ -527,7 +526,7 @@ struct pdr_service *pdr_add_lookup(struct pdr_handle *pdr, !service_path || strlen(service_path) > SERVREG_NAME_LENGTH) return ERR_PTR(-EINVAL); - pds = kzalloc(sizeof(*pds), GFP_KERNEL); + struct pdr_service *pds __free(kfree) = kzalloc(sizeof(*pds), GFP_KERNEL); if (!pds) return ERR_PTR(-ENOMEM); @@ -542,8 +541,7 @@ struct pdr_service *pdr_add_lookup(struct pdr_handle *pdr, continue; mutex_unlock(&pdr->list_lock); - ret = -EALREADY; - goto err; + return ERR_PTR(-EALREADY); } list_add(&pds->node, &pdr->lookups); @@ -551,10 +549,7 @@ struct pdr_service *pdr_add_lookup(struct pdr_handle *pdr, schedule_work(&pdr->locator_work); - return pds; -err: - kfree(pds); - return ERR_PTR(ret); + return_ptr(pds); } EXPORT_SYMBOL_GPL(pdr_add_lookup); @@ -651,13 +646,12 @@ struct pdr_handle *pdr_handle_alloc(void (*status)(int state, char *service_path, void *priv), void *priv) { - struct pdr_handle *pdr; int ret; if (!status) return ERR_PTR(-EINVAL); - pdr = kzalloc(sizeof(*pdr), GFP_KERNEL); + struct pdr_handle *pdr __free(kfree) = kzalloc(sizeof(*pdr), GFP_KERNEL); if (!pdr) return ERR_PTR(-ENOMEM); @@ -676,10 +670,8 @@ struct pdr_handle *pdr_handle_alloc(void (*status)(int state, INIT_WORK(&pdr->indack_work, pdr_indack_work); pdr->notifier_wq = create_singlethread_workqueue("pdr_notifier_wq"); - if (!pdr->notifier_wq) { - ret = -ENOMEM; - goto free_pdr_handle; - } + if (!pdr->notifier_wq) + return ERR_PTR(-ENOMEM); pdr->indack_wq = alloc_ordered_workqueue("pdr_indack_wq", WQ_HIGHPRI); if (!pdr->indack_wq) { @@ -704,7 +696,7 @@ struct pdr_handle *pdr_handle_alloc(void (*status)(int state, if (ret < 0) goto release_qmi_handle; - return pdr; + return_ptr(pdr); release_qmi_handle: qmi_handle_release(&pdr->locator_hdl); @@ -712,8 +704,6 @@ struct pdr_handle *pdr_handle_alloc(void (*status)(int state, destroy_workqueue(pdr->indack_wq); destroy_notifier: destroy_workqueue(pdr->notifier_wq); -free_pdr_handle: - kfree(pdr); return ERR_PTR(ret); } From patchwork Wed Jul 3 09:42:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13721598 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 614391422CC for ; Wed, 3 Jul 2024 09:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999784; cv=none; b=mRAoju5m87DY76vosr5exfJ3T7DSF0ye17g700fjUOi1DtthUPT9cCMkTQOZHyXV5j4qHw4dwixADDLa4c8llYsWiN9tg/jwBPt4IErBdxv3Th24B0IJq2Ppj0jyGsaNH5WRg5HZ/S8dKTO+CJ3t6VMspfoauIx8r6J/yQsNknU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719999784; c=relaxed/simple; bh=Jq0jlG89u9hud4QvxGvDm+WMAUvi4Tm+sc+lYy6IEW4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Eq/uJEuQKUQYpgl48smVHoTa1XQzzhH9FNNEnPLEwvrYnHkovRGJyoQVNtFtzS/PkZsXm2aq6/m14AHRB1zJCFoeWxN/t/jElnr8P5LkDKOb0s+lqty+iMoboHZ3oefXe11vVMhCHqu/qHiMTDF8dsP3ld2yuxxqk6LXwx2vffQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=yFz7ZOMX; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yFz7ZOMX" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3636c572257so3711496f8f.0 for ; Wed, 03 Jul 2024 02:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719999781; x=1720604581; darn=vger.kernel.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=4pYRZX+NSiwidYn0MWwg3SiL2WiSTwldzzZjg+SAT9I=; b=yFz7ZOMX+28Sv80KaOvXPSjX/A9C+Cb3SvljNm7vXODFgLinx6p9f6o/lFSZJa614z TizqmposHfHIBHZb1cgBoNA93iy3/3FVco7iqA7Qb9BJtk7vg6mdkSL84uFFUJx/EvqS i1WtcDzHMrSI6Iz0LR3wsoH9aKywMQ2XfO32Gsz8YUgXeEZ+JYQkqsVGPL3/af5Z5VE0 C/BYNhDhWb53w8MTdcKnZuHHBeFYpwehjIUZKhk9RKIlbfYamXbw8qlr2dX4JjVCoz23 L+YtwLg5CNGMoLhb0qnFjUstLbXLBJUwa7xveaEKLwwBG1+O3zxMvA3weDO2rp2YI8mc veZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719999781; x=1720604581; 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=4pYRZX+NSiwidYn0MWwg3SiL2WiSTwldzzZjg+SAT9I=; b=aOWNvBqrFzuJ06ku94EUmVUNA60kTbA+B7Syc52/o573SmBVDAaQpeduqB77XRwQgP QNTaOLSskAOtDH3UU/1PD7jiQJKwk5Fs1imOrqO1r8BLvBQ65M6fcEmvCnXoZwsJg6i/ vVe2DGYTi0EvQkV3UzWWp8Y6B0ffjvsvX5xjPTaXz5cMmom9Vfg1jhnxEvUbl79tOnvf ipgZft4ZuoYExBHsR/R8B5jAR8QmD+pPZpMbxW4MHhbNisUyNOfWcdVjf3IzAumd2xFj Dp5R1Q/nDdQxbwgm+32vrxHY4aEkWctCI6gQrHe7wgSBgv30r3zWH6vIAQZx8TDUMkXX p9Rw== X-Gm-Message-State: AOJu0YxB2u/ggB3HS5iN8Dy51t18p1kZUYtrVZlP/OHbeJjH/qCn+1N/ nS3N5hcW0LgfASQm2Mv98x9NQY2Tl3uNvOkTeK1D2iCZCy/3q45ViT2GQcBcS0I= X-Google-Smtp-Source: AGHT+IFWB4DW3FsA6wGH0ff7ZiA+oTRSHRSUHHe3nL56wU5YlOkiMjj2tYWvcvQcU/QIqFwdzi6Sig== X-Received: by 2002:a5d:6852:0:b0:367:8f98:c501 with SMTP id ffacd0b85a97d-3678f98c65cmr1690529f8f.38.1719999780870; Wed, 03 Jul 2024 02:43:00 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm15341394f8f.100.2024.07.03.02.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 02:43:00 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 03 Jul 2024 11:42:40 +0200 Subject: [PATCH 5/5] soc: qcom: wcnss: simplify with cleanup.h Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240703-thermal-const-v1-5-6e59e139c65d@linaro.org> References: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> In-Reply-To: <20240703-thermal-const-v1-0-6e59e139c65d@linaro.org> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1904; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Jq0jlG89u9hud4QvxGvDm+WMAUvi4Tm+sc+lYy6IEW4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmhR0bcBnmEh+GBsRCoRqmtTRL5Fmpc/yV0AnNM 1D/dJe8iQaJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZoUdGwAKCRDBN2bmhouD 11EFD/wPkjo6yn0annMs8pDfoUHjIpLBQ+3NuImJ1F6ieXBKkgf9n3tvlYMqXYGHs3Cl7aWSbw2 pbgPRDYjrnBaXoRovrylyXGnmCpnt/SRSpWgXL8naTDADYS38EMBrEoV9GiMUEEc77WxEkgv82X wJz6kQs+/gsfbURh7nb1+iU/owcjoMld+dh/biNLs9v+zdqNlJSfR9YX2XmeQ7baXXHoSSEmrtF ivOqej5DvFkMJMpsKHPtiX7tw669rxVJrHsPRYmwkDQqsnj2yf9m4RiX8nhsvQh7ZuSccIpbMPP 5a9unMamwFS5WqTpaEbPpUiMI13kmcCkZt4M3UP4VDlUspbl2bF+87Mftx8GJuC23hAdGsuzg+X bMp9eNEOUqQtRU8Vs5o0tkvTlSrgLja1T1jCENEDj45D75tVHZnHMacQZKZHtPfQHgOoZJ+ljod 9u3mnDVQEeJBu+NwKHq3tuoOg8YVuq2hYiggpO9P8t9lDSGz663NcyEMp3AAHAKv1+0vzNJlo3+ 0XR7FsE40AgZ3wJ9K6+IlaqTjQ4nnoiOALx3cb6nlVuxDQ01UpjmtzUKHqsq7EvjMtT+Q6Ozh/p rGBT4z5SsQeiwq6yNSYkTBZNMt6a06A0XkQvIgl0ZR+1LMKEZEkcEXHNkxGhi2O9FJlgTHbONJm lEVXlpn4UvZYg7A== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Allocate the memory with scoped/cleanup.h to reduce error handling (less error paths) and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/wcnss_ctrl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/soc/qcom/wcnss_ctrl.c b/drivers/soc/qcom/wcnss_ctrl.c index 148bcbac332d..62b424e90d90 100644 --- a/drivers/soc/qcom/wcnss_ctrl.c +++ b/drivers/soc/qcom/wcnss_ctrl.c @@ -3,6 +3,7 @@ * Copyright (c) 2016, Linaro Ltd. * Copyright (c) 2015, Sony Mobile Communications Inc. */ +#include #include #include #include @@ -198,7 +199,6 @@ static int wcnss_request_version(struct wcnss_ctrl *wcnss) */ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc) { - struct wcnss_download_nv_req *req; const struct firmware *fw; struct device *dev = wcnss->dev; const char *nvbin = NVBIN_FILE; @@ -206,18 +206,19 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc) ssize_t left; int ret; - req = kzalloc(sizeof(*req) + NV_FRAGMENT_SIZE, GFP_KERNEL); + struct wcnss_download_nv_req *req __free(kfree) = kzalloc(sizeof(*req) + NV_FRAGMENT_SIZE, + GFP_KERNEL); if (!req) return -ENOMEM; ret = of_property_read_string(dev->of_node, "firmware-name", &nvbin); if (ret < 0 && ret != -EINVAL) - goto free_req; + return ret; ret = request_firmware(&fw, nvbin, dev); if (ret < 0) { dev_err(dev, "Failed to load nv file %s: %d\n", nvbin, ret); - goto free_req; + return ret; } data = fw->data; @@ -263,8 +264,6 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc) release_fw: release_firmware(fw); -free_req: - kfree(req); return ret; }