Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1939590rdb; Tue, 5 Sep 2023 09:19:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgMPJVONEIzRQZ96RIdcLHcOufuBV9S4aoODHgNGNVamT+TdtkJDmwix4roNENcMH7Uc6h X-Received: by 2002:ac2:5f5a:0:b0:500:920d:2add with SMTP id 26-20020ac25f5a000000b00500920d2addmr233037lfz.34.1693930784222; Tue, 05 Sep 2023 09:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693930784; cv=none; d=google.com; s=arc-20160816; b=z6bG0kwatwx2IOwdY+7ST1O6kvNn+sAIcpinruUrO6SlF9XDDZtTnNsKBrC7Bfa4F5 U7Q/S0TK7eTXWiK1AJtVNaGKjDkNm3fyty3MyRWu//00z9Bo8oHTYus/jnlVKQ3mPgaY 3nG3szCYDKFSlaPft3E9KxvFlW3wTcQOIUgL7ajrAXsyyu/rec5dgRp/JGurCzM0v2J9 Enj/OX1+i6V0kyq/2EEd5ynbMsQt0TRirzOh5bI/ilQXyZpM8cEPKp9OEuXBzva1C4aA BYs1ozyG7/qAsrMod0t16GH6NmykfOYWCmoo4vvbGaOj4EKn5sqqLbo7ReHLtvQxH0Nu DBUA== 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=lWtupZVh/hNglyvB+QPBKJ+SSe9s9P140z0bzxoSn8Y=; fh=/5xPoZbXxIhm5GdXt1NxqAJ8/sOnqKUP+sAyK8mg+5Q=; b=055A4ZtylBPAzmjuLG4LmC6jmjMoaMAlzAYcNXTlH+c3rO4EzQ2d8r9JxFpimJbTlJ Y29p+TaygqWKxTupvNLWN/+X+1EGSuWRQ2VWRlBjFEHluiodeyLQ1z90pyR6HHTMBa1g Db3DhQW8jAAWJsBQ6grqKHHZu9sUr4nG1snMGNDOvP/mgF2gFkE6rRf1IiFJZ6RR547b 05MlVHxmV3MRAYzeRgkmq06tnSIuPfkavwFsDyhE0ZjF/Stsvtd0cwWuVZoZWeK9O4as ZDOX7qduAvcTcPTGEwcB0p7OEMYcqsa+OCYvfOOS2bJ3FJQ1tn+bF39YP8cu1DHpRtnd Hrrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=PXraO4BC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a170906169700b0099b6c03e6fdsi7742671ejd.960.2023.09.05.09.19.37; Tue, 05 Sep 2023 09:19:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bewilderbeest.net header.s=thorn header.b=PXraO4BC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bewilderbeest.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345993AbjIAJ1e (ORCPT + 9 others); Fri, 1 Sep 2023 05:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234850AbjIAJ1d (ORCPT ); Fri, 1 Sep 2023 05:27:33 -0400 Received: from thorn.bewilderbeest.net (thorn.bewilderbeest.net [71.19.156.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC4F710E7 for ; Fri, 1 Sep 2023 02:27:29 -0700 (PDT) Received: from hatter.bewilderbeest.net (unknown [IPv6:2602:3f:e471:aa00::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 66B40162; Fri, 1 Sep 2023 02:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1693560449; bh=lWtupZVh/hNglyvB+QPBKJ+SSe9s9P140z0bzxoSn8Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PXraO4BC1W1WtEFsmxZfj9q1UpgMjhJonDA+Ln+bz2DXlE2MLIX6hAvFmqiyXLYNz l7HsuCqEJNODFBHesM1dZCOpqzqazNJ9OPVzzV6iuJjg9ENYNOieytwjseO3ez2ZWU HnBF5OkZ7C1uRP4q9ITOZqbSg1+a7j61Sq2EOp8E= Date: Fri, 1 Sep 2023 02:27:28 -0700 From: Zev Weiss To: Naresh Solanki Cc: broonie@kernel.org, Liam Girdwood , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] regulator: userspace-consumer: Add regulator event support Message-ID: <5000a233-e992-455a-bca3-79aaa8713ff4@hatter.bewilderbeest.net> References: <20230831121412.2359239-1-Naresh.Solanki@9elements.com> <20230831121412.2359239-2-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20230831121412.2359239-2-Naresh.Solanki@9elements.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 31, 2023 at 05:14:09AM PDT, Naresh Solanki wrote: >Add sysfs attribute to track regulator events received from regulator >notifier block handler. > >Signed-off-by: Naresh Solanki >--- > drivers/regulator/userspace-consumer.c | 54 +++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > >diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c >index 97f075ed68c9..a936661d99cd 100644 >--- a/drivers/regulator/userspace-consumer.c >+++ b/drivers/regulator/userspace-consumer.c >@@ -29,6 +29,10 @@ struct userspace_consumer_data { > > int num_supplies; > struct regulator_bulk_data *supplies; >+ >+ struct kobject *kobj; >+ struct notifier_block nb; >+ unsigned long events; > }; > > static ssize_t name_show(struct device *dev, >@@ -89,12 +93,30 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, > return count; > } > >+static DEFINE_SPINLOCK(events_lock); >+ >+static ssize_t events_show(struct device *dev, >+ struct device_attribute *attr, char *buf) >+{ >+ struct userspace_consumer_data *data = dev_get_drvdata(dev); >+ unsigned long e; >+ >+ spin_lock(&events_lock); >+ e = data->events; >+ data->events = 0; I still don't think this is a good solution for the problem. I for one frequently examine things in sysfs using shell commands like 'cat' and 'grep' and such, and I suspect I'm (very, very) far from alone in that. With this design a user doing that could cause a monitoring daemon to miss events that it was expecting to receive via this file. I don't think we should be creating sysfs files that are secretly land mines that allow a curious user innocently peeking around in sysfs doing (they think) read-only operations to break things for other programs using those files. Zev