Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp376696lqh; Tue, 7 May 2024 01:41:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9NfEp9Qr7QMskTIyTCWg8isGatmswu7nDjo26FuORDsw45zNI5zU/y0uDPIZVIpWcA0if4SKUBlyyDciSoUrisCvTifYdUrCAbarPyA== X-Google-Smtp-Source: AGHT+IH5w3AbuTD2CXFNmoVOWd8Uf8uY4c5Q5HQnTSdwlcUz8Ot0zC62lOEnxrKRCakl7lSxu6OU X-Received: by 2002:aa7:d351:0:b0:572:d4fc:cc3 with SMTP id m17-20020aa7d351000000b00572d4fc0cc3mr7267023edr.2.1715071277704; Tue, 07 May 2024 01:41:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715071277; cv=pass; d=google.com; s=arc-20160816; b=KsGXOqtxzPQzcNBmnhdfHZYWB+YA8u6mnIYEYD7IihwBPYNvbFrN44D6mEQikKe6UD NU1pvvSCuKnX4BZVFvpis9vAWq9h3GcoDmtKgwoF+bRyROrsb4L3LYLJBdWgc5OOP+Z+ UpMxP+OPItO7IjnZtkBjvATR87NjA+stdVRJc34SVMq+VlMtEjRTjuO/skHBwwax67wl WP5scdOjb1e0urvdWPCvbbwk2LxiEdrApDbofomjssy9NYjrvoCH1s6PKu6i1JwR26P0 v4wvYz3HCG/VRx0luSsWkKfjhgMFnKqwIiMm0D/piTT4CagG/AB+kFIpbPPjHMuVDyYY Ac8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vEDsPJSu04J6yEg6hJSM5Y0W+r48O6GjHP0ckYabSEo=; fh=p5qEDRbY6YwxxwlM9x8fDoNBFYaD8hcuuQFqNLFF+IQ=; b=Y+mFs/EK2Ykb3aS8Y2HtXZ0VKGIfWx4mOmX7lcjoLuvkP2AXe+jsPKXfU/7+8roL+Q /bKQDXS5MXIe+9AE569CSpDaFfNW1ksMetjISydP6oPwVkwZxoaOlaG+R4xHFerz76ys Tp7CWo0gptVFR2y5CIFX1SOxniDMIpDnsaNeBnkUlldvf3ydMCoKOvSUyLU3JUi8ydYR Rxmjyj8eV1nxXLwDOJ7kjbcl+aVpSpTC4Mdfoj5gVYZN/uWtdi1iB+TCvjhOLmHz026Q Q4RrbZAI8YtfWNZUKHNlsWsiIKLwHtUD4btRvP4BiNEEqPoTsIpTAaS8pMheTVVB0yri WgMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KhSBliwr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-170885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z9-20020a056402274900b00572ab8ed69esi2680912edd.541.2024.05.07.01.41.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 01:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KhSBliwr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-170885-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170885-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 462631F22D7B for ; Tue, 7 May 2024 08:41:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2370F14D433; Tue, 7 May 2024 08:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KhSBliwr" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 123AF13CA8D; Tue, 7 May 2024 08:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715071259; cv=none; b=kIkMsXnMuFJrDGh1WcljmzDxJmeSN40pWVuYFPl89s/OUibjcdc2LwdGwmUtFkzn8YlB6sxQGQshiqyjoDK6lxxHIznDiofuATNGS9tktc0JRv/gr35fq1E2RA5YMAqK/+rqKsC2mECTJ0d5pepsylcF3wD90k01lWDUbm9vjfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715071259; c=relaxed/simple; bh=sUjfAESTunl9013EBi9dsmv2GLZ5rTVceLRbegv7l8I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mKIbnsDIBnDG6EuFvzxCbcSPW5IMZyGfO6YjIYDXvLQaDA7iCZra+ygqJCuRYy0cJ9Xke9AU4JRF5apqnRvZd5es94TgD1J4BwA6E/BmrICxThTRqpQ3Qk1MwThWvGVCN57sHGWcRnH3OIGRZCzh7Q4fsc4EBSoVOIpqkYZzQaQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KhSBliwr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2607AC3277B; Tue, 7 May 2024 08:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715071258; bh=sUjfAESTunl9013EBi9dsmv2GLZ5rTVceLRbegv7l8I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KhSBliwrI/bU2fZ42hVY1khLzHigeyRIA/KhyOPr/A0NKIb3ugHhAkZYBAYYg78+4 nDFLqlYda/5fbLCZhTM/cMxc9mM2X5Dw3nAeNJFVsLQReagAvalOWQd+4dWCwnI1WR yjWc+JBRcVIdp0YdqdB0fYPDFlAuhysswwhXi86TgowjWEDnXJ3o7dkyo00xCMy5eN D6ZKTyybzFg+so1fTvzcXQK/v8K3FIoKubLjPQKCtHRsvjYB65fMeK/GhoibnrZ866 97fyP0TE8kIdSkfuEaADnQyyLKWndlw9vs9NiwCdPbrmQ0OUGmb117mNbbur88tUeq 3m7Hrytq62LpA== Date: Tue, 7 May 2024 09:40:52 +0100 From: Lee Jones To: =?iso-8859-1?Q?Andr=E9?= Apitzsch Cc: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kees Cook , "Gustavo A. R. Silva" , Bjorn Andersson , Konrad Dybcio , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-arm-msm@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org Subject: Re: [PATCH v2 2/3] leds: sy7802: Add support for Silergy SY7802 flash LED controller Message-ID: <20240507084052.GW1227636@google.com> References: <20240401-sy7802-v2-0-1138190a7448@apitzsch.eu> <20240401-sy7802-v2-2-1138190a7448@apitzsch.eu> <20240411124855.GJ1980182@google.com> <20240503071953.GD1227636@google.com> <3309a9f1f5848681d0acf3bfdf9b6525fc88e1bc.camel@apitzsch.eu> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3309a9f1f5848681d0acf3bfdf9b6525fc88e1bc.camel@apitzsch.eu> On Sat, 04 May 2024, André Apitzsch wrote: > Am Freitag, dem 03.05.2024 um 08:19 +0100 schrieb Lee Jones: > > On Thu, 11 Apr 2024, Lee Jones wrote: > > > > > On Mon, 01 Apr 2024, André Apitzsch via B4 Relay wrote: > > > > > > > From: André Apitzsch > > > > > > > > Add support for SY7802 flash LED controller. It can support up to > > > > 1.8A > > > > flash current. > > > > > > This is a very small commit message for a 500+ line change! > > > > > > Please, tell us more. > > > > > > > Signed-off-by: André Apitzsch > > > > --- > > > >  drivers/leds/flash/Kconfig       |  11 + > > > >  drivers/leds/flash/Makefile      |   1 + > > > >  drivers/leds/flash/leds-sy7802.c | 532 > > > > +++++++++++++++++++++++++++++++++++++++ > > > >  3 files changed, 544 insertions(+) > > > > > > > > diff --git a/drivers/leds/flash/Kconfig > > > > b/drivers/leds/flash/Kconfig > > > > index 809b6d98bb3e..f39f0bfe6eef 100644 > > > > --- a/drivers/leds/flash/Kconfig > > > > +++ b/drivers/leds/flash/Kconfig > > > > @@ -121,4 +121,15 @@ config LEDS_SGM3140 > > > >     This option enables support for the SGM3140 500mA > > > > Buck/Boost Charge > > > >     Pump LED Driver. > > > >   > > > > +config LEDS_SY7802 > > > > + tristate "LED support for the Silergy SY7802" > > > > + depends on I2C && OF > > > > + depends on GPIOLIB > > > > + select REGMAP_I2C > > > > + help > > > > +   This option enables support for the SY7802 flash LED > > > > controller. > > > > +   SY7802 includes torch and flash functions with > > > > programmable current. > > > > + > > > > +   This driver can be built as a module, it will be > > > > called "leds-sy7802". > > > > + > > > >  endif # LEDS_CLASS_FLASH > > > > diff --git a/drivers/leds/flash/Makefile > > > > b/drivers/leds/flash/Makefile > > > > index 91d60a4b7952..48860eeced79 100644 > > > > --- a/drivers/leds/flash/Makefile > > > > +++ b/drivers/leds/flash/Makefile > > > > @@ -11,3 +11,4 @@ obj-$(CONFIG_LEDS_QCOM_FLASH) += leds-qcom- > > > > flash.o > > > >  obj-$(CONFIG_LEDS_RT4505) += leds-rt4505.o > > > >  obj-$(CONFIG_LEDS_RT8515) += leds-rt8515.o > > > >  obj-$(CONFIG_LEDS_SGM3140) += leds-sgm3140.o > > > > +obj-$(CONFIG_LEDS_SY7802) += leds-sy7802.o > > > > diff --git a/drivers/leds/flash/leds-sy7802.c > > > > b/drivers/leds/flash/leds-sy7802.c > > > > new file mode 100644 > > > > index 000000000000..c03a571b0e08 > > > > --- /dev/null > > > > +++ b/drivers/leds/flash/leds-sy7802.c > > > > @@ -0,0 +1,532 @@ > > > > [...] > > > > > > +static int sy7802_torch_brightness_set(struct led_classdev > > > > *lcdev, enum led_brightness level) > > > > > > s/level/brightness/ > > > > > > > +{ > > > > + struct sy7802_led *led = container_of(lcdev, struct > > > > sy7802_led, flash.led_cdev); > > > > + u32 led_enable_mask = led->led_no == SY7802_LED_JOINT ? > > > > SY7802_LEDS_MASK_ALL : > > > > +       SY7802_LEDS_MASK(led->led_no); > > > > > > Do all of the fancy multi-line assignment outside of the > > > declaration block. > > > > > > > + u32 enable_mask = SY7802_MODE_MASK | led_enable_mask; > > > > + u32 val = level ? led_enable_mask : SY7802_MODE_OFF; > > > > + struct sy7802 *chip = led->chip; > > > > + u32 curr; > > > > > > This is a temporary placeholder for fled_torch_used, right? > > > > > > fled_torch_used_tmp?  Sometimes abbreviated to tmp. > > > > > > > + u32 mask; > > > > > > That's a lot of masks.  Which one is this? > > > > > > > + int ret; > > > > + > > > > + mutex_lock(&chip->mutex); > > > > + > > > > + /* > > > > + * There is only one set of flash control logic, and > > > > this flag is used to check if 'strobe' > > > > > > The ',' before 'and' is superfluous. > > > > > > > + * is currently being used. > > > > + */ > > > > > > Doesn't the variable name kind of imply this? > > > > > > > + if (chip->fled_strobe_used) { > > > > + dev_warn(chip->dev, "Please disable strobe first > > > > [%d]\n", chip->fled_strobe_used); > > > > > > "Cannot set torch brightness whilst strobe is enabled" > > > > > > > + ret = -EBUSY; > > > > + goto unlock; > > > > + } > > > > + > > > > + if (level) > > > > + curr = chip->fled_torch_used | BIT(led->led_no); > > > > + else > > > > + curr = chip->fled_torch_used & ~BIT(led- > > > > >led_no); > > > > + > > > > + if (curr) > > > > + val |= SY7802_MODE_TORCH; > > > > + > > > > + /* Torch needs to be disabled first to apply new > > > > brightness */ > > > > > > "Disable touch to apply brightness" > > > > > > > + ret = regmap_update_bits(chip->regmap, > > > > SY7802_REG_ENABLE, SY7802_MODE_MASK, > > > > + SY7802_MODE_OFF); > > > > + if (ret) > > > > + goto unlock; > > > > + > > > > + mask = led->led_no == SY7802_LED_JOINT ? > > > > SY7802_TORCH_CURRENT_MASK_ALL : > > > > > > Why not just use led->led_no in place of mask? > > > > mask and led->led_no are assigned the same value from this point on. > > Thanks for the clarification. > How to you come to the conclusion that mask and led->led_no are > assigned the same value from this point on? Because I am blind and didn't see the double equals ("=="). #shouldhavegonetospecsavers -- Lee Jones [李琼斯]