From patchwork Thu Sep 5 04:17:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13791732 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 14CC2CD4F50 for ; Thu, 5 Sep 2024 04:35:08 +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=2hL/oJ8v77sFrESpjTE2muwhc7qNiYaOX9Ne/zSSlqk=; b=4caFeu/BiEq3O26zGhviJSjpuY J/KVGACkY4m4vp67U30ps6vs2ApI5fwWBHFD9peIVd4pcCW0yeHjIvq0LOeUbiHz9D2/xdGSelPMM /knjxMPmd3t7Kux0JS4xlnLBgkShXbOr9toqcDnjkXX83Y0C5togdwR+ROfIbXwQChUCZ2U8sRYsc FwG2rmJxt035MC+XRD4arwIqDR5E4X6FuujvTtUFVJoNaqLxmXQSPQk5GA1NE7uXy3LQ4sjNjYf81 /I3plf4EvM2xkGKDo+Ipy2yNU4Kv0r27LINJwhOYhosHaTSnhl+iZ5BgAWfqYLSmCnJB/5FVZQSPh 9HLu1omQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm4Cx-00000006wuz-187U; Thu, 05 Sep 2024 04:34:59 +0000 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm3wg-00000006tVA-0Zhr for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 04:18:11 +0000 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-5d5b1e33fa8so211688eaf.3 for ; Wed, 04 Sep 2024 21:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725509889; x=1726114689; 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=2hL/oJ8v77sFrESpjTE2muwhc7qNiYaOX9Ne/zSSlqk=; b=aoR/3YJ8Er/6iBZvXFdcGa1G+NqjChbl2iKmD+w7DMQ42hmA3pEeQU5wM9erhsOJk3 YkLOifkfP3ZNuIXZZs/zYss5+DjYrjug6s3ZuuVzitdq5ZTDgkQXR5wd2O1ywDqXBffP OGpr4OrijE7NzSt0nVvu/cbTcfSFBmMEVYqViK60GjjffC6ruwoKB+y9tXaNEGLBEoLC dReIEg3X9P9NxFLVXOS6ssZr7E9BANOmoJEjZ0aGgePxPyVEPQtXj7uO4of6us/UAh+E kSrAVvLWbtm6PMxDOTzWZXKJMivCfknldrmPSB78dzwH4Xa1Qj3+0ll244CGydK4Le0U pVTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725509889; x=1726114689; 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=2hL/oJ8v77sFrESpjTE2muwhc7qNiYaOX9Ne/zSSlqk=; b=Oxwo7UhbzeIU5cIaNdPYtQmd0A2ecd5RGiAMZbznyKLHqM+TdFOeryPbeXVDj4i78S wsi+3b8sqFndp81Xd5D3Ncl+yFsQyyRz5OxlAGrr+rE5jJ97p/Z32uzVkTf1SSDpDJg8 vokWGgA5nfZ2lFroXw5gJI+t89kmnHsurHWqnsHxdDfzTHpN91ia/bNkTvap3pYXqgby YHYpDxp9sflm8S3vdn/gmrCNuv9LsGfEuFtHMuOJ0RIPrzxIAC3G0KltOdBJH3Bw1lWP 6PW4DTDhJVk3R7aMNPipWDVHdJivGyEVl2Fd1buFMjW4k99ZMq/rGFx4BTWTNwiiOPul 7zcw== X-Forwarded-Encrypted: i=1; AJvYcCWyosQ1+pAWAMimyZ/Ais3NFtEXplww2p9L0xQhrpmD5NgtPfqiD0GBTLq/E2MVXqliRDAaoXk5tGaIZYKfriW1@lists.infradead.org X-Gm-Message-State: AOJu0YyDYUxldwu2N2sOxkAKTuEsG0ZkpR3zFK0TJ1BjJaHJLBsRLQAh nAmifcVkx5GpE4exI/G5uWUiLLIwG8SL3WDhdOHOQDxh6p7UhCf0kP96nA== X-Google-Smtp-Source: AGHT+IHFtlZtt/7jfalAzcdSLrrI2tqquQOXGQfEgeIl9ZKOtYpILy5RI3LJ8SU6F2JK5e0j4C+FUw== X-Received: by 2002:a05:6359:410e:b0:1b5:fa8a:791b with SMTP id e5c5f4694b2df-1b8117ef578mr1137606955d.23.1725509888625; Wed, 04 Sep 2024 21:18:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 21:18:08 -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 17/24] Input: sa1111ps2 - use guard notation when acquiring spinlock Date: Wed, 4 Sep 2024 21:17:22 -0700 Message-ID: <20240905041732.2034348-18-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_211810_240485_3F0A4B9E X-CRM114-Status: GOOD ( 14.08 ) 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/sa1111ps2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c index 1311caf7dba4..375c6f5f905c 100644 --- a/drivers/input/serio/sa1111ps2.c +++ b/drivers/input/serio/sa1111ps2.c @@ -92,7 +92,8 @@ static irqreturn_t ps2_txint(int irq, void *dev_id) struct ps2if *ps2if = dev_id; unsigned int status; - spin_lock(&ps2if->lock); + guard(spinlock)(&ps2if->lock); + status = readl_relaxed(ps2if->base + PS2STAT); if (ps2if->head == ps2if->tail) { disable_irq_nosync(irq); @@ -101,7 +102,6 @@ static irqreturn_t ps2_txint(int irq, void *dev_id) writel_relaxed(ps2if->buf[ps2if->tail], ps2if->base + PS2DATA); ps2if->tail = (ps2if->tail + 1) & (sizeof(ps2if->buf) - 1); } - spin_unlock(&ps2if->lock); return IRQ_HANDLED; } @@ -113,10 +113,9 @@ static irqreturn_t ps2_txint(int irq, void *dev_id) static int ps2_write(struct serio *io, unsigned char val) { struct ps2if *ps2if = io->port_data; - unsigned long flags; unsigned int head; - spin_lock_irqsave(&ps2if->lock, flags); + guard(spinlock_irqsave)(&ps2if->lock); /* * If the TX register is empty, we can go straight out. @@ -133,7 +132,6 @@ static int ps2_write(struct serio *io, unsigned char val) } } - spin_unlock_irqrestore(&ps2if->lock, flags); return 0; }