From patchwork Thu Sep 5 04:17:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13791741 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 074E7CD4F50 for ; Thu, 5 Sep 2024 04:39:52 +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=xz2erQSg3sDaQU8qTCUlHXjZi76BIHFsta/dILnpIUo=; b=GiXSGELQ50Eh2JxyWbOIHLC/8Z SzIwR1WEmuRK1CPOwScMoefvg1n2/LIdUe+Nc7pV/8NU1HLUVF2/qvH+S6OdqERMDoqlpS+9alfmT scneT4pMlpvzdnmxD0VPW+1ebO5mkU/BZwLoRziB8qNebr83Em7ra85spEryZEbn9KGiFFDb+iGl9 2onfN1kTSYCPzTMp0M4epdtMoBN0xDPvfcdpoGSeNkurYSBHYKDJAkj354ZqsHyJlm8SDw/jFtBhE Kr5Sh4I5G1uT03dJ/NbDZwgDFlWJA703GEDuwrndMTLDObAgeOlIbjFBQYB1eDYOx5MKe4Ea4MO2Q 58c3zKKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm4HX-00000006xpM-0EvD; Thu, 05 Sep 2024 04:39:43 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm3wm-00000006tXy-30qI for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 04:18:17 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-709339c91f9so242733a34.0 for ; Wed, 04 Sep 2024 21:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725509896; x=1726114696; 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=xz2erQSg3sDaQU8qTCUlHXjZi76BIHFsta/dILnpIUo=; b=LC2H2DtSv/3vkSyc9RykLoYlWyXoH4B0Mp7SGU3kzURq7clrhomI+7+uv8IhewCmH+ PYeHBmUQvZZwH12ZqqGWUz7noE4h9Cn9uj7M0PHKCeoRqlf3+AuWRud2pm54Hul8PfOn m+kwHjqFVg35f230hr55zhQ9WzhJjJv80jxaVOxxozNYS5BU8kChrS8zu2IJSvbyD4B+ 1078LMWbkERKsXxEgrSMBWerdhh43DngFHTgQJ2IZesnVZYBjwFxGiUI/MoxNWGHbSjW l70kuS1eYNIuHE/5km3ljp586EijitQ2eTRnVAmFmpXQN+Ub77zLSQRa2L89QT802fsv 4jyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725509896; x=1726114696; 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=xz2erQSg3sDaQU8qTCUlHXjZi76BIHFsta/dILnpIUo=; b=bqB9d24bQE+GkMrBSKt5i49Yo1bD3euFzZfkg7Vk53cY/xbD44ojNUHlevq623McNJ eb4j+RLxRHQ40+ydHdhYh4HfMGqXDsz3WSsSmcZW5djRd9/pyOYFVu6defNgRyhjSxiC qMAJ/BBF9aS0GRETraw3Zc5psWxsUduKTjshbdVAE0bTTDukTQhMLxXUNjxj8uchsR+e 6gKwtr/BL6uo39wIc2B/VTD9tfGcU9QcaT3LoKezK6zLzKYXpPfoZHQdyoFqjfYngW4v sVIfl3JyCvSNulYL1aI4zGdRmac8JVYAMknZPWjDYfoF4oPJ2gd2pMde9GahBGV/2vWN vcuQ== X-Forwarded-Encrypted: i=1; AJvYcCXPYVBAeKOI0yF6Puk2ldvtn8NpNL0D43Ugw04t4KDZ9v3VABHIfl7vjIJd1Wmu0FEbZIHhxkYf1OWkGwphrm40@lists.infradead.org X-Gm-Message-State: AOJu0Yysy8Qz1VEL5X+elsKOrxoUNOu0C1dVoaFtbRCcp3brDdn9AzP3 QKBzShKAShOCempDFQJa2OxVxQYy/Ddxl6kJEUeMLL4/IgeBCE6M X-Google-Smtp-Source: AGHT+IFPTVGs3vyKg3Li6dflqJQ+JnKv/J7SxlC09OoKIqCCU5IWw2pa42IFrQdn8vuEJ1eR5r+pIw== X-Received: by 2002:a05:6359:5f8a:b0:1b5:e9e0:2421 with SMTP id e5c5f4694b2df-1b7e37a5389mr2316618255d.6.1725509895909; Wed, 04 Sep 2024 21:18:15 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:13bd:b4e:4c0f:4c37]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d4fbd8d52esm2450216a12.32.2024.09.04.21.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 21:18:15 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , Helge Deller , "K. Y. Srinivasan" , Wei Liu , Dexuan Cui , Samuel Holland , Lyude Paul , Michal Simek , Hans de Goede , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 22/24] Input: sun4i-ps2 - use guard notation when acquiring spinlock Date: Wed, 4 Sep 2024 21:17:27 -0700 Message-ID: <20240905041732.2034348-23-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905041732.2034348-1-dmitry.torokhov@gmail.com> References: <20240905041732.2034348-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-20240904_211816_776258_38F49C2E X-CRM114-Status: GOOD ( 13.03 ) 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 Using guard notation makes the code more compact and error handling more robust by ensuring that locks are released in all code paths when control leaves critical section. Signed-off-by: Dmitry Torokhov --- drivers/input/serio/sun4i-ps2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c index 95cd8aaee65d..267214ca9b51 100644 --- a/drivers/input/serio/sun4i-ps2.c +++ b/drivers/input/serio/sun4i-ps2.c @@ -101,7 +101,7 @@ static irqreturn_t sun4i_ps2_interrupt(int irq, void *dev_id) unsigned int rxflags = 0; u32 rval; - spin_lock(&drvdata->lock); + guard(spinlock)(&drvdata->lock); /* Get the PS/2 interrupts and clear them */ intr_status = readl(drvdata->reg_base + PS2_REG_LSTS); @@ -134,8 +134,6 @@ static irqreturn_t sun4i_ps2_interrupt(int irq, void *dev_id) writel(intr_status, drvdata->reg_base + PS2_REG_LSTS); writel(fifo_status, drvdata->reg_base + PS2_REG_FSTS); - spin_unlock(&drvdata->lock); - return IRQ_HANDLED; } @@ -146,7 +144,6 @@ static int sun4i_ps2_open(struct serio *serio) u32 clk_scdf; u32 clk_pcdf; u32 rval; - unsigned long flags; /* Set line control and enable interrupt */ rval = PS2_LCTL_STOPERREN | PS2_LCTL_ACKERREN @@ -171,9 +168,8 @@ static int sun4i_ps2_open(struct serio *serio) rval = PS2_GCTL_RESET | PS2_GCTL_INTEN | PS2_GCTL_MASTER | PS2_GCTL_BUSEN; - spin_lock_irqsave(&drvdata->lock, flags); + guard(spinlock_irqsave)(&drvdata->lock); writel(rval, drvdata->reg_base + PS2_REG_GCTL); - spin_unlock_irqrestore(&drvdata->lock, flags); return 0; }