From: Lee Jones <lee@kernel.org>
To: "André Apitzsch" <git@apitzsch.eu>
Cc: Pavel Machek <pavel@ucw.cz>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
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
Date: Thu, 2 May 2024 10:10:17 +0100 [thread overview]
Message-ID: <20240502091017.GF5338@google.com> (raw)
In-Reply-To: <c5e5f49295350ada2cdb280a77b1c877058d4d64.camel@apitzsch.eu>
On Wed, 01 May 2024, André Apitzsch wrote:
> Hi Lee Jones,
>
> thanks for the feedback. I will address your comments in the next
> version. I have a few comments/questions though, see below.
>
> Best regards,
> André
>
> Am Donnerstag, dem 11.04.2024 um 13:48 +0100 schrieb Lee Jones:
> > On Mon, 01 Apr 2024, André Apitzsch via B4 Relay wrote:
> > >
> > > [..]
> > > +
> > > +#define SY7802_TIMEOUT_DEFAULT_US 512000U
> > > +#define SY7802_TIMEOUT_MIN_US 32000U
> > > +#define SY7802_TIMEOUT_MAX_US 1024000U
> > > +#define SY7802_TIMEOUT_STEPSIZE_US 32000U
> > > +
> > > +#define SY7802_TORCH_BRIGHTNESS_MAX 8
> > > +
> > > +#define SY7802_FLASH_BRIGHTNESS_DEFAULT 14
> > > +#define SY7802_FLASH_BRIGHTNESS_MIN 0
> > > +#define SY7802_FLASH_BRIGHTNESS_MAX 15
> > > +#define SY7802_FLASH_BRIGHTNESS_STEP 1
> >
> > Much nicer to read if everything was aligned.
>
> Using tab size 8, SY7802_FLASH_BRIGHTNESS_* look aligned to me. Do you
> refer to SY7802_TORCH_BRIGHTNESS_MAX here?
These were not aligned in my mailer. You can ignore.
> > > [..]
> > > +
> > > + /*
> > > + * 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"
>
> The comment and the warn message are taken from 'leds-mt6370-flash.c'.
> But I think using the warn message you suggested the comment can be
> removed.
It's an improvement, right?
> > > + 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?
>
> I might be missing something, but I don't know how to use led->led_no
> in place of mask, when
> led->led_no is in {0,1,2} and
> mask is in {0x07, 0x38, 0x3f}.
This doesn't make much sense.
I guess you mean that led_no is a u8 and mask is a u32.
What happens if you cast led_no to u32 in the call to regmap_update_bits()?
> > Easier to read if you drop SY7802_TORCH_CURRENT_MASK_ALL to its own
> > line.
> >
> > > + SY7802_TORCH_CURRENT_MASK(led->led_no);
> > > +
> > > [..]
> > > +
> > > +static int sy7802_probe(struct i2c_client *client)
> > > +{
> > > + struct device *dev = &client->dev;
> > > + struct sy7802 *chip;
> > > + size_t count;
> > > + int ret;
> > > +
> > > + count = device_get_child_node_count(dev);
> > > + if (!count || count > SY7802_MAX_LEDS)
> > > + return dev_err_probe(dev, -EINVAL,
> > > + "No child node or node count over max led
> > > number %zu\n", count);
> >
> > Split them up and report on them individually or combine the error
> > message:
> >
> > "Invalid amount of LED nodes"
>
> This snippet was also taken from 'leds-mt6370-flash.c'.
Old mistakes should not be repeated. :)
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2024-05-02 9:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 21:23 [PATCH v2 0/3] Add sy7802 flash led driver André Apitzsch via B4 Relay
2024-04-01 21:23 ` [PATCH v2 1/3] dt-bindings: leds: Add Silergy SY7802 flash LED André Apitzsch via B4 Relay
2024-04-02 16:22 ` Rob Herring
2024-04-01 21:23 ` [PATCH v2 2/3] leds: sy7802: Add support for Silergy SY7802 flash LED controller André Apitzsch via B4 Relay
2024-04-11 12:48 ` Lee Jones
2024-05-01 14:59 ` André Apitzsch
2024-05-02 9:10 ` Lee Jones [this message]
2024-05-02 19:19 ` André Apitzsch
2024-05-03 7:20 ` Lee Jones
2024-05-03 7:19 ` Lee Jones
2024-05-04 18:27 ` André Apitzsch
2024-05-07 8:40 ` Lee Jones
2024-05-02 20:13 ` Christophe JAILLET
2024-04-01 21:23 ` [PATCH v2 3/3] arm64: dts: qcom: msm8939-longcheer-l9100: Add rear flash André Apitzsch via B4 Relay
2024-04-01 21:45 ` [PATCH v2 0/3] Add sy7802 flash led driver Trilok Soni
2024-04-01 22:11 ` André Apitzsch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240502091017.GF5338@google.com \
--to=lee@kernel.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=git@apitzsch.eu \
--cc=gustavoars@kernel.org \
--cc=keescook@chromium.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=phone-devel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).