From patchwork Sun Aug 25 05:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13776685 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 A2F90C5321E for ; Sun, 25 Aug 2024 05:26:30 +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=TIA6h/0y/Yz1gsinooJtctLwNKMffY0VfmYdSxulMqA=; b=YwkAvxlysCu9kn+xHcMcLIjOUO onfVs6urA/UI0FBEZOO3WzGV6guHyquLHH/gcS+ZYW05lo5oaaUDJeLYZye0MSvry31MEJOTsny8U 4d81mNHvQH9fgOyc1U2BzqPVDRQm34FV/F7spefL5S22NbM39r5u2IZszxNn0F3qf8BQv0ZAsQtgD 62v09xwN6gTl4fmfisWoSljl4eVHaIRefsoLbnoSnZAG+3jddP4agz23qNMn2xVM+j5dOA19zF/sy 6zA2EiGtHzO2eGazhJMPR7BVMkFjxyGsePdy6l6uK0Kk7HHPbgTLRMF4mvyCG7ter8UeHlNztihMK MmCH/Q/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5lc-00000003g4A-11fq; Sun, 25 Aug 2024 05:26:20 +0000 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5cZ-00000003dlp-3kkI for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 05:17:01 +0000 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-2701824beeeso2600007fac.1 for ; Sat, 24 Aug 2024 22:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724563018; x=1725167818; 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=TIA6h/0y/Yz1gsinooJtctLwNKMffY0VfmYdSxulMqA=; b=REmkbRuBz9o/yf/aNepcFR9p0/xNZZJXkQEuDVBW3yt9sWkoydT7DzxLokjjq7ofEe nDPUX0nZMJ3LGHtShaR/DnLrwiZ4xkhMjrStbymt2pvI9EONMoWa1Jmsom47LTlN8otM gL//5xW38+fFGk/hXEULCho/EJaYL17JgA6B5xaVvqkBJp0lnhVy5M8fNqQb6omwHHVF LPzlM7qYpy9y7QjCrVrn08DkUt/pT80ZRc/6PQSsORA8cYMaOHQEH6POQca+uSEUT98U mpipupNFTQCIFPvosbx+sX+tZpM6vhacKI8p/4U1vqNZLBVJ1BYRRNXkcoyG58Sni9d+ QchA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724563018; x=1725167818; 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=TIA6h/0y/Yz1gsinooJtctLwNKMffY0VfmYdSxulMqA=; b=Y3yvx5zMCLpHTelhG//hNQk9ZRGYNVTzA0oflpry91a49+z+DSfv83pR68qGhvHSUN bZK3EuuyYNSn8QEbPOD1cvBzKEe5HwoNeRAiOSDf0v4IdK8mYZShMDgm/2OBQ5NddUk9 EwaYZx6Vj1C/rjqUU9j0SYnav/GweowTZYjHk4VFJTbTidOWlIKqhnMf9VvOnagd1Y2F uzKdG74nhngpqFca+DVXZ+T+YaKFxPLKoPv/7x2rXI1Y0jfJKGCqBU2cOPGZM5EnalPA cjNL14/1CIzI1KxRq3y7fLp/Ap0/Oel2wAIiCpG22m/BL2DudBjqLs0dEqacojonSWZN LUmA== X-Forwarded-Encrypted: i=1; AJvYcCUTOYjrXREcdYCDlbsZhhEQldjB1FhF67PkHqLPPp7fV4kZJr8r0SD/kaXOv35ROKy0wIZooLaXGpwo0IaUAhXp@lists.infradead.org X-Gm-Message-State: AOJu0YwBO3u0yXbhtAtAQCfsroTKNu55QweSCvS92HfqajxquqDc9Okk cXrakqag2EMR5eUbQe9Z5Immm+vN0hHh9mHhUfpNWoKGVv7qNi/Y X-Google-Smtp-Source: AGHT+IGpby1l5kr49d3Ag7IqPDJ5s1jsbrR0tYx5ZtWy5I5Dnd9r2dAg+L7acAO7bMwntLfgmcpiOw== X-Received: by 2002:a05:6870:548a:b0:26f:e09f:6090 with SMTP id 586e51a60fabf-273e6620ee7mr7487035fac.37.1724563018382; Sat, 24 Aug 2024 22:16:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2024 22:16:57 -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 15/17] Input: spear-keyboard - use guard notation when acquiring mutex Date: Sat, 24 Aug 2024 22:16:19 -0700 Message-ID: <20240825051627.2848495-16-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_221659_958002_A16490C3 X-CRM114-Status: GOOD ( 12.61 ) 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/spear-keyboard.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c index 1df4feb8ba01..2d3f656e59dc 100644 --- a/drivers/input/keyboard/spear-keyboard.c +++ b/drivers/input/keyboard/spear-keyboard.c @@ -274,7 +274,7 @@ static int spear_kbd_suspend(struct device *dev) struct input_dev *input_dev = kbd->input; unsigned int rate = 0, mode_ctl_reg, val; - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); /* explicitly enable clock as we may program device */ clk_enable(kbd->clk); @@ -315,8 +315,6 @@ static int spear_kbd_suspend(struct device *dev) /* restore previous clk state */ clk_disable(kbd->clk); - mutex_unlock(&input_dev->mutex); - return 0; } @@ -326,7 +324,7 @@ static int spear_kbd_resume(struct device *dev) struct spear_kbd *kbd = platform_get_drvdata(pdev); struct input_dev *input_dev = kbd->input; - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); if (device_may_wakeup(&pdev->dev)) { if (kbd->irq_wake_enabled) { @@ -342,8 +340,6 @@ static int spear_kbd_resume(struct device *dev) if (input_device_enabled(input_dev)) writel_relaxed(kbd->mode_ctl_reg, kbd->io_base + MODE_CTL_REG); - mutex_unlock(&input_dev->mutex); - return 0; }