Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp282022pxk; Thu, 1 Oct 2020 02:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx61+E41Tc/NhfSteoV78F6dnO7pCD92kL5lufZFYNzXpqvtCfNVMhPmJwShXk9uWYOrMY5 X-Received: by 2002:a17:906:82d1:: with SMTP id a17mr6881212ejy.385.1601543368850; Thu, 01 Oct 2020 02:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601543368; cv=none; d=google.com; s=arc-20160816; b=ASfr6jUZV3Efvh6TzkFTGKKxlGIwuBw4Y0M4ExgNW4gP03WsRrFeaPqw3o29i6+ri/ nkYs6GJRosPbjuhOvE74oyNHvgo5xos1xTmGXiMWHm1y4lWSz6U180p89+86N9neV+Qw Z6l+Cet9mvj7z/BYgUj7NpHCkOsg4GODdN+CqDx49DFnpBwp/KWH6loovtD/GPX7psN6 M684PA2VqoKl6Wii/i6xSr2vwKveuxapTFvTuKZ1jp09YD+Lv3JU+VvBBi6oo6xVyuOz pG6IZsB+oY9tKyIA9PKbai7/BtBCbAl6E+yk+CZ4dKCe/uLBgtOcspjUyoEp1iH3CahZ c0ww== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5v0wK8KaFcB76lMCqK4+WPqSD8sMYzerPJ+WQv8/2tI=; b=LI+Zkwkyz6KBGA8Th9Q3DDJ3cDuqDgprWP0OXhXpz7y5wccPeZf3d1Csq6/fDk4opY 0D9+N6lY5Ew/lqa/I5c1eIYhTsVhdWC1nv00p38DOcA57LDfL6UtNVn7gIw9uZxa4l/5 dOUf8zNYOOpNhE4uv5DgrhFMBunDWDvlxGWAIp9v6mKJQ5/y22DuMXHB2i8mbGcMw4Rj 9xDznuuxs5Lv0+TkuJycVpaQ1CzNFE2RTvd8fJexzMEGN0BRBZvmFuvhmUvQUmtS8Tzl ID9xA2kup0ZJojfO1xxMpogkdFQ7rXMpV5Zv8kiPRfap2pEyMQQNsLp/SvXHFDSX3m+P k0yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si3068902ejm.431.2020.10.01.02.09.05; Thu, 01 Oct 2020 02:09:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731697AbgJAJFn (ORCPT + 99 others); Thu, 1 Oct 2020 05:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbgJAJFm (ORCPT ); Thu, 1 Oct 2020 05:05:42 -0400 Received: from smtp3.goneo.de (smtp3.goneo.de [IPv6:2001:1640:5::8:37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D62C0613D0; Thu, 1 Oct 2020 02:05:41 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.goneo.de (Postfix) with ESMTP id F395E23F0F3; Thu, 1 Oct 2020 11:05:38 +0200 (CEST) X-Virus-Scanned: by goneo X-Spam-Flag: NO X-Spam-Score: -2.958 X-Spam-Level: X-Spam-Status: No, score=-2.958 tagged_above=-999 tests=[ALL_TRUSTED=-1, AWL=-0.058, BAYES_00=-1.9] autolearn=ham Received: from smtp3.goneo.de ([127.0.0.1]) by localhost (smtp3.goneo.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jn13Cqk_puzT; Thu, 1 Oct 2020 11:05:37 +0200 (CEST) Received: from lem-wkst-02.lemonage (hq.lemonage.de [87.138.178.34]) by smtp3.goneo.de (Postfix) with ESMTPSA id 1EEF22402AE; Thu, 1 Oct 2020 11:05:37 +0200 (CEST) Date: Thu, 1 Oct 2020 11:05:31 +0200 From: Lars Poeschel To: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= Cc: Thierry Reding , Lee Jones , "open list:PWM SUBSYSTEM" , open list , Greg Kroah-Hartman Subject: Re: [PATCH] pwm: sysfs: Set class on pwm devices Message-ID: <20201001090531.gubfwmznlto2ng6l@lem-wkst-02.lemonage> References: <20200929121953.2817843-1-poeschel@lemonage.de> <20200930065726.fjcsm4pfh65medgl@pengutronix.de> <20200930092056.maz5biy2ugr6yc3p@lem-wkst-02.lemonage> <20200930094146.73s3qzvf5ekjeavc@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200930094146.73s3qzvf5ekjeavc@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 11:41:46AM +0200, Uwe Kleine-K?nig wrote: > Hello, > > I added Greg Kroah-Hartman who I discussed this with via irc a bit to > Cc:. > > On Wed, Sep 30, 2020 at 11:20:56AM +0200, Lars Poeschel wrote: > > thank you for your review! > > > > On Wed, Sep 30, 2020 at 08:57:26AM +0200, Uwe Kleine-K?nig wrote: > > > On Tue, Sep 29, 2020 at 02:19:53PM +0200, poeschel@lemonage.de wrote: > > > > From: Lars Poeschel > > > > > > > > This adds a class to exported pwm devices. > > > > Exporting a pwm through sysfs did not yield udev events. The > > > > > > I wonder what is your use-case here. This for sure also has a place to > > > be mentioned in the commit log. I suspect there is a better way to > > > accomplish you way. > > > > Use-case is to be able to use a pwm from a non-root userspace process. > > I use udev rules to adjust permissions. > > Hmm, how do you trigger the export? Without being aware of all the > details in the sysfs code I would expect that the exported stuff is > available instantly once the write used to export the PWM is completed. > So changing the permissions can be done directly after triggering the > export in the same process. The export is triggered through the userspace process itself. Why can it do this ? Because there is another udev rule, that changes permissions when a pwmchip appears. Then I'd like to have the second udev rule, that changes permissions on the freshly exported pwm. The userspace process can't do this. You are right I could propably do everything from within udev: If a pwmchip appears, export certain pwms and right away change their permissions. It does not also not feel right. It'd require knowledge from the userspace application to be mapped to udev. > Out of interest: What do you use the pwm for? Isn't there a suitable > kernel driver that can do the required stuff? Compared to the kernel-API > the sysfs interface isn't atomic. Is this an annoyance? Use-case is generating a voltage from the pwm. This voltage is used to signal different states and does not change very often. This is absolutely not annoying that this is not atomic. We just change the duty cycle on the fly. Everything else is configured one time at startup. I'd call what I need pwm-dac. I could not find a ready to use driver. Maybe I could misuse some kernel driver for this. Maybe I could use pwm-led or pwm-brightness or pwm-fan. Propably pwm-regulator could work, there is even a userspace facing part for this, but this is not devicetree ready. ...and the worst, please don't blame me: The application is java, so ioctl is a problem. So, sysfs was quite a good choice for me. Regards, Lars