From patchwork Thu Aug 22 16:48:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 821368 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.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 5A9CDEAC0 for ; Thu, 22 Aug 2024 16:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724345340; cv=none; b=CPPi+RCsgOwDw81GmrsrqR5AUl/QLIiIWf+8Yn5+4mhIh06jr9Jee1NjY3Budbp5lzKahylbskh8XddSFh+jV8N99EYupdMS0Aci6UU685oF2qgSOFBUePkNQgIpwGsZK/sM9kV7OO4XGpHtbPsTf+BXSh4oXWn8OB0zOvJlcGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724345340; c=relaxed/simple; bh=7ngHf1J/E6UZCdoJAqPhOYaHMASi62RNsv+4T02DVO0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=L8QMZO+aglHs9XGE7doL13Qjv04fW+XEbOoC9IYeojRJR1qkMof0oQyBfiPUmvP4230q5xHRclXlSPQjLscBiLFqCv3NMWmGHszim473HW85wDakDx6polycxSU8kC7ODEq0qWYjrm1mRxJQF382nnGXcxIyjBMSVVAEXclbnKM= 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=RYm7BRAw; arc=none smtp.client-ip=209.85.128.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="RYm7BRAw" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42808a69a93so1798915e9.3 for ; Thu, 22 Aug 2024 09:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724345337; x=1724950137; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y/uPrqpj9NK/aRR9ivkQ1oqXqgAV9rXCTBKB3mCN+LQ=; b=RYm7BRAwR5CkQB3l/m7hKFnJKN0nRlDe4RjH2DdwTRLMj1DyhrKySKRT4mkIpDKHFM I1fezT/ADd8gAztFO3MByqrwZzoiKN0RSadf0NnuHrGzOK7Rvr1Qxo/MMNN0J9rOMxZC bB2C+ftYBxJw8G3LnwlX2lD1nwWjjMfxK2Nz2NO//Nu8C+hljLA6K2UqR34LFp/cxjgC BY+JKHyxo3mOZyg2BqIrdEFH7vleZ/jJ+gpPqi3tzcGYFjCRoLlsj7/tuUxpQEj+IwRc wjXYqEOB7QrIvoTTV9fz5rEVwNm0xZPwdoUf49qXN1HJl+pM4/fiOWSUcT/i7V3beGnD 4tmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724345337; x=1724950137; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y/uPrqpj9NK/aRR9ivkQ1oqXqgAV9rXCTBKB3mCN+LQ=; b=hETCzuzx+fYzPNVIot39M7/pp3detzgTh0SEZ3gmOkl2dry+G5OU89dofvuixNOVlC APddxa1Uu071RWAoF0fwzm/rVSyX87IxQWaZDtO4OShu7W2F/WbpvMKnnrmmBlogk0Xr fQdE9K+eE8Iprlj/A8JwTYkXMYCBy/EuTe0z06U/9A7pmdJ6kQ3mHML+4UZ39B3avksS TLpxmiI/Wmr7EzWulpe5PmgYqrgcfJb0Egb/QuHvY7sLF38+bEzjaiJqGejpVgGyJqfv ZcjFAZr8iPOGyBsKYNKeFI5pF4YqXll78Z4KMZBdWJZU1n0/DoOkLGmP3obOnFsxwqGU 9L/Q== X-Forwarded-Encrypted: i=1; AJvYcCUoN5FKXqn/j8/JVNyWtdACNMzdrMP2YkkrtybKzx0t/qFZSysUWKpvw9JPlO3+2L5YY9rAgsID4Tu0x53X@vger.kernel.org X-Gm-Message-State: AOJu0YxMZaGJ5kMgvdqCmBzLY4iEcFCCWjR+Jp40uTj94bK0pSNcu2F6 CHbEuaK1a0MOCHlZ/dhGPnUdxs3YCVOA52pXLPPGYaYil2zZfCINcPVg26FNrtQ= X-Google-Smtp-Source: AGHT+IFUODpqlZ8UTaxs48M78/4DVqeVEA2pz7iAWCpAl+BVIKgEuEHkLXgg2dsPoJkUiatJ7UoLvQ== X-Received: by 2002:a05:600c:4fd0:b0:424:8b08:26aa with SMTP id 5b1f17b1804b1-42abf0f7f81mr29841885e9.3.1724345336612; Thu, 22 Aug 2024 09:48:56 -0700 (PDT) Received: from krzk-bin.. ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abefc627asm68062765e9.34.2024.08.22.09.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:48:56 -0700 (PDT) From: Krzysztof Kozlowski To: Bjorn Andersson , Konrad Dybcio , Andy Gross , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 1/3] soc: qcom: pmic_glink_altmode: simplify locking with guard() Date: Thu, 22 Aug 2024 18:48:50 +0200 Message-ID: <20240822164853.231087-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/pmic_glink_altmode.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c index 463b1c528831..bd06ce161804 100644 --- a/drivers/soc/qcom/pmic_glink_altmode.c +++ b/drivers/soc/qcom/pmic_glink_altmode.c @@ -5,6 +5,7 @@ */ #include #include +#include #include #include #include @@ -114,7 +115,7 @@ static int pmic_glink_altmode_request(struct pmic_glink_altmode *altmode, u32 cm * The USBC_CMD_WRITE_REQ ack doesn't identify the request, so wait for * one ack at a time. */ - mutex_lock(&altmode->lock); + guard(mutex)(&altmode->lock); req.hdr.owner = cpu_to_le32(altmode->owner_id); req.hdr.type = cpu_to_le32(PMIC_GLINK_REQ_RESP); @@ -125,18 +126,16 @@ static int pmic_glink_altmode_request(struct pmic_glink_altmode *altmode, u32 cm ret = pmic_glink_send(altmode->client, &req, sizeof(req)); if (ret) { dev_err(altmode->dev, "failed to send altmode request: %#x (%d)\n", cmd, ret); - goto out_unlock; + return ret; } left = wait_for_completion_timeout(&altmode->pan_ack, 5 * HZ); if (!left) { dev_err(altmode->dev, "timeout waiting for altmode request ack for: %#x\n", cmd); - ret = -ETIMEDOUT; + return -ETIMEDOUT; } -out_unlock: - mutex_unlock(&altmode->lock); - return ret; + return 0; } static void pmic_glink_altmode_enable_dp(struct pmic_glink_altmode *altmode, From patchwork Thu Aug 22 16:48:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 821367 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 1DE9E1CDA2E for ; Thu, 22 Aug 2024 16:49:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724345342; cv=none; b=eBD8jYltHYFJ2KEcwtnglINVQD5qB796nU4g44CYXWNmtxcqa3jB2YOOAGm6rHdafvwew17hi+cPhWnTArDXc7onLo9u9+H1uTHfzZXYP1g9XhGMbMSwhkwovS22hwNwHyDSZItokNG2QpYraDbt29mhndDk2BalfveJX+Me5YM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724345342; c=relaxed/simple; bh=lgvrJ8aoF3ob8PNfM19iTWrPg0RJ64p0xDquFgIO/Hs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fD2oKHSKqiYhu0H7ZiS40qj6U1uMVVapHUnCScFsr8oTpA/fXREp4U/LZwLv+8XJgo9We51Q1dNCY2v5T5tiKrF3EnPlykiKKN0egBsOZo9mXF7Bgxhk+tLmqFqDvgIknLdpgEp9TXFHCRo9ychTjVSXSBvCglXbOir1NAlP6Cs= 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=r5mOcWZ4; arc=none smtp.client-ip=209.85.128.54 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="r5mOcWZ4" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4281da2cdaeso1802095e9.2 for ; Thu, 22 Aug 2024 09:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724345339; x=1724950139; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3MgKIFP5vj9lpxOte9EHXKK0r0k7d1Xhr99VIevfK64=; b=r5mOcWZ4v9eYg3gr3GJT5uDhgwhYDOMCxCbBtp/gG+XPKWoM4Qj+xtfFGq6UI8shPA Yc0VfeklFcCWOUc614tW8qRU4QeNPw62b/c/d6emBB7a6YV5nHeIZ5jV2zjL0kWv8+O3 csk1zax+r4aQfLINB/wpR/6wO6NC2BcQRB0X4+t0y55ddUACV3Yx4D2r2xzbUoS5JdVz JZ66vRTqMZaw6JtoyujPOogV9shu3FYon+vm3Uu35j6k+PQFZ55BqH3JLIZHnSIN4yK7 YcjjP4rBYQgGR0N9t8RfZPFBT8D+fn3ta/QSoK9NbdMK4CZRcSOy2b5GiOoowM3eqRhr 4S2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724345339; x=1724950139; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3MgKIFP5vj9lpxOte9EHXKK0r0k7d1Xhr99VIevfK64=; b=CFn3U8kQkvTUPnDcmE3lwvX/Du88g5ZJ6UfdYdG29Cs7NenHv3qL16i7OGulaIYiZp Szf1XWt/y5B4YUkI9EjTURWzChnPRCR9dcsg/qPK5Vpez6d4U+n6vghnm+x+3E+I+UKq DUo/9+LnNlgyhiLnqa/ufTAzzlgAQ+dh9kD87SET6WH2u6/up6a/J3dNBOtxAwN5dbdK 9sQAZhVZHzFn/zW5jD0k8cg8E1xyGx+eakZxXbMfVJrqclJN1ouBua1ExfZRLaS43hHI pO1F9uruTCBMOgObLKL68NVL2GP4fTs91t2OsKJ0KVMlxzI0t+ovLuQm+hNvM1EyjJ4k l9ig== X-Forwarded-Encrypted: i=1; AJvYcCUSA+wljah07hZP3wPti4ffcgD/DXfjcDFa2XYKwNcL1ca/PJRullukCb3ynDQvUrZSFb7c1fGHF8Ja2Kjs@vger.kernel.org X-Gm-Message-State: AOJu0YwMjzJN+S83lnhnvrFdzZA7/5+4HWOZqODBRKI2swAxcJ+FEjEb OLvK+lBUMm994nvCNi0oDBhUwOLTKHXFsIM0LG8lhuvglChKnhIfT0Q7SmSdsM8= X-Google-Smtp-Source: AGHT+IGWgVVW8NGHzfRv3h4x5tYOjc7g3TUO+7XqUYxknVGhDDe78fw9e2Lh6zARIA6ofN88ls2hrg== X-Received: by 2002:a05:6000:1fae:b0:36b:36aa:a14e with SMTP id ffacd0b85a97d-372fd8291b0mr2693229f8f.8.1724345339497; Thu, 22 Aug 2024 09:48:59 -0700 (PDT) Received: from krzk-bin.. ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abefc627asm68062765e9.34.2024.08.22.09.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:48:59 -0700 (PDT) From: Krzysztof Kozlowski To: Bjorn Andersson , Konrad Dybcio , Andy Gross , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 2/3] soc: qcom: pbs: simplify locking with guard() Date: Thu, 22 Aug 2024 18:48:52 +0200 Message-ID: <20240822164853.231087-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822164853.231087-1-krzysztof.kozlowski@linaro.org> References: <20240822164853.231087-1-krzysztof.kozlowski@linaro.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/qcom-pbs.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/soc/qcom/qcom-pbs.c b/drivers/soc/qcom/qcom-pbs.c index 77a70d3d0d0b..1cc5d045f9dd 100644 --- a/drivers/soc/qcom/qcom-pbs.c +++ b/drivers/soc/qcom/qcom-pbs.c @@ -84,16 +84,16 @@ int qcom_pbs_trigger_event(struct pbs_dev *pbs, u8 bitmap) if (IS_ERR_OR_NULL(pbs)) return -EINVAL; - mutex_lock(&pbs->lock); + guard(mutex)(&pbs->lock); ret = regmap_read(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, &val); if (ret < 0) - goto out; + return ret; if (val == PBS_CLIENT_SCRATCH2_ERROR) { /* PBS error - clear SCRATCH2 register */ ret = regmap_write(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, 0); if (ret < 0) - goto out; + return ret; } for (bit_pos = 0; bit_pos < 8; bit_pos++) { @@ -104,37 +104,31 @@ int qcom_pbs_trigger_event(struct pbs_dev *pbs, u8 bitmap) ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, BIT(bit_pos), 0); if (ret < 0) - goto out_clear_scratch1; + break; /* Set the PBS sequence bit position */ ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, BIT(bit_pos), BIT(bit_pos)); if (ret < 0) - goto out_clear_scratch1; + break; /* Initiate the SW trigger */ ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_TRIG_CTL, PBS_CLIENT_SW_TRIG_BIT, PBS_CLIENT_SW_TRIG_BIT); if (ret < 0) - goto out_clear_scratch1; + break; ret = qcom_pbs_wait_for_ack(pbs, bit_pos); if (ret < 0) - goto out_clear_scratch1; + break; /* Clear the PBS sequence bit position */ regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, BIT(bit_pos), 0); regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH2, BIT(bit_pos), 0); } -out_clear_scratch1: /* Clear all the requested bitmap */ - ret = regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, bitmap, 0); - -out: - mutex_unlock(&pbs->lock); - - return ret; + return regmap_update_bits(pbs->regmap, pbs->base + PBS_CLIENT_SCRATCH1, bitmap, 0); } EXPORT_SYMBOL_GPL(qcom_pbs_trigger_event); From patchwork Thu Aug 22 16:48:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 822244 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 8DB2D1CDFCE for ; Thu, 22 Aug 2024 16:49:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724345344; cv=none; b=CxiqGM+9INb73LPz0lxIJMc6otZNTtC4Pd85QU5td9jxvMrCpKJ8ib9pkmv5C/PMW+Jzsaaha55fM7H8QwM9CrL53hBOL47DgZMP4ILgd50gFPawrXl7gcan1HWg8SS8/fTPF6OnrwU4KEhk1eBAKWv4UM4SxxMpOho4X+lYfFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724345344; c=relaxed/simple; bh=MevB+qQ6YIteof+ZP702/oPm06OBrbHOvjn8I+MZjr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D8nAz6kR1ba9ybomBA0AY5Gn25ZtMY9VE28FB3KiSEJqw4WUziT4vfvbBz9NwZeo1ob+nSEbJLyOsWr5jXNmljhwbxyKuqYOTVSoOMQFAzL+a0QYpTRaGVSo5UL8OEu/0CoYhZ+T4ynCljqv7HJDCifjhT7+FZz+hYxoZqpJ+cY= 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=tTMttrZ/; arc=none smtp.client-ip=209.85.128.51 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="tTMttrZ/" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-427d71e746aso423765e9.1 for ; Thu, 22 Aug 2024 09:49:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724345341; x=1724950141; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wCSOOQBbc65Crx+eDy1f4bPe3yYik0noPUdHPZ2Q4cc=; b=tTMttrZ/W5ty+piNhJ+14ng9o0l8v9hkbFNXCoKxxiA+St3P2TMduGL7JrsTy/b3zb UxoMRf8i1MMu+kY4/SUoYc5pmtxMrqntljQQoMJ5jiIm95h+RCX3IwOjwM8JrPZgL2e1 yD1nZAYc/KnDIbp6wFYbPMDqfx601d1srqXl5lDLxLAhBfnArw/W6fmhPB8Jmx6onp2w OiJtYyIVwUosNp7uBqZT6OFNLdgNimd36ab3xqMKlqPYyrNGEQ83Ow/OVJxw0Ys8IrdC b0o6Vzldc2tdSm2YDdZR/88Vu3ZLuGdATQmFepmCuuiiNE0Atj30fBJQFzrh9Myjq7Qq 8h7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724345341; x=1724950141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wCSOOQBbc65Crx+eDy1f4bPe3yYik0noPUdHPZ2Q4cc=; b=hOzUEfz18gsUGPrkznEPakuIxOON1MTTDES0cbdkDOde9KXPqYqRVD8ZQAqarvu67x e91hYg7bhFNUkkeo+aZi8RQMYLME4FVCbSMW6TxSguyNnZizjVJEwk/kQ5/yPzbusO2M /uw0wgfeugpeIqoFrbs2w5mS7eY89EMd21Hir3A1Wozxp50ynpNH7MFcx4FdyeSNbCf4 LONbuZIGL3Usf7K+n0S+xjhVP656XlQtMg7SK8RsvofhhqeGKeHsFNA2BKYxtr1gFydR wFGmjoFQcbu0KueT2LTOHxOvyCx1hiGlIrZ/CfUjjx73j7eUPMulxnYcydEZbFFxkxxb hliA== X-Forwarded-Encrypted: i=1; AJvYcCXuEqJvCgatL+dZzC4ZHkOurKxpuxuj4ohL50mkYOzzp6/FM2xdl6eiA3mI87dM4GzYCjL88Gzrm9dQ1CPx@vger.kernel.org X-Gm-Message-State: AOJu0YyDtdwhQr16p6yST3T/LR2QUJjMwIHs2Il4eC5f4JsTiIaKAPVE GEN+s3C6ifQCwOlwEsgEZ/kPruhDV4gFXlgSd5Qzhvc/wTs07P+SG1sKQZSK0SE= X-Google-Smtp-Source: AGHT+IG+ji4y5pZk4uMPiZTqYIDcHBKI/EfdhUcrz2Rs+u3IueHjNPuHQ/B1l2iHyGoeSDwdbzApqw== X-Received: by 2002:a05:600c:1ca0:b0:427:f1a9:cb06 with SMTP id 5b1f17b1804b1-42abef82886mr30937365e9.0.1724345340783; Thu, 22 Aug 2024 09:49:00 -0700 (PDT) Received: from krzk-bin.. ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abefc627asm68062765e9.34.2024.08.22.09.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:49:00 -0700 (PDT) From: Krzysztof Kozlowski To: Bjorn Andersson , Konrad Dybcio , Andy Gross , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 3/3] soc: qcom: smem_state: simplify locking with guard() Date: Thu, 22 Aug 2024 18:48:53 +0200 Message-ID: <20240822164853.231087-4-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822164853.231087-1-krzysztof.kozlowski@linaro.org> References: <20240822164853.231087-1-krzysztof.kozlowski@linaro.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify error handling (less gotos) over locks with guard(). Signed-off-by: Krzysztof Kozlowski --- drivers/soc/qcom/smem_state.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/smem_state.c b/drivers/soc/qcom/smem_state.c index a8be3a2f3382..cc5be8019b6a 100644 --- a/drivers/soc/qcom/smem_state.c +++ b/drivers/soc/qcom/smem_state.c @@ -3,6 +3,7 @@ * Copyright (c) 2015, Sony Mobile Communications Inc. * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -60,20 +61,15 @@ static struct qcom_smem_state *of_node_to_state(struct device_node *np) { struct qcom_smem_state *state; - mutex_lock(&list_lock); + guard(mutex)(&list_lock); list_for_each_entry(state, &smem_states, list) { if (state->of_node == np) { kref_get(&state->refcount); - goto unlock; + return state; } } - state = ERR_PTR(-EPROBE_DEFER); - -unlock: - mutex_unlock(&list_lock); - - return state; + return ERR_PTR(-EPROBE_DEFER); } /**