From patchwork Sun Aug 25 05:16:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13776679 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 5877CC5321E for ; Sun, 25 Aug 2024 05:21:38 +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=H7WxrWJ62hQ2vKyvroZvAzkaBumF7Y0KoLKrYpStuCE=; b=yNaXtzLceRLRd81Nvm7oCmvEiD 9vrKo86JorHhUi25Y/2ObNlq3M4iQMbKlWvNtBxn88jzWo0fQs8NO4McF2hwqA+fgaIJTuHcvzLZF n9rTrMllpvlX52n6vKS9wN2OoFsPsxaeCaelWuzhQZYSenh8SF/QR6KDp4xafGxoRjIzzw48trS8h VLgdjU8NhkVmvMvVbyKfpm6FbqHCtA+EMCDx5QYL8fPryuHXmSUz/Dx9n2Ei+EYIOa65sXQqDZ6wC mXr5G8jKzrQNLZ7hP+WRfrMm6/VsnzDF2hSzOtw7Wfq2Wpa8P7pdvuDNIYgHiNM+2dvhs6oOPs/mp rUDGanvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5gt-00000003fFM-15A6; Sun, 25 Aug 2024 05:21:27 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5cL-00000003dds-2OVL for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 05:16:47 +0000 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-7094468d392so2671526a34.0 for ; Sat, 24 Aug 2024 22:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724563004; x=1725167804; 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=H7WxrWJ62hQ2vKyvroZvAzkaBumF7Y0KoLKrYpStuCE=; b=fVuE86pF+pvkuwHa5/R7TXoC2OjMMvxQZIYDhHipVI/fF/M8qqLx5/XGnwTJtoCti1 ayl3fKjaxZKBiqT1BQSPTyJ/dJGAKuR4lWeOurhIeAzchl5iS3rBaTBcTbAev9vTZrS+ MJCWk/Dk0xA2Y1HtnN4+m+3KzV0Xc84PvKGYbQuE2/OfQYK9HA7BlQQoC9c3Co0GXgXj lobe+FUKHSGMXFUftZJawXOnLquUq0jwdMSn2dDihDwt88SQX6mnIE4/251ByceiHxJh 6svf4XKKQzF+mfvvBnnE15sRf/EThFeu9eZMPkcTHK4eexPdtuAghbbY2pwMcWJXmOsA 82Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724563004; x=1725167804; 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=H7WxrWJ62hQ2vKyvroZvAzkaBumF7Y0KoLKrYpStuCE=; b=xL3apDt+k7gOizWyOkeJ8QZHGF0W8ppj4abxnj7JvOzfCYbrPCloIqjebZrhi6DEMQ fLGLC0SQQ3FWJGCarGLGpcZ84/gCRS5n8/j7QKPYeHpVKrbvE7F5md0ctyMDz4df83F9 9yhpDBUlMm4P3FaiUhIUMF73/8AyEkbaIAadIpH67BTN0CWjSsgcGyRQs9UJPF30VXWt QCGzAKR/tjrMkK/pr0cM8bFezz4kyMzrw9H2Y/moCXvjTmGc3YosobeAnpWrNggB9Ynf N0GgzoMWBdPu0aikDy4KRcJUQNXB+ysep2XxZW34sfKj2R7CFl+p1NVkoeHS1dcXq+W3 fUzA== X-Forwarded-Encrypted: i=1; AJvYcCVoukVClxub6bGOmHO8fmRZl+OK1o0N6esK5RtIN8MIfjeVPYR+kZBDRWrxQAwyeJdUZkCxQnsWH0J88DcIXXbR@lists.infradead.org X-Gm-Message-State: AOJu0YzutZfQZ63ykeN55gACsG1ohdJWapAF8itTomYyTp6temI8IFsg OK0He88j8XqrGMbeUbossJwEKxeV0toBj+Qv8lkPIPqvW3mYiUZj X-Google-Smtp-Source: AGHT+IH+QpbfxDnkPKJFQfMCjn2cIc8LsR3+E1IY+zf3Sg3+FogfeIFria8bka1eODj7ExYmhpbLgw== X-Received: by 2002:a05:6830:2808:b0:703:6ab8:1fe3 with SMTP id 46e09a7af769-70e0eb31f1amr8578138a34.15.1724563004054; Sat, 24 Aug 2024 22:16:44 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:66dc:ce07:b7cc:51ea]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ad55a94sm5622442a12.57.2024.08.24.22.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2024 22:16:43 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Michael Hennerich , Shawn Guo , Sascha Hauer , Fabio Estevam , Laxman Dewangan , Thierry Reding , Hans de Goede , Tony Lindgren , Jeff LaBundy , linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org Subject: [PATCH 04/17] Input: ep93xx_keypad - use guard notation when acquiring mutex Date: Sat, 24 Aug 2024 22:16:08 -0700 Message-ID: <20240825051627.2848495-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240825051627.2848495-1-dmitry.torokhov@gmail.com> References: <20240825051627.2848495-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-20240824_221645_637151_93F35B5C X-CRM114-Status: GOOD ( 11.69 ) 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 This makes the code more compact and error handling more robust by ensuring that mutexes are released in all code paths when control leaves critical section. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/ep93xx_keypad.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c index 6b811d6bf625..a8df957ef261 100644 --- a/drivers/input/keyboard/ep93xx_keypad.c +++ b/drivers/input/keyboard/ep93xx_keypad.c @@ -184,15 +184,13 @@ static int ep93xx_keypad_suspend(struct device *dev) struct ep93xx_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 (keypad->enabled) { clk_disable(keypad->clk); keypad->enabled = false; } - mutex_unlock(&input_dev->mutex); - return 0; } @@ -202,7 +200,7 @@ static int ep93xx_keypad_resume(struct device *dev) struct ep93xx_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)) { if (!keypad->enabled) { @@ -212,8 +210,6 @@ static int ep93xx_keypad_resume(struct device *dev) } } - mutex_unlock(&input_dev->mutex); - return 0; }