From patchwork Sun Aug 25 05:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13776684 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 17E17C5320E for ; Sun, 25 Aug 2024 05:25:44 +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=6On2/1bDkxm+R+4fGzTtvwf3YjBZiAkFwRYzWZ0YLaw=; b=cdkRKNpuoh2uJsyVJaFUK4sl9u dkz9fXiQLpOWmEO6ViDVZNbzDxQRx3ER/mlNZ8vDBbeGUD4PYt8TCR04mC4tE1I7eBbnW6/RmOXJq +CWLbKoHpBbr9iQ/yhuIvVaBoOoPvkIPr0KtK7l7PGZqljOPDwrMU/bX/U++fVTWHPBp87H4cH6B2 wqhLwV2NgQrpQfBcZVeBfeiN6cqLw9qv1Mv1ntorfWz7HAjOCWqMg4lZ0UgMKxVhBpnZn/JBMpEvw ry8wcP91hQXvmRyfA2MIIXTv6jHn95RizmRowu5xLj95BU4a/0HSkCaB922IVx7cmEeTJBxxvOPkB XDbw7Kdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5ks-00000003fuY-3ItK; Sun, 25 Aug 2024 05:25:35 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1si5cY-00000003dl3-0v4a for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 05:17:00 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2021c03c13aso24234085ad.1 for ; Sat, 24 Aug 2024 22:16:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724563017; x=1725167817; 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=6On2/1bDkxm+R+4fGzTtvwf3YjBZiAkFwRYzWZ0YLaw=; b=mIwFpXDdIvztZhVaaMcWdIgSGEKQ0oYvefzU2jEm1xiSuWU5Awnf5vWTM67JpqAvPm qVebbslLtBnzPJS7KFHRxqw2lAa4rFebcWnyh201TBthF6f4UpNNyk1dwbiPTGJIsVjd sApZXHcvdQnRIarQNd0E4J4GVFK2PJWUxp0SIBPQZdMaEilM/jy4upfnfBjVKfYNb3sN l6MlxvxOmFiRP4CIrdyuPvzoegfCNvyFF3z16mdLR5RLQNIoUjtr3PzgttcD6TzM2AO0 g47oD511Yfa8w6MtZmkJ8FDfDfs5F2tz9Ue0oYQI66JE0jZwXuwnEuM6+hBh2Ev8iwaq A2gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724563017; x=1725167817; 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=6On2/1bDkxm+R+4fGzTtvwf3YjBZiAkFwRYzWZ0YLaw=; b=ue5CWkvns5RJ09nSnv1bZzQ65fJf6bLusCy7WPLFrh0/ohytqn6pXbM4o5ucru0hpG VAZkgST3PhGh99BLQ11dsFAFCOWaPgbQ5W8fz1bEqxVswUWD7B3GSUnHH41N6RL4HMPM XmJDRw7sUwLmY0SY1ZuYSEYlFXdSlLWjBK5K7zTbTkR3MYXyKdkUGLPHHYPPFjtgI6rv AXNtWYivo7qit909+LhISgGkwz0+veKslTKJfCeTqTVssdfVQnc+Y4yZzJbycREIygjB pEB5Cd+6t6dDlIF96LOt4aJo7lYlepuoBFi/Nv+ZtXiAu35lOp7FNk62tKqyAYjf4Y8E W9Zg== X-Forwarded-Encrypted: i=1; AJvYcCUhWpo7hlIUGdF8pi8jebKktg5i7+pXP39hCEQfGHwAy4x+20U/KAfQBcV4K14ZqBtY9ijlMUs5NocSqUWlMXFK@lists.infradead.org X-Gm-Message-State: AOJu0Yw/xwHENaKF8WIIIijORXBpB5uN8MngfYhF7LRKCAZitaTe59V7 QGhMcGuF6qJ1a3Iv/Q8acHXwpbvAca77vQqXXbDpz7Wul0+u3Njp X-Google-Smtp-Source: AGHT+IGTPS2b+A1C17aqp6MUwEwi5FNiFSaX+X5FwBh4QbkvAkE9nJITwi8u1xgUd3TXRjDwffCIyQ== X-Received: by 2002:a17:902:f9c8:b0:1fa:1be4:1e48 with SMTP id d9443c01a7336-2037ee28d69mr115710795ad.11.1724563016984; Sat, 24 Aug 2024 22:16:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2024 22:16:56 -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 14/17] Input: pxa27x_keypad - use guard notation when acquiring mutex Date: Sat, 24 Aug 2024 22:16:18 -0700 Message-ID: <20240825051627.2848495-15-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_221658_292044_FD0574A9 X-CRM114-Status: GOOD ( 15.55 ) 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/pxa27x_keypad.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index 3724363d140e..38ec619aa359 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c @@ -682,7 +682,7 @@ static int pxa27x_keypad_resume(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); struct input_dev *input_dev = keypad->input_dev; - int ret = 0; + int error; /* * If the keypad is used as wake up source, the clock is not turned @@ -691,19 +691,19 @@ static int pxa27x_keypad_resume(struct device *dev) if (device_may_wakeup(&pdev->dev)) { disable_irq_wake(keypad->irq); } else { - mutex_lock(&input_dev->mutex); + guard(mutex)(&input_dev->mutex); if (input_device_enabled(input_dev)) { /* Enable unit clock */ - ret = clk_prepare_enable(keypad->clk); - if (!ret) - pxa27x_keypad_config(keypad); - } + error = clk_prepare_enable(keypad->clk); + if (error) + return error; - mutex_unlock(&input_dev->mutex); + pxa27x_keypad_config(keypad); + } } - return ret; + return 0; } static DEFINE_SIMPLE_DEV_PM_OPS(pxa27x_keypad_pm_ops,