From patchwork Thu Sep 5 04:17:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13791712 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 C4287CD4F57 for ; Thu, 5 Sep 2024 04:25:36 +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=j8VPXswHBHTUlmDFHKrQ5BC1wv3BR4y3AP5bfe5KlEs=; b=VeC/d1cBjpvs9XibPMuAAwHT7p P/0y9Fra6yok6KtZatLjMidsZ3zUzKMrVq6zpNm/J1qhnJ4jiDzz+if66Kxs+c7izM5eoT3L7Ix+m 5cJfiLPVmy11WmYUtWOErRYozAfsZwntccZVi4ZnfybcZTUjGzF/KsBGWXre7M6Eq2pidRGyAICe0 ZKhaMnzHM4bkBrK97etRQZOorh8vLgR5j0SIPw2Aq7xqYdjuhS6u0Lco7frbboV4gU544gHbO7Zf8 NK3CaSCLMlg/H76tdd6gHOhiqzdjKa/ZP6nOJIaGfvBgeSmAokMfld/DhQ2TPUIRaWvps+UJIZLA2 c7/EkVFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm43j-00000006vKl-3p1a; Thu, 05 Sep 2024 04:25:28 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm3wR-00000006tOM-1cZZ for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 04:17:56 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5df998d7a44so211921eaf.2 for ; Wed, 04 Sep 2024 21:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725509874; x=1726114674; 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=j8VPXswHBHTUlmDFHKrQ5BC1wv3BR4y3AP5bfe5KlEs=; b=CI+/LORN2rvmik0G4JoY7RcB8wmj+QA855R9sv9WKVgDnw/SchvKBpHSCx6NEO0OCB Ec91PbWVwB5R5YNfoDyqGfFu+rBCK/ngpdc60gM7YP9MzCC6qGp8R6EeN69jNEOFzVbW jIXgo0xLhNs1kq0G9M+eEMhgdu+kOkl+bhJfdhTM8RUhqZaxL06O7lQaSaWJbao+w6df j8hvF80T8N87WP5hi4hZv2AZOevXI/BamlYMApIx5LFjc8wsdyVd7mysGJ1amGyzBoV9 Mb5TbviXRGSjI0PPfyPc+Jjj44b2w9Y47mGTEfwVzvfpgnN7jjnTafyntrMNUZoUTfQc e6ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725509874; x=1726114674; 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=j8VPXswHBHTUlmDFHKrQ5BC1wv3BR4y3AP5bfe5KlEs=; b=bWInRP+hp4cKKHReyi6WGNbFGSQ/u4ni0eK8njbRTENrAE4kGcD5pzj3CYsXMTwOpg XZAq2XLmZs6ZZ7q8inJklXDbBX4n0dEq3vVVTiuiebUJqePUKLQAvrrKs+zgLgwqjgmR RDK/FFitKezHBdO8kgwEQ3O66DJQfFXq9wve9fOfLtiEd2d2N0gDLYxCpPaEm1lTDL/s 6z689snnol9LeImf4O0x18VNPzu+/xccKtG0v+nluHzz7xYlrXpon6OIdG7PXjFEZXQG lhn3q4xWzhFL1rmSPWD20uyOTwjsl0A3ZahwdSVcaen5H9GY7rIag3t0OWCDNml/G5J1 w2dQ== X-Forwarded-Encrypted: i=1; AJvYcCXLUdEO8KBWGl6qtuJqkyTxPRiR2Awl6nOxSqPVi9/fYqhYUZF10b4Z82r4DmmUpjE98sCtJ/1gu/4QLmKLfkbt@lists.infradead.org X-Gm-Message-State: AOJu0YzBOFcy6Ld7p51r5BIhLrvTK8VcnD42160dlL0mFDY42ePm1TgU 1jDina9dA27Mznd1oCN+T+3orQpdHCkJ0uQ+Acqz9d7LjeWvU2mR X-Google-Smtp-Source: AGHT+IGI2QjJK2UofL6z1AHMX7SrEpAd/PMAyIbsnSlBJf71WYXVl7JagSZR9Rgb4HVgwu3bRh55Vg== X-Received: by 2002:a05:6358:898:b0:1b8:f18:3e53 with SMTP id e5c5f4694b2df-1b8117bcb29mr1047970355d.9.1725509874043; Wed, 04 Sep 2024 21:17:54 -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.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 21:17:53 -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 07/24] Input: sunkbd - use guard notation when pausing serio port Date: Wed, 4 Sep 2024 21:17:12 -0700 Message-ID: <20240905041732.2034348-8-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_211755_460933_985F3A7A X-CRM114-Status: GOOD ( 11.06 ) 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 serio ports are resumed in all code paths when control leaves critical section. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/sunkbd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 72fb46029710..3299e1919b37 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -241,9 +241,8 @@ static void sunkbd_reinit(struct work_struct *work) static void sunkbd_enable(struct sunkbd *sunkbd, bool enable) { - serio_pause_rx(sunkbd->serio); - sunkbd->enabled = enable; - serio_continue_rx(sunkbd->serio); + scoped_guard(serio_pause_rx, sunkbd->serio) + sunkbd->enabled = enable; if (!enable) { wake_up_interruptible(&sunkbd->wait);