Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp393811ybl; Wed, 4 Dec 2019 04:38:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyAtBfBwka7dkF/0bxsnL8WZQetSLuffwTTfJQzrtnsGSTBuAoawergaErvTlPx3sKe07j5 X-Received: by 2002:aca:d5d3:: with SMTP id m202mr2199306oig.161.1575463128327; Wed, 04 Dec 2019 04:38:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575463128; cv=none; d=google.com; s=arc-20160816; b=HTt8ETj1YMvTlGbqjHt3WksGnxYd6tmiF/mkcYPMZMhH1qrO3yqTH5kLoV1eD0JrYL NSZOba9bSp4kwHHV453TPxWpqJ0Jtcvg40+xY1gdGL/Z3dgoIuEtQiix/ZXFFJoD9CGH hvFX9UD9DH9da+kXpLh514LjdcuU1wQvZykc5tBCcEPkrNqmX1ADKhqDU/8LdNpNDZWO A1n3B1Mn3qCDZqGSBH9uq5XZyWbwj5JVUJiubfR74w85alfsVzx1ZKTT2uPJ8XzV6Vjv mxHHCjZMDTXwVaSRZNktvLaaIqsXmdyusBKJUuBwatcAULzAlnjubop/Cl9V+WxDq2PZ uDQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9bP4HXFmXemcDSo9TnjEkADZf0hlMOoRKnB6EjljnHY=; b=cj9//GxfUOhqKH6zPieTFZ9FGSqq9Rzp/oUXKNhrMSMP/dQzByH19oeHPbMwlhnxCP lBz60X/pgq5zPpVBDJ7Sh4w99WlRQJbByoPiTMu+wdotvXjushl342XL9/Bnz0fndJ47 HkeypOAu3OU+cljL1BqprXa/BaMfNefiSa4HO7WRJRTxxuRhqkbFQOjAF7EkLakJlGm7 pHBB+Ak0eqwGztiLKj/hfmcS9IlMD83kbP8qfQfGEN6nNf5knWLRatA0tUFJEBgF8e9P YhZHU77eA6pxkjQPQQ3OUZ3VjH8S2CNeuqwjopxB4ISK27EGukXYDzPzg3Eh9L8AnfNN z0gQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k188si3066771oib.201.2019.12.04.04.38.35; Wed, 04 Dec 2019 04:38:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727731AbfLDMiA (ORCPT + 99 others); Wed, 4 Dec 2019 07:38:00 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:54886 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfLDMiA (ORCPT ); Wed, 4 Dec 2019 07:38:00 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 39BFF1C25EC; Wed, 4 Dec 2019 13:37:58 +0100 (CET) Date: Wed, 4 Dec 2019 13:37:57 +0100 From: Pavel Machek To: Jean-Jacques Hiblot Cc: jacek.anaszewski@gmail.com, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, tomi.valkeinen@ti.com Subject: Re: [PATCH v7 2/2] leds: Add control of the voltage/current regulator to the LED core Message-ID: <20191125163738.GC3816@amd> References: <20191021174751.4421-1-jjhiblot@ti.com> <20191021174751.4421-3-jjhiblot@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CdrF4e02JqNVZeln" Content-Disposition: inline In-Reply-To: <20191021174751.4421-3-jjhiblot@ti.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --CdrF4e02JqNVZeln Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > A LED is usually powered by a voltage/current regulator. Let the LED core > know about it. This allows the LED core to turn on or off the power supply > as needed. >=20 > Because turning ON/OFF a regulator might block, it is not done > synchronously but done in a workqueue. Turning ON the regulator is > always How will this interact with LEDs that can be used from atomic context? > +static ssize_t regulator_auto_off_store(struct device *dev, > + struct device_attribute *attr, const char *buf, size_t size) > +{ > + struct led_classdev *led_cdev =3D dev_get_drvdata(dev); > + ssize_t ret =3D size; > + bool auto_off; > + > + if (strncmp(buf, "enable\n", size) =3D=3D 0) > + auto_off =3D true; > + else if (strncmp(buf, "disable\n", size) =3D=3D 0) > + auto_off =3D false; > + else > + return -EINVAL; Sounds like device power management to me. Is it compatible with that? > @@ -135,6 +203,8 @@ static void set_brightness_delayed(struct work_struct= *ws) > (led_cdev->flags & LED_HW_PLUGGABLE))) > dev_err(led_cdev->dev, > "Setting an LED's brightness failed (%d)\n", ret); > + > + led_handle_regulator(led_cdev); > } > You only modify set_brigthness_delays, so this will not work at all for non-blocking LEDs, right? > static void led_set_software_blink(struct led_classdev *led_cdev, > @@ -189,6 +259,7 @@ static void led_blink_setup(struct led_classdev *led_= cdev, > void led_init_core(struct led_classdev *led_cdev) > { > INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed); > + INIT_DELAYED_WORK(&led_cdev->reg_off_work, turn_off_regulator_delayed); > =20 Could this re-use the workqueue? Many systems will not need regulators, so this is overhead... > + /* > + * the regulator must be turned off. This cannot be Use "The", and fix double spaces between must and be. > + } else if (regulator_on && old =3D=3D REG_R_OFF_U_OFF) { > + /* > + * the regulator must be enabled. This cannot be here "The" > + /* > + * small optimization. Cancel the work that had been started "Small." > +#include > + > +/* > + * The regulator state tracks 2 boolean variables: > + * - the state of regulator (or more precisely the state required by > + * led core layer, as many users can interact with the same regulator). > + * It is tracked by bit 0. > + * - the state last asked-for by the LED user. It is tracked by bit 1. > + */ > +#define REG_R_ON BIT(0) > +#define REG_U_ON BIT(1) > + > +enum { REG_R_OFF_U_OFF =3D 0, > + REG_R_ON_U_OFF =3D REG_R_ON, > + REG_R_OFF_U_ON =3D REG_U_ON, > + REG_R_ON_U_ON =3D REG_R_ON | REG_U_ON > +}; That's quite weird use of enum. > +++ b/include/linux/leds.h > @@ -149,6 +149,15 @@ struct led_classdev { > =20 > /* Ensures consistent access to the LED Flash Class device */ > struct mutex led_access; > + > + /* regulator */ "Regulator". Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --CdrF4e02JqNVZeln Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCXeeopQAKCRAw5/Bqldv6 8uypAJ9qIc1TE8M1YLh8IbRiajmjRpCowACcDMrhUrZ+kLOC4MH0sIilzbC58Bo= =AhQV -----END PGP SIGNATURE----- --CdrF4e02JqNVZeln--