Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp665869rdb; Fri, 22 Dec 2023 00:59:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGL4UvNo2ILMQEvH8NzzERrk2Tv1PfIUiCdW/aj9DBPzGvwi6gkQ/zfjscYDi0x7LvFrbbk X-Received: by 2002:a50:9983:0:b0:552:9915:fab1 with SMTP id m3-20020a509983000000b005529915fab1mr455242edb.47.1703235550890; Fri, 22 Dec 2023 00:59:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703235550; cv=none; d=google.com; s=arc-20160816; b=ILLEFy97BRVhvf0JTGxT8hgVb3srrYf7UH8xSnMC5Hz1CNl+qBjjN7W2X9oqaguQ2Y RNVeYCIO8gJB4Ty0eu4yp7lgBPriMT45GB5IuK2wpl985ZSck23e7MJoPqFHGTH6ES0I 60IAB9a79BU6q9UvlGOymNl4/pWXCT0OSOc1GrbvRDL/3wEkvlqsFng5rBEtbEa/qRF1 NZX7hKHuAdjLZ7ntNJIy5NDnZAdMvJErfvKygKb1r4HohPzKxr8TMO8q5bpR6BRGCHXL 8HBpxlISAdwamvKxvBeicjCmw2b+sYY+WEJZnnY04AuZkoLNRg5b8t+pHMHvAau+N1fI zUlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ecNqm3KCZK5TPbasxuftGkkhiYfCxbseeo7kCc76bg8=; fh=PPoaEFk1kNcwOz6EL6IFLP5yhh6OEcJh4j5KfnOY1Bc=; b=Sb4WpShX6wHAXvXG7HCkRCRa9VC1gJtU1v/KlhS+X2E5EanIL3j3dkIz95s9HzHHwk Wp2ZXIQjpgNGh03TguwcrUGegb8hCvXiepizgJkN41Tkrpcv9SrQUoACzXSVkPI759bD Pox56K+1C5WjYiWCLVE01OF4xJzD45atfXkDE7cmg3xTCov4QoHJyot3c+d+52mXkW21 pBZVO0FkiGHj+kRMdeQb+Axj8MX5ciqmJEqEgKj55YjpqWbbh56yKVWHCkqF5k0+61fc COxYk05rWekVcSOdbKJGzVO1qsyKbSa/IYFJQbWBqcSdddAE7yJxQe/4jttlBO2YtHIc Ih5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=AKyUKZfq; spf=pass (google.com: domain of linux-kernel+bounces-9526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9526-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n29-20020a50935d000000b0055362f400c0si1631336eda.390.2023.12.22.00.59.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:59:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9526-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=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=AKyUKZfq; spf=pass (google.com: domain of linux-kernel+bounces-9526-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9526-linux.lists.archive=gmail.com@vger.kernel.org" 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 7B05A1F26424 for ; Fri, 22 Dec 2023 08:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71768D51E; Fri, 22 Dec 2023 08:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="AKyUKZfq" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) (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 9FF0BFBE8 for ; Fri, 22 Dec 2023 08:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-vs1-f50.google.com with SMTP id ada2fe7eead31-466e5faf29eso11579137.2 for ; Fri, 22 Dec 2023 00:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1703235539; x=1703840339; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ecNqm3KCZK5TPbasxuftGkkhiYfCxbseeo7kCc76bg8=; b=AKyUKZfq/enD4Xfvlcu7aku4l+XOxNyMnkhEhy+EC72uFlxszex87BUmYqFP6VCSdP cuhKJ6CwqDjJSj9Kl2Wnusw8JOpWn6gi+/Yt4AfOBC5qrvFB0JEVgdzlxOF8QBUxxrvH WI3HQapDEc9wjvRLucFBm+VzX64JHYB1TXVWPm5xcVBmN2dKTZldgIuJcZiHgipw1fVF KnoLv6o0pJv30qKpA9GMS8e7TRWSkypGsJ/wjJ+qLFYEN5+njUJ8XPgd+zzj2NxO82QN uL6aNEzEvRhhfhGmFHdeiL+Zyv0P5IdzmYpQAvLSeBUt2nfYuKmpC28PzKVF50qx2Fjp Pa9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703235539; x=1703840339; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ecNqm3KCZK5TPbasxuftGkkhiYfCxbseeo7kCc76bg8=; b=i3jtVJePvahzuwvRRC9m0H9Jtp7NC7Ob1QBNw/rBY0b9yGX9wY9EfHF3gVRLqjckAg dFA255uIxwdK1vh6NwBt39ZSgWRQjA9vQrl3YAX9aGlE3i7G6Ny5XoKtWcGoGrySmV3k zKhWIcSPqglqZ7WQXrdGLEGK1CpSW0E84vQ8+vYKjzby9MWJd5qVT8O8qEzl9wYwYZn+ DtAuzE4Z4hDx5vI2xsL3O0dKn4+zRCvwgW7AuHROvLXNAPGVJy3ySQVcaFmgHMwiKwsI BfSqlsDQewqI2rBNggHP1hdNwGk8hLmH1vyxsfLVfLDB3uEWkYwgyFG6JM2xWsMEVkw+ saIw== X-Gm-Message-State: AOJu0Yw4ze7Cli1ZxVRw3xfNC7fPTbh4VsHfTNp50o6R4kadZQTfccYT a5egEaOnWTNZGpfiQyUXCD60xvwBE+70wG0/OcklyhVLlp3TSA== X-Received: by 2002:a05:6102:32cb:b0:466:c6b0:d10e with SMTP id o11-20020a05610232cb00b00466c6b0d10emr586157vss.1.1703235539292; Fri, 22 Dec 2023 00:58:59 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221175527.2814506-1-andriy.shevchenko@linux.intel.com> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 22 Dec 2023 09:58:48 +0100 Message-ID: Subject: Re: [PATCH v1 1/1] gpiolib: cdev: Split line_get_debounce_period() and use To: Kent Gibson Cc: Andy Shevchenko , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 22, 2023 at 2:12=E2=80=AFAM Kent Gibson = wrote: > > On Thu, Dec 21, 2023 at 07:55:27PM +0200, Andy Shevchenko wrote: > > Instead of repeating the same code and reduce possible miss > > of READ_ONCE(), split line_get_debounce_period() heler out > > and use in the existing cases. > > > > helper > > > Not a fan of this change. > Yeah, sorry but NAK. READ_ONCE() is well known and tells you what the code does. Arbitrary line_get_debounce_period() makes me have to look it up. Bart > So using READ_ONCE() is repeating code?? > Doesn't providing a wrapper around READ_ONCE() just rename that repititio= n? > What of all the other uses of READ_ONCE() in cdev (and there are a lot) - > why pick on debounce_period? > > The line_set_debounce_period() is necessary as the set is now a > multi-step process as it can impact whether the line is contained > in the supinfo_tree. The get is just a get. > > And you could've included me in the Cc so I didn't just find it by > accident. > > Cheers, > Kent. > > > Signed-off-by: Andy Shevchenko > > --- > > drivers/gpio/gpiolib-cdev.c | 23 ++++++++++++++--------- > > 1 file changed, 14 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c > > index 744734405912..c573820d5722 100644 > > --- a/drivers/gpio/gpiolib-cdev.c > > +++ b/drivers/gpio/gpiolib-cdev.c > > @@ -651,6 +651,16 @@ static struct line *supinfo_find(struct gpio_desc = *desc) > > return NULL; > > } > > > > +static unsigned int line_get_debounce_period(struct line *line) > > +{ > > + return READ_ONCE(line->debounce_period_us); > > +} > > + > > +static inline bool line_has_supinfo(struct line *line) > > +{ > > + return line_get_debounce_period(line); > > +} > > + > > static void supinfo_to_lineinfo(struct gpio_desc *desc, > > struct gpio_v2_line_info *info) > > { > > @@ -665,15 +675,10 @@ static void supinfo_to_lineinfo(struct gpio_desc = *desc, > > > > attr =3D &info->attrs[info->num_attrs]; > > attr->id =3D GPIO_V2_LINE_ATTR_ID_DEBOUNCE; > > - attr->debounce_period_us =3D READ_ONCE(line->debounce_period_us); > > + attr->debounce_period_us =3D line_get_debounce_period(line); > > info->num_attrs++; > > } > > > > -static inline bool line_has_supinfo(struct line *line) > > -{ > > - return READ_ONCE(line->debounce_period_us); > > -} > > - > > /* > > * Checks line_has_supinfo() before and after the change to avoid unne= cessary > > * supinfo_tree access. > > @@ -846,7 +851,7 @@ static enum hte_return process_hw_ts(struct hte_ts_= data *ts, void *p) > > line->total_discard_seq++; > > line->last_seqno =3D ts->seq; > > mod_delayed_work(system_wq, &line->work, > > - usecs_to_jiffies(READ_ONCE(line->debounce_period_us))); > > + usecs_to_jiffies(line_get_debounce_perio= d(line))); > > } else { > > if (unlikely(ts->seq < line->line_seqno)) > > return HTE_CB_HANDLED; > > @@ -987,7 +992,7 @@ static irqreturn_t debounce_irq_handler(int irq, vo= id *p) > > struct line *line =3D p; > > > > mod_delayed_work(system_wq, &line->work, > > - usecs_to_jiffies(READ_ONCE(line->debounce_period_us))); > > + usecs_to_jiffies(line_get_debounce_period(line))= ); > > > > return IRQ_HANDLED; > > } > > @@ -1215,7 +1220,7 @@ static int edge_detector_update(struct line *line= , > > gpio_v2_line_config_debounce_period(lc, line_idx)= ; > > > > if ((active_edflags =3D=3D edflags) && > > - (READ_ONCE(line->debounce_period_us) =3D=3D debounce_period_u= s)) > > + (line_get_debounce_period(line) =3D=3D debounce_period_us)) > > return 0; > > > > /* sw debounced and still will be...*/ > > -- > > 2.43.0.rc1.1.gbec44491f096 > >