Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp585055pxf; Thu, 11 Mar 2021 09:58:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOP3dF+NQB33KeUzH+bj67ewvMwdJJjrBghlQyGgiTq1db+q0uM021C01XT7YQ9GF/K74H X-Received: by 2002:a17:906:add7:: with SMTP id lb23mr4179018ejb.273.1615485531948; Thu, 11 Mar 2021 09:58:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615485531; cv=none; d=google.com; s=arc-20160816; b=VfmgnP5irhVYveVQa6eSZ+wjTe8YmZEv1waa8V6DK6aFQTXlwubgxQaoF3YU7sU/3F BDM/Z1Gj9o2SqWRJnGsmxfHFUg6KrsxL5eNT6HUbKdDImRI5nFJ5Y7xQkd+hKVATRRgG qfIZaJQIUVggOpJDRS2JCN4kk5x5NxNnQpkj330pRlECMeMh361nEzSn11tuDlCrYh6G w4Q1zNQ70F1U3gpegfdugTtSfm/KOu6gv0c2UjwOSrnETaRVn+7M8/1Ue1g7lCMJToNK pwPD0lC6a7e/AmgbwRsy6ZEz3CbpwbnYXGZmf1w18lfMKpbrqH0B08dnJy5kHNsYMJRD RIJg== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=0QUbZJuplPr7o89Qh+WB553ZbR6I9ilbLQihud+p0t0=; b=pyvIbj4Ie7NaSeRUTfNSybVjI+95+XjO1RQYdofFeHGGq1Q9jJaFXpSz+Ui9fsEGiM BvUWQKxNdar3MYi4hbg2zcUZ2V9U3RAiA4gbHTl4xLDlP+a1dQR27AotSmP4YIeKzTdZ rwDC1psrH9CVxWblUCVteLSQbNZOrZm3ebjgyvCx71aG+3v7shwq8MDFJBGYLwI5zSUQ 2+W5lmE8kx1SDNTCdFePIUTJrbZ43IjTCP42QaMAM9VCB5QHf7x6x1nM/eB/3hHZpVeD D5iAl+5nZnCyCEYCqON/cvuO5r6lhgIoFQJv9nIL6C9v0EznHp9epCj09HYVWESuQgbU CczA== 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 e13si2152986edz.432.2021.03.11.09.58.28; Thu, 11 Mar 2021 09:58:51 -0800 (PST) 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 S229930AbhCKR5F (ORCPT + 99 others); Thu, 11 Mar 2021 12:57:05 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:54964 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhCKR4t (ORCPT ); Thu, 11 Mar 2021 12:56:49 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 143641C0B77; Thu, 11 Mar 2021 18:56:47 +0100 (CET) Date: Thu, 11 Mar 2021 18:56:46 +0100 From: Pavel Machek To: Hermes Zhang Cc: Dan Murphy , kernel@axis.com, Hermes Zhang , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH] leds: leds-dual-gpio: Add dual GPIO LEDs driver Message-ID: <20210311175646.GA11088@duo.ucw.cz> References: <20210311130408.10820-1-chenhui.zhang@axis.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline In-Reply-To: <20210311130408.10820-1-chenhui.zhang@axis.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Hermes Zhang >=20 > Introduce a new Dual GPIO LED driver. These two GPIOs LED will act as > one LED as normal GPIO LED but give the possibility to change the > intensity in four levels: OFF, LOW, MIDDLE and HIGH. Do you have hardware that uses it? Seems reasonably sane, but: > +config LEDS_DUAL_GPIO > + tristate "LED Support for Dual GPIO connected LEDs" > + depends on LEDS_CLASS > + depends on GPIOLIB || COMPILE_TEST This will break compile, right? Describe which hardware needs it in Kconfig. > index 2a698df9da57..10015cc81f79 100644 > --- a/drivers/leds/Makefile > +++ b/drivers/leds/Makefile Put it into leds/simple . You may need to create it. No dts bindings etc? > +#define GPIO_LOGICAL_ON 1 > +#define GPIO_LOGICAL_OFF 0 Let's not do that. > + priv =3D container_of(led_cdev, struct gpio_dual_leds_priv, cdev); > + > + if (value =3D=3D LED_FULL) { > + gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_ON); > + gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_ON); > + } else if (value < LED_FULL && value > LED_HALF) { > + /* Enable high only */ > + gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_OFF); > + gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_ON); > + } else if (value <=3D LED_HALF && value > LED_OFF) { > + /* Enable low only */ > + gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_ON); > + gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_OFF); > + } else { > + gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_OFF); > + gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_OFF); > + } > +} Make max brightness 4 and use logical operations to set the right values. > + priv->cdev.name =3D of_get_property(node, "label", NULL); > + priv->cdev.max_brightness =3D LED_FULL; =3D 3. > +static const struct of_device_id of_gpio_dual_leds_match[] =3D { > + { .compatible =3D "gpio-dual-leds", }, Need dts docs for this. > +MODULE_DESCRIPTION("Dual GPIO LED driver"); > +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR? GPL v2+ if you can do that easily. Best regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --qMm9M+Fa2AknHoGS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCYEpZ3gAKCRAw5/Bqldv6 8mJ0AJ9f/8ma0HFtMfdwbHjo117qF//KggCfdOMBp2A2ug22BKkVZdL/UA6RD+M= =mBc4 -----END PGP SIGNATURE----- --qMm9M+Fa2AknHoGS--