Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp228583lqp; Tue, 11 Jun 2024 22:32:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV99vkJaPYJT/oIW/ZB+FlMdgyBnI2aB2kzNBIUkrFnzrxzZUaZB1Alq1fd/EhRWZ4r01615/fOCAwY5WN+iJTdX5OfYIB2pMND/TcwWw== X-Google-Smtp-Source: AGHT+IHXGOron+r7IYcBsKSDaBFavvr1AJb6ywLEylaB9xplssuSFTktlorn7LSLWelVJEWL1nA0 X-Received: by 2002:a17:90b:14d:b0:2c2:5f25:5490 with SMTP id 98e67ed59e1d1-2c4a76dff6fmr965172a91.34.1718170364123; Tue, 11 Jun 2024 22:32:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718170364; cv=pass; d=google.com; s=arc-20160816; b=G5FHXTMRXDyUcBZo2k2l3uKRTE7AbIzWnrQCL1kjKqvMpT6BpJxQUAUoIVg9DeVePM DfY+j7ts2jlpIsQVnVLhQcEugj+VDmbAhjZYa2g7RR5loj5ZUzpdXkvgXShKLo4VT9W9 Hg+tDTA1v7NubfkxOpe3EMn9Jqt3POTQL0vHTx+xFNCC0WA9pEPtYKdB9avhwjJsC+lF 3djATUT0TUsvUSDM3sr3q54S5nMge5i0Q4SOH0NC40SF6Q9a+Luqfm21x3tvTjNRz46v cNnRKZ2e19G9/9jVnzxNff7qY1+S5HGAyjU2Gq8bM4tqdkmZA/qegvnbDlwJ4OmLeCAV HQhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=Q8O4evamKXuWqTPGHIl46sPGNgVHjOBdlOE3EoJxFkw=; fh=JM0nGda4Y+axYtxHkyYvMpp7cftUnF82kNlaYdcCQxc=; b=vqeutpyf1xLNUGWqWdsFyEDIWmwMrkfmsxk8ZQ3C+cioIGo8/sRRDp5ue6+OwHwU1Q 1KJQTxz3v484zfQW609Bg6KWeK+seNSROcwQnpPEHUkZuCmA6MbIqZbz2OMJ/Taa4A9m JjFVhON67WW4Ox18Jp3GhQu7mDjTIynt9qeq/QxFK4+/9LvqRp1hWofxqpcfp0yztnZ4 rLUrBW4Lq5geCarIKMiU+C0bjVZDqrqiaNjwa2gOahtKat2O452f5zlGJdQrsCrVmdDJ 869hoDhjFo1wkZqjUJ5bS83iO8FYOkCa1joebB+61LHOTgdXcFO5qu2FWKb18+tb3uh8 Kmrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=l3fyLFvd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-210947-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a75e5fc6si772562a91.34.2024.06.11.22.32.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 22:32:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210947-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=l3fyLFvd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-210947-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4F481B21AB7 for ; Wed, 12 Jun 2024 05:31:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DAC4374CB; Wed, 12 Jun 2024 05:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l3fyLFvd" Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3746E22092; Wed, 12 Jun 2024 05:31:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718170307; cv=none; b=WPBl5PRWDWdt30bpeNsfj5hyAw6/CAQAjOELBja6sMXzGDHijl/gR0AXO8WvFLIH4y9qbGrKnCOh7+7Tp+aveWwm3gJZb8heZ2+xz7zQACIRHlIt6ZHV+BMAod6DjFQc9RTENtfsWTga0+mMwsK6Ur+YpRU/TR/zCbf8DvHLRTo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718170307; c=relaxed/simple; bh=tpXpYk02XunfGAs+UGnMoSZ1SSbgmpeXpxB1InHLaOs=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=i2twsNCuuz1FOvbv8ZplRWpgLDXH8imonDuYVJBKwjPbHyGuehvZLsjcjuoYol/GG4AiEBAK6BnzPweAt0J1LzyIAXbMteRxIWZ6Ci+TlYSK96zNQfiMAtQN9DPHIDlf6AOxo2+EgqCZtXPck0RKLh+q18UHsjvNRmpX3EFv/zU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l3fyLFvd; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-681ad26f4a5so1214131a12.2; Tue, 11 Jun 2024 22:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718170305; x=1718775105; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Q8O4evamKXuWqTPGHIl46sPGNgVHjOBdlOE3EoJxFkw=; b=l3fyLFvdMQL+DEEXgAekN8KGpKg958QeDWBs7JUuJJKZ+Or4Sukr9BquwcaNj7psPB 4eIwzf4XTqAVI2Y8eaK2zWJF+o8JXcJDtHUcnb3KvZutT++NfnsKkCzZ9ZZ4TAQsRXTw deEpTpWx6OS595LJgtxWM2i2SXDSwkmYT+Wgnt+gXoGYABlWawhLLhxAcO8zJZlvPz/T yZmAKDNzyqP0ZxHz544ipxdg5bmU6gWodHiqHOfwofGnXciaiMageyLKe4igysgP3dzU MxCH33ncD1O1MY+F+IWBd5L03JTouRn6ahSE81x730A1EQ4goR9775UflxJHHn40fm14 k/KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718170305; x=1718775105; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q8O4evamKXuWqTPGHIl46sPGNgVHjOBdlOE3EoJxFkw=; b=StLxRuiPczDBsk5eCLy/gH6NI55jcP1NsvF9jvkbH8sioRZ5S4AQNR2Xzf0XIpBfsj pPd5jzOBOF9V0/OCQejuDStAQltQCt+zv/Oeu9CTrh/HukWjDCuYgAC34W8KOGIuzyn2 R2bX4f+zCl2F/JB7jnbVQ8cLdNdSF/JnXWJnhkhgmsoZU17jYeKeZMFOBSmFT9n0/fVi ICb/G2T7x9dfQpc3DM/0nJjy5VGiTvP8nVz1ts156eq6cZ1OEGLZANbMuyZRyz0TnAJS EAK/StOni0dj0wp4PUWv6DEz7E4b1y1WNQxrJZWdWlhhhsmkkvbuTKM0C39eLH6zBpK0 3FVw== X-Gm-Message-State: AOJu0YxATGwyb7RtJxQZRrfMbzsNkD/ih+2IjEYU8WZwlAp8t/GmHBjt NlePSZ8q8hTWcbACHriDAU3YrZx3CSk15axOcd/XiCXMwFlI76elDlVyug== X-Received: by 2002:a05:6a20:841d:b0:1b8:b517:9bf9 with SMTP id adf61e73a8af0-1b8b5179cecmr615437637.25.1718170304923; Tue, 11 Jun 2024 22:31:44 -0700 (PDT) Received: from google.com ([2620:15c:9d:2:3077:52c7:3e56:8d61]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c4a75defafsm679440a91.7.2024.06.11.22.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 22:31:44 -0700 (PDT) Date: Tue, 11 Jun 2024 22:31:42 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org, Jason Gerecke Cc: linux-kernel@vger.kernel.org Subject: [PATCH] Input: wacom_w8001 - use "guard" notation when acquiring mutex Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Switch the driver to use guard notation when acquiring mutex to have it released automatically. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/wacom_w8001.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index c8abb9557ee8..ed2ca8a689d5 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c @@ -380,30 +380,28 @@ static int w8001_open(struct input_dev *dev) struct w8001 *w8001 = input_get_drvdata(dev); int err; - err = mutex_lock_interruptible(&w8001->mutex); - if (err) - return err; + scoped_guard(mutex_intr, &w8001->mutex) { + if (w8001->open_count == 0) { + err = w8001_command(w8001, W8001_CMD_START, false); + if (err) + return err; + } - if (w8001->open_count++ == 0) { - err = w8001_command(w8001, W8001_CMD_START, false); - if (err) - w8001->open_count--; + w8001->open_count++; + return 0; } - mutex_unlock(&w8001->mutex); - return err; + return -EINTR; } static void w8001_close(struct input_dev *dev) { struct w8001 *w8001 = input_get_drvdata(dev); - mutex_lock(&w8001->mutex); + guard(mutex)(&w8001->mutex); if (--w8001->open_count == 0) w8001_command(w8001, W8001_CMD_STOP, false); - - mutex_unlock(&w8001->mutex); } static int w8001_detect(struct w8001 *w8001) -- 2.45.2.505.gda0bf45e8d-goog -- Dmitry