From patchwork Sun Aug 25 05:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13776695 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 A607CC5320E for ; Sun, 25 Aug 2024 05:31:47 +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=TgrHzPeIHjCQToVGMM9JpdcPooP9HE7kqNjFtcQ3CT4=; b=gZenEHOLB3m0XfIt7gkDymlzZv P2qpCXBXTrEg6Q/tQ3YVwpffM2Ghi+BiO4I4+JZOLqj8d87yOPI0A/ZLo7PUVKujiVrRRJXJ3Zj0X cHOlvZ1jaGAHpbxSewnn7EKZdoKuoTBaseCvDwtG870uAbAjTaBP1aF5fME5uA8JrzVPlvKGCZxKj 8WlrqsMJd/wkWX9pmV01EYI8OAhWidIgul7Ar6pq5WksSMSKJOlEnWIcrFJ7EAiBjnnuBhDg+P39v CHgHN7Hxywl+wmDgb11HE5/K0aes7fqjc5tCXJR1u5L4Toj9zV+lZHjfPiBklChWzqzlVTYA+li7r AdcWJv+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5ql-00000003hTJ-18pY; Sun, 25 Aug 2024 05:31:39 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5cV-00000003djg-30ba for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 05:16:57 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-71433096e89so2772775b3a.3 for ; Sat, 24 Aug 2024 22:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724563014; x=1725167814; 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=TgrHzPeIHjCQToVGMM9JpdcPooP9HE7kqNjFtcQ3CT4=; b=gy/ocSp8P4cl+i9WIdi3TQj7HgOP0N1BqM+RdorF1ms2WqokB/X48o/lsfykhbd3rp Dl24cnOkH4XcyG6Ofincr0O3fH89plVOyb8pJFEUmSWULQOvMfN9NvCuGR2Qe1+5bVpV Eon//hmnGWAlrPfATDcM1dui3JoEM1WLrTlKctUKexi1EXs3lqg+k1qgIig6LDnbIcD6 uXrctZO4DJm/Z+JuEC/uvTWay3Tg5G/UZIsjAPP8V41/9A4Irtg25HHDUn5g89gnIrhD ItpF3ImXqv5jVeLngNNK7atMjxdRrCp8KBmT146TS8gxGMlRwObzzYBlB0feT9U25q2C ThJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724563014; x=1725167814; 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=TgrHzPeIHjCQToVGMM9JpdcPooP9HE7kqNjFtcQ3CT4=; b=ML4N+zW5OIfIB567rTZUdReY9PMhZejC316/ZtX6pmOKRi306mEUGU1ajCUw7Zgw5f wGbckEDWS76SSfWdC2hIx+DdcUPUHSPzp6uWNshAF2/eOpJsu+JrPIu2XDDakVNnhKEr o/2vUWEzrBkFKRvX6JE9vNa6GdJbJ5ht6bCLb/rWV7yVD9TeUayFRJo5A7GtzSELs2Uk +nRq+LKVmHgiOV2WFBplYU6CFNPfphpueMuvTgDSADuZ79pkjUzpEC6FnhlfhgKagS/s ZYNvIDOAW8n+bZJBdUPUZfdzjmeUd7xglTRzuW5JZuUt8lsghZ/NXAb5ybZRGj7cRlWl N2rQ== X-Forwarded-Encrypted: i=1; AJvYcCU9twbJF8LJ8q++J7sY8WgEZSkor2zbU3nZcDOEAKQAUlZeRE/nWYOjOV6qqsmlkmWd8vclFRmVSeAUrRChEKG1@lists.infradead.org X-Gm-Message-State: AOJu0YxksnN9Dngtqv8MTqz19oYPvdkIBY2g5UKvQYEVT3c0NXHHFsHx TRSUlX9qE3MydWdmT42Tfoe4IdldPINnvZe786+bR2i9CGmzBsfF2cHbdw== X-Google-Smtp-Source: AGHT+IG9GzB5hV+R3jUFqV7C8FiDWaB5skbl01e83Rq6Yxznn6igCC+xVD3kT7dOcBsXXHvExd8ddg== X-Received: by 2002:aa7:8895:0:b0:70d:1fbe:b96f with SMTP id d2e1a72fcca58-71445893b63mr6876250b3a.21.1724563014434; Sat, 24 Aug 2024 22:16:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2024 22:16:54 -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 12/17] Input: omap4-keypad - use guard notation when acquiring mutex Date: Sat, 24 Aug 2024 22:16:16 -0700 Message-ID: <20240825051627.2848495-13-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_221655_778747_8AEF64C0 X-CRM114-Status: GOOD ( 10.71 ) 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/omap4-keypad.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 040b340995d8..935c2b27b81c 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -144,7 +144,7 @@ static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys) { u64 changed; - mutex_lock(&keypad_data->lock); + guard(mutex)(&keypad_data->lock); changed = keys ^ keypad_data->keys; @@ -158,8 +158,6 @@ static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys) omap4_keypad_report_keys(keypad_data, changed & keys, true); keypad_data->keys = keys; - - mutex_unlock(&keypad_data->lock); } /* Interrupt handlers */