Received: by 2002:a05:7412:d002:b0:f9:9049:d2ea with SMTP id bd2csp64533rdb; Wed, 20 Dec 2023 04:14:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEd/FgQjPetA+Sw71FaJjfU1/UZGYr+xwnKvoKlpSV5BVoaV0v/P4Eiguj6i4G4hmn7CE85 X-Received: by 2002:a17:906:201:b0:a24:1e0e:ccb2 with SMTP id 1-20020a170906020100b00a241e0eccb2mr2664861ejd.61.1703074475241; Wed, 20 Dec 2023 04:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703074475; cv=none; d=google.com; s=arc-20160816; b=Ss1NkXtq9cq8tP/6D3ZaTS8RK3uD8YzQejl3WnQYXa9D82UOUvIcOmhiIeCfy4cUET pewlywb7RAtiIPAs/KNv+LThzWzu2u0v6aabRKActW9SHqgZthMpr4SETny5NqxcGB9y t/TWEmmr4RKUjprXmWQJY98HfAq13cV6B6C3zxkByRCCrzZCIhf7uxUtUjp/HK9z7V08 eZA0mcNRdBkzSGOnEAdEL3PhCsk2RJNZI47lu59KSNLs0BO8xyFJLtCbaO04KUPIz5G9 +ELzkD7grc5JmYq2VVLg/Jpc1a1KhkdgOfjW952YdRnOvuOuAVcYmyKCWNq7VtxNmIhv YikQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lkbaWKNWG4TQluqIF/XAJ7K7LvKr8qSqNHNv/8QuIYM=; fh=2Hmk2+MVViEF0KjzxYUiDLGjhYOS+yeUz+iu1Qazwnc=; b=V3QnDdhdRVg8BtRZSG+eHJ5iU+OQ+YvxGOR2b7hPMJ6+8Ufvny7O0CgQAcu/hDk9z1 nxC7XDbOsBLAiTSlSQGKvkpG1GeZFgSY2x5i2aW5Hbs5McIvoRADmRe2MvcmoQObtow3 uk+RkFRwQuUJpzv3ZbfnPlerKYXrgN2WdVTipKe+fLqHptmLYz8HPgGWjbQLl/BPko8V z7YSfWZjD4Z4vxTvI1aMglpGa49Pj5N09DvbB6UxuNvZRy3AlGvvsMDtFY4U60sd2Ym9 h7WL5FlCTkO+yOSexmT31ZhLao9Ee+8hUheHmEV+rf5QcVZzH7KFSl1w64jtpA/F9Fhw r0Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MvNF/c5l"; spf=pass (google.com: domain of linux-kernel+bounces-6878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6878-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u26-20020a17090626da00b00a1d885359cfsi12076973ejc.326.2023.12.20.04.14.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 04:14:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="MvNF/c5l"; spf=pass (google.com: domain of linux-kernel+bounces-6878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6878-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0509D1F236A9 for ; Wed, 20 Dec 2023 12:14:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E37424B48; Wed, 20 Dec 2023 12:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MvNF/c5l" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 2879C2511E; Wed, 20 Dec 2023 12:13:36 +0000 (UTC) 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-pj1-f41.google.com with SMTP id 98e67ed59e1d1-28a5d0ebf1fso521822a91.0; Wed, 20 Dec 2023 04:13:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703074416; x=1703679216; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=lkbaWKNWG4TQluqIF/XAJ7K7LvKr8qSqNHNv/8QuIYM=; b=MvNF/c5lcZ4VU4OH0qSk8YM6k7lLbnIk5pdhTeBaJItw5nl1Hc3I8N4wGn+HvmNZhc MiAyjg/uxtCIzwU48NadTq7+1xh5R5JpDp/NX18N3QlfUOR4mUH6u1mk9FHT0SapeCOt cfbAipWWkS2OO1NnBmWeam3vSYBGLTbNBa16nT6eymD7JcVLRqTNqp7FG7S+HlAfMK8u zHnxg9FGpTpbdS8xL97lSEqKj47FaTVGit6pTRKJHocDPzhf9I/25shpWTjjzrwPXY+8 IqHeRToiuVfb5OpD2FLfDG6xXTs0k2bqb6lXuolA8VINgbabIdJQF4tYNYtzVDwtsQ9a WUvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703074416; x=1703679216; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lkbaWKNWG4TQluqIF/XAJ7K7LvKr8qSqNHNv/8QuIYM=; b=tPbKnB83rjYkhxlftjI23g5tqcJiLyiwp3boeCCrv4tJXGdRqOQ7VoFTDb+obzNtUC 1dVgmvpTPv345zKiIabddL7c+tOeA5wLZ3GuUoXlh5CnZ8u8eoxGOlwTAIVfgGFpMC02 fmGER1R6qSt4nOP6qQWiAZm3fWg/o47PqZTdKYgNRJYbVlBO0bYzJaMkFGfTzS9aDhHT N07a79gQP3lM9JwfjZswsFGwTYTKehC7S3sHz5KzYHSEZtfusBcdop8RuvyQhhH7lTwZ q5rvJQStptbxaUzAQqyy76gC4R9u3NV7kI9EmnpJU3phogi72DQ0E3bGM0d174KhKisk MoAw== X-Gm-Message-State: AOJu0YyH2QiEVnuVC4L4YBvxpv///mdw8B3rqWLHKEySKNvbUAA9b/Nq DCr81vf6SDk8eBTqHrwy+jU= X-Received: by 2002:a17:90a:f293:b0:28b:d2fa:1725 with SMTP id fs19-20020a17090af29300b0028bd2fa1725mr1334548pjb.43.1703074416316; Wed, 20 Dec 2023 04:13:36 -0800 (PST) Received: from rigel (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id n14-20020a17090a2fce00b0028ad32914basm3398249pjm.41.2023.12.20.04.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 04:13:36 -0800 (PST) Date: Wed, 20 Dec 2023 20:13:31 +0800 From: Kent Gibson To: Bartosz Golaszewski Cc: Linus Walleij , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, andy@kernel.org Subject: Re: [PATCH 4/4] gpiolib: cdev: replace locking wrappers for gpio_device with guards Message-ID: References: <20231220015106.16732-1-warthog618@gmail.com> <20231220015106.16732-5-warthog618@gmail.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Dec 20, 2023 at 01:05:35PM +0100, Bartosz Golaszewski wrote: > On Wed, Dec 20, 2023 at 12:56 PM Linus Walleij wrote: > > > > (+PeterZ) > > > > On Wed, Dec 20, 2023 at 2:52 AM Kent Gibson wrote: > > > > > Replace the wrapping functions that inhibit removal of the gpio_device > > > with equivalent guard macros. > > > > > > Signed-off-by: Kent Gibson > > (...) > > > +DEFINE_CLASS(_read_sem_guard, > > > + struct rw_semaphore *, > > > + up_read(_T), > > > + ({ > > > + down_read(sem); > > > + sem; > > > + }), > > > + struct rw_semaphore *sem); > > > > Isn't this so generic that it should be in ? > > > > Otherwise all the patches look good to me. > > > > We already have this: > > DEFINE_GUARD(rwsem_read, struct rw_semaphore *, down_read(_T), up_read(_T)) > DEFINE_GUARD(rwsem_write, struct rw_semaphore *, down_write(_T), up_write(_T)) > > DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T)) > DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T)) > Ah - in rwsem.h - I missed that. > This can surely be used here, right? > Don't see why not. I would still like to move the gpio_device specific macros to gpiolib.h, as they apply to the struct gpio_device defined there. The naming probably needs some reworking, so open to suggestions on that. Cheers, Kent.