Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1253584imw; Tue, 5 Jul 2022 06:29:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tMebKbfRXGzRagegi8WCwvcy7+cmbyh3xz9M3PO+rkyYAISJnnUafHIk2wYnapVr/AhK4w X-Received: by 2002:a17:90b:1c82:b0:1ee:eb41:b141 with SMTP id oo2-20020a17090b1c8200b001eeeb41b141mr43035644pjb.143.1657027764899; Tue, 05 Jul 2022 06:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027764; cv=none; d=google.com; s=arc-20160816; b=iZVNa2CLSZumROsfrtcecY1lFUFWQFspl3Sue/J4NQ/QJMFIm3AgIme7oXCV/WulOG IrvJxzfpur4xXyxv+TBW8HcUd2xJH22pYLdZdhwqYV0AyIINu5UPH1YaVm/CFqgB5wN2 IDBuWU44KF4cgM9rz+mZ/B59enySyjn+i0Ou4wuGmUTZ4WNnY0n7sofA5cdGP474fRK/ plQjKyG9CYrXkkddVXAw4jN2TwK+8QjdUpkIuq0OI8U8QVNT6TGIo5lpO7NYLuw0WJPL rfiOZ7YJ+7UrH+qnIuzpXd3ARMKS6IjorOV6o3Sz2cuFBawEsknF4M+IjCCDrWpjzXMU Et6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=x+/EDObtox90U/ADEGqSDnrz6rRpf9b8cL6zSMAE/pc=; b=j/AcaSPShKcdQDOqkjhbh5u8g6qExkUSxcKX+3Zw/WfyUNP9cyptLP7d8VVzUD+2Ya 64Z4QtjNo9tixHlX5QO/BpLZwNITEzKPQwSyYsFr/CR/EJceSGbQhCZiYIBIHuCk5+yO fd/mHZmuEeCubfcR/2zV/709tTyV2uUjBkUe5HIHjlVIT+5QZ/95Ip2gr/SQKsSHvvKu DtPYV/XOVPJH5SbPzDF2jWc0fxYp/8IWEipOF6NNap2WFSM7WOhpebbaEldwrnXwZvA9 PE0LJ9fdKdenidaiTVoOGXt2DvEmYbuEvOeeBGn1cn1BZTyhrHH2R0/VBPuagGjUtGTI L1LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SGQ+VMDC; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na2-20020a17090b4c0200b001ed5108dc17si31093016pjb.143.2022.07.05.06.29.12; Tue, 05 Jul 2022 06:29:24 -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=@kernel.org header.s=k20201202 header.b=SGQ+VMDC; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239608AbiGEMhm (ORCPT + 99 others); Tue, 5 Jul 2022 08:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239442AbiGEMal (ORCPT ); Tue, 5 Jul 2022 08:30:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0BC1F63B; Tue, 5 Jul 2022 05:22:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 92BC7B816A4; Tue, 5 Jul 2022 12:22:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03C6BC341C8; Tue, 5 Jul 2022 12:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657023761; bh=Hl6oQo9fBaw8lhEcoZN8z4oGgTIORkI///LPXaadh+8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SGQ+VMDCiVJPI4dlqjm6Uv2sKZm0+joTht54YfW3He8Z4TXCbeHtiJKZdcs1VujQB XAA2SxR6GNjQtjJKLXg7y0JYM5Pz/vsfXtRkhyGy6LKLQqz3Np79+MNzF60ClPJoQ2 ooyBc3m5oTtSEMv4OJbpNAiQA7yu3QQxnc+nMB3uvPwmV563psN5lrHm3fRSrJPqe9 vWttuvEoEvZ8wLAsrNvAc7KAS4SfQC4GJa9ZKpY7Vcf86/dBvakGk9dyVc6ouR9k69 XLfGDOgNuwErrygPnknj+3tPXCpXiczR2VNMUTBkvimKnSi34NCzhkDHzteL5aOhsu Z/fKTCx/OnzZg== Received: by pali.im (Postfix) id 3564ACBF; Tue, 5 Jul 2022 14:22:38 +0200 (CEST) Date: Tue, 5 Jul 2022 14:22:38 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Marek =?utf-8?B?QmVow7pu?= Cc: Pavel Machek , Rob Herring , Krzysztof Kozlowski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] leds: Add support for Turris 1.x LEDs Message-ID: <20220705122238.ul3cctrxkkttge3m@pali> References: <20220705000448.14337-1-pali@kernel.org> <20220705000448.14337-2-pali@kernel.org> <20220705123705.0a9caead@thinkpad> <20220705105609.cpabhrwozyeejwqe@pali> <20220705135227.6380d6d5@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220705135227.6380d6d5@thinkpad> User-Agent: NeoMutt/20180716 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Tuesday 05 July 2022 13:52:27 Marek Behún wrote: > On Tue, 5 Jul 2022 12:56:09 +0200 > Pali Rohár wrote: > > > > > > > I don't consider this a problem > > > > I think it is a problem, to ensure that 'cat multi_intensity' for every > > Misunderstanding. I meant that I don't consider the eventual > inconsistency a problem, i.e. I agree with your code. > > > > Or maybe just write the value? > > > Is the register write expensive on the CPLD or why are you trying to > > > avoid it if unnecessary? > > > > I just do not see any reason to do unnecessary writes. > > But now you do an unnecessary check. I think that testing if some bit is set in 32-bit general purpose processor register is something which really does not play role here. Note that readb() is always needed to do because it is required to modify just one bit and this cannot be done without read-modify-write operations. > Unless the writeb() is slower than > that check. Since this isn't i2c, I am wondering how fast that writeb() > is... But this is just me wondering, we can keep it the way you wrote > it... > > > > > > > Hmm. Wouldn't it make more sense to simply have the global brightness > > > accept values from 0 to 7, instead of mapping it to 256 values? And > > > call it something like selected_brightness_index? > > > > All other drivers have brightness entry which operates on monotone > > brightness property. > > Brightness levels do not have to be monotone and by default are > > decreasing: 0 = brightness with higher intensity; 7 = no intensity (off) > > What do you mean all other drivers? AFAIK only one driver does this > global brightness thing, and that is Omnia. The global brightness is > something different from LED cdev brightness property, the same names > are just coincidental (in fact it caused confusion when Pavel was > first reviewing Turris Omnia driver). Maybe it should have been called > global_intensity, to avoid the confusion... Ok. I thought "brightness" == "brightness" too. Anyway, as Omnia has this API it makes sense to use same API for other devices, this allows userspace software to be compatible with more devices. > > I cannot image who would like or prefer usage of such API. > > One file that represents the index of the selected global intensity (as > is stored internally in the CPLD) and another file that represents the > configured intensities between which the button switches makes sense, > IMO. And this is the issue. If you want to get current brightness, you need to read two files and then do non-trivial logic to derive current brightness. > > Just stick with existing APIs. "brightness" entry takes intensity value > > which is monotone, 0 the lowest, MAX (=255) the highest. > > Again, the name "brightness" does not imply that it is the same thing > as "brightness" of a LED cdev. And since it even doesn't live in > /sys/class// directory, we are proposing new API and can use > whatever makes sense. > > I am not saying that the way you did it doesn't make sense. I am just > wondering if it wouldn't make more sense to be able to read the index > of what the user selected by button pressing. > > Marek So what about exporting another sysfs file which controls current level (0-7)?