From patchwork Mon Aug 19 04:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767902 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 5E57DC3DA4A for ; Mon, 19 Aug 2024 05:03:21 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ygqoPfWAW6OFjzFeMVvvEaUInHc1K7ny5EjqPZNE9l4=; b=vm91UTNoApfzSNzlL4VMyhQMfx ZX17ucwd1DFy5HRWs98pTVK7N8B4tKlx0442shbif1ltQEmpGjeVGwtEJ3AqSWY/SFxtYhezUQVO6 5XszAh8quyWxeEojuZigUGqsgRbh8vWevxIwtZJTTIX8eSNh9toCLMqpGUmdMuFC260zFO0nQ5gfN tP9fk4M7PQmn6c/UqpYLdn131BbbadKuBgEPKFREPAtz5e6nZPXGgB4TbM8eD+Or8/Cu9ni9VyPs/ T3gTQK96NaAlaVz9sgABl7rQR5Q1yPL9uf6sGMlT/VJw8PTyVXK+8bSNhvM/xJa8rmRyJNJs71rUu g6lHmCNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuXt-00000000Mm7-3ny1; Mon, 19 Aug 2024 05:03:10 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTS-00000000LXb-0SCM for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:35 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-7a1c7857a49so2215514a12.1 for ; Sun, 18 Aug 2024 21:58:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043513; x=1724648313; darn=lists.infradead.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=ygqoPfWAW6OFjzFeMVvvEaUInHc1K7ny5EjqPZNE9l4=; b=DSW55EGVrVvP+/uJ/NEhQBQpVt5UvWsDiljoE+/PfNWglci9kxADSa83pxVq+3gymt sfCrsgvQWi2pwiUTIG80eqAs3Ft9lzeaLISUCp7yW/O1vGwYpbhzqpgyhkLk1/htFYcL NWOcrFtKc8E7IaawlcQNqFp2BO7Rd06B49SEYGxM3vYlMgExR97T2p3/Leip2iyD1J1D a8GJKaZsX/YnrHctzsb9XpwH4jdEvqCG1cVs6TY7nQhZxbgE9EnBHYzXG07JLX1zTiLR UF2gdfBKvW+iyobIRKwC1VYcvpDuKhvcnxJXL3TlX68s178sigfeJu9fT0VJIAFJdcv6 NQJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043513; x=1724648313; 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=ygqoPfWAW6OFjzFeMVvvEaUInHc1K7ny5EjqPZNE9l4=; b=Z/p8cGR/vzQd+EYr4M/v0wSxxNq6SoZzNCAnBAeKjb4rQIl1MjWj6dMCWqDLQ1v9rY jeZtvVY0k3i4im1JMzuq/AYT82s8Sr0/mEeQM3Ay6L/MsQKAjwk+YCTXdYhU5b8Qmq8t XCE9hJiaTxhhYvtdBfMXCzEH60Q6E5NRKB+B/Ij/SzEbxS6YGEYw+6dMt5a4RYFoKCWV jeZoqR3gEYDFisaEqvhxKJ9mbrs3Nhz/RsPXcIsVa3yKK0O5hK+vWtmaUXD+T6uDsBQU w+OShMfrcDVQjO7XWbg2su1tg/atsYf8FkKbBqiWkh/aIPgd1a9uk01eDiPyHr3gzqU+ b64g== X-Forwarded-Encrypted: i=1; AJvYcCXADInQbbUFAi6w9u3pQNb4WaCwH/kWun+GCDvVH17deHCfsu8xQ38rpMQifoK0UNqCfD2EbdzBZi5wLf87r27d+R3+62OAVdTlvomGV3nwNSHBLsM= X-Gm-Message-State: AOJu0YzRQMkWMZPK7u2FexYQ68IUWcLquSr7x2eXQOFU4pl8BSnsKCYy oiEXFa3yH1yiva3cFu+/JlnQ48ZqrJKwxA11XaDYIbOlLmbAntTB X-Google-Smtp-Source: AGHT+IFeaM8qHan63qZff53j+wzJZr72I4+OcPJOuBS6lMPEx82cmFqJMPlxZb5d4552hWK/VzOVjw== X-Received: by 2002:a05:6a20:bf24:b0:1ca:6b6e:9aaa with SMTP id adf61e73a8af0-1ca6b6e9b33mr5884996637.2.1724043512829; Sun, 18 Aug 2024 21:58:32 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:32 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 06/14] Input: samsung-keypad - use guard notation to acquire mutex Date: Sun, 18 Aug 2024 21:58:03 -0700 Message-ID: <20240819045813.2154642-7-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215834_177275_AB3A0519 X-CRM114-Status: GOOD ( 12.75 ) 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 Guard notation is more compact and ensures that the mutex will be released when control leaves the function. Signed-off-by: Dmitry Torokhov Reviewed-by: Krzysztof Kozlowski --- drivers/input/keyboard/samsung-keypad.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 924327de4d8f..71f5b85b02bd 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -519,15 +519,13 @@ static int samsung_keypad_suspend(struct device *dev) struct samsung_keypad *keypad = platform_get_drvdata(pdev); struct input_dev *input_dev = keypad->input_dev; - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); if (input_device_enabled(input_dev)) samsung_keypad_stop(keypad); samsung_keypad_toggle_wakeup(keypad, true); - mutex_unlock(&input_dev->mutex); - return 0; } @@ -537,15 +535,13 @@ static int samsung_keypad_resume(struct device *dev) struct samsung_keypad *keypad = platform_get_drvdata(pdev); struct input_dev *input_dev = keypad->input_dev; - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); samsung_keypad_toggle_wakeup(keypad, false); if (input_device_enabled(input_dev)) samsung_keypad_start(keypad); - mutex_unlock(&input_dev->mutex); - return 0; }