Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5672520rdb; Wed, 13 Dec 2023 16:18:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFscLur18JmKQvgo/LBnREyknNPn8zrPn6o2uVANVRbgHsz0gkvbP3X063qIdUZS47QpA/4 X-Received: by 2002:a05:6358:15d0:b0:170:15a7:1fea with SMTP id t16-20020a05635815d000b0017015a71feamr6686261rwh.2.1702513107065; Wed, 13 Dec 2023 16:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702513107; cv=none; d=google.com; s=arc-20160816; b=TphWagJ4GspDGSy1i0cWHu3c2ZvfA2iCX8/o2z32jQHfGn0jCqIZVRFNdQH9M3h3oj ol3pzjMfyS9GyVRJsYGuhmnGZLuVIjm20DJ+KYtPM6TUdPJjkfycRHMd8d6+31N60SX2 cPQBZoCDE4VDnM1ZZrEpo5MwNEy4atwqDi5/HAAZDpMZcaQDTITg2GCoF+XgvXrKtjaM q41Jxkm4K8o1VjJQ369vqgr8m08jRKS8kkg69JShTJiRbKvAKU05KSJk2yhzbTrPV9Vp QXUMXo5iBHkFGNcnDOfdS+DmNzEwDfEf2j6uIfy027mp13Mt8ShAWKv5CUIsDQLaKq6i zp0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sBplHsQKCXk6W0ml/hFriO8Dxkh7jyAyK1nM1uz0Edw=; fh=JQuCuTmtpe770U/EjoFOYWKrhTpVWH6ywEqFQCyG1jE=; b=Psca3+DDeBo6J5KZp8+m9ufv/eyZKplDQu554xi4EQrpIp61ryhcUDBx4AASQ5IJHz fB8MeJo3x1GAdotDoqkkn0hK/dXBCIL7tvfABnq6mh75ojE/Uvt9yk1hiNLZMqZ3351k 02app58gD2cYYvL6JDyJ1ASeeBFiDORZPh/m0GmKrzr97NOvPwTurCu7tUE7P6/A38uw hffrt0bmefgcOKqqdPI4dyl/HwUuX/dZMmXS0xHSf/+X5qdt4q+zOG9eIq24gqgUWlXn SD5IIR5jJJQnO5rVbHmBha+csxd7F+2Yg0YCrOAwO6FQ1otkn/pzv2sGhvzzuu6/2c3l 0Z6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hKwKfsDZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f24-20020a17090ac29800b0028555ec82easi11642430pjt.57.2023.12.13.16.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:18:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hKwKfsDZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2079980327DC; Wed, 13 Dec 2023 16:18:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442806AbjLNASB (ORCPT + 99 others); Wed, 13 Dec 2023 19:18:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjLNASA (ORCPT ); Wed, 13 Dec 2023 19:18:00 -0500 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51ED1C9; Wed, 13 Dec 2023 16:18:07 -0800 (PST) Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-35f71436397so9335895ab.3; Wed, 13 Dec 2023 16:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702513086; x=1703117886; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=sBplHsQKCXk6W0ml/hFriO8Dxkh7jyAyK1nM1uz0Edw=; b=hKwKfsDZovSElzbZiRNVrJQlbgdjjvqT6817muiboOaALd/dcC0hxiSZTiDQ2zkm3x YdEVQG9FVDzavNlDUJfZhbF0Nn8cDRoOCy6zEhto1TqI6W6pjfiLbdsZyBnB8+xHYbbI XzAa3qu+11702Ox3Idqnvn7Ar/qXctPyoO2WtB2S5W968hYbnYXGx3eP4e2R5Ou8LvY2 +L/5YALGiY6GU5kKfTMfT8mkHh5vuNmcjjNoBDJCwe2IVMmguj4Fzab8FYnuPpgBACGj Dc73sPv4LjWIbmeH+W3Ja/D8VPf5Gtz6VqC8JEBniUCl0ayEDc0+WfdGU+Yus0tGGi7J p9aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702513086; x=1703117886; h=in-reply-to: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=sBplHsQKCXk6W0ml/hFriO8Dxkh7jyAyK1nM1uz0Edw=; b=BiDHG9//AlGh890YOxlLXsGeUcED+FNJE0CK9yXHw8ld/fhL1sTjQiREjc5HVIWXOr EbsWjCd5oDm8UNLu1BrspqoHsHwZrKIzmXe+wyrFJVp7mYWXoSDtPc//73/ZLz2PSz6W EdkRzAabdl9DjBTtLjvgRL66CgagcU608kvvQ2G4j32IdyeUkpDgdIWHE0Ax61yguHT+ 7Bgx0e8IxIqisZZiwlWOkhkzMOexTku2dGqrnLWtESBwGJeclSER0UD/VTzFEtE7ZVvJ S0PF4nS8nRgFxUY7R9WPIQO0eG4FSWWuVALBz/ZFwvlGhDTGgq4IdSMQA5pDf7/0vowQ q/Lw== X-Gm-Message-State: AOJu0YxY7r/1tGaCyfiaHRhfT6eJVz0XWwBxr1lAnC6eKGpq/TgtmAAd GBHZrnaxoRXC1NdNOd68Zxc= X-Received: by 2002:a05:6e02:144:b0:35f:7200:cdbb with SMTP id j4-20020a056e02014400b0035f7200cdbbmr1864666ilr.83.1702513086548; Wed, 13 Dec 2023 16:18:06 -0800 (PST) Received: from rigel (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id bs9-20020a632809000000b0059b2316be86sm10465036pgb.46.2023.12.13.16.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 16:18:06 -0800 (PST) Date: Thu, 14 Dec 2023 08:18:01 +0800 From: Kent Gibson To: Andy Shevchenko Cc: Bartosz Golaszewski , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linus.walleij@linaro.org Subject: Re: [PATCH 1/4] gpiolib: cdev: relocate debounce_period_us from struct gpio_desc Message-ID: References: <20231212054253.50094-2-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 16:18:24 -0800 (PST) On Wed, Dec 13, 2023 at 10:07:12PM +0200, Andy Shevchenko wrote: > On Wed, Dec 13, 2023 at 08:03:44PM +0100, Bartosz Golaszewski wrote: > > ... > > > > > > > > > > > +static struct supinfo supinfo; > > > > > > > > > > > > > > > > > > Why supinfo should be a struct to begin with? Seems to me as an unneeded > > > > > > > > > complication. > > > > > > > > > > > > > > I think we should keep it as a struct but defined the following way: > > > > > > > > > > > > > > struct { > > > > > > > spinlock_t lock; > > > > > > > struct rb_root tree; > > > > > > > } supinfo; > > > > > > > > > > > > That is what I meant be merging the struct definition with the variable > > > > > > definition. Or is there some other way to completely do away with the > > > > > > struct that I'm missing? > > > > > > > > > > Look at the top of gpiolib.c: > > > > > > > > > > static DEFINE_MUTEX(gpio_lookup_lock); > > > > > static LIST_HEAD(gpio_lookup_list); > > > > > > > > > > In the similar way you can simply do > > > > > > > > > > static DEFINE_SPINLOCK(gpio_sup_lock); > > > > > static struct rb_root gpio_sup_tree; > > > > > > > > The fact that this has been like this, doesn't mean it's the only > > > > right way. IMO putting these into the same structure makes logical > > > > sense. > > > > > > I disagree on the struct like this on the grounds: > > > - it's global I dislike having the global at all - and now you want two :-(. > > > - it's one time use Its not about how many times it is instanciated, it is about maintainability. > > > - it adds complications for no benefit It provides a placeholder for collective documentation and clarifies scope for the reader. How is it more complicated? > > > - it makes code uglier and longer > > > What, swapping an underscore for a period? And you would hope the generated code is essentially the same. > > > > It boils down to supinfo.lock vs supinfo_lock. I do prefer the former > > but it's a weak opinion, I won't die on that hill. > > Me neither, just showing rationale from my side. > I can't recall the last time I intentionally used separate globals over a struct, so if there are no strong opinions otherwise I'll leave it as a struct. Cheers, Kent.