From: Hans de Goede <hdegoede@redhat.com>
To: Dan Scally <dan.scally@ideasonboard.com>,
linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org
Cc: pavel@ucw.cz, lee@kernel.org, markgross@kernel.org,
sboyd@kernel.org, hpa@redhat.com
Subject: Re: [PATCH 5/8] leds: tps68470: Refactor tps68470_brightness_get()
Date: Thu, 23 Mar 2023 10:52:06 +0100 [thread overview]
Message-ID: <ac0d584d-0d80-981d-e2eb-b68f03e333a9@redhat.com> (raw)
In-Reply-To: <14b8e3e2-1a29-04c7-18a1-0eda82ec97fa@ideasonboard.com>
Hi,
On 3/23/23 08:43, Dan Scally wrote:
> Morning Hans
>
> On 22/03/2023 17:22, Hans de Goede wrote:
>> Hi,
>>
>> On 3/22/23 17:09, Daniel Scally wrote:
>>> We want to extend tps68470_brightness_get() to be usable with the
>>> other LEDs supplied by the IC; refactor it to make that easier.
>>>
>>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
>>> ---
>>> drivers/leds/leds-tps68470.c | 17 +++++++++--------
>>> 1 file changed, 9 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/leds/leds-tps68470.c b/drivers/leds/leds-tps68470.c
>>> index d2060fe4259d..44df175d25de 100644
>>> --- a/drivers/leds/leds-tps68470.c
>>> +++ b/drivers/leds/leds-tps68470.c
>>> @@ -77,23 +77,24 @@ static enum led_brightness tps68470_brightness_get(struct led_classdev *led_cdev
>>> int ret = 0;
>>> int value = 0;
>>> - ret = regmap_read(regmap, TPS68470_REG_ILEDCTL, &value);
>>> - if (ret)
>>> - return dev_err_probe(led_cdev->dev, -EINVAL, "failed on reading register\n");
>>> -
>>> switch (led->led_id) {
>>> case TPS68470_ILED_A:
>>> - value = value & TPS68470_ILEDCTL_ENA;
>>> - break;
>>> case TPS68470_ILED_B:
>>> - value = value & TPS68470_ILEDCTL_ENB;
>>> + ret = regmap_read(regmap, TPS68470_REG_ILEDCTL, &value);
>>> + if (ret)
>>> + return dev_err_probe(led_cdev->dev, ret,
>>> + "failed to read LED status\n");
>> I realize this is a pre-existing problem, but I don't think we should
>> be using dev_err_probe() in functions which are used outside the probe()
>> path?
>
>
> I had thought that this was being encouraged because of the standard formatting, but actually now I re-read the comment's function it's just "OK to use in .probe() even if it can't return -EPROBE_DEFER". My bad; I'll fix it.
>
>>
>> So maybe fix this up while at it and make this:
>>
>> if (ret) {
>> dev_err(led_cdev->dev, ""failed to read LED status: %d\n", ret);
>> return ret;
>> }
>>
>>> +
>>> + value &= led->led_id == TPS68470_ILED_A ? TPS68470_ILEDCTL_ENA :
>>> + TPS68470_ILEDCTL_ENB;
>>> break;
>>> + default:
>>> + return dev_err_probe(led_cdev->dev, -EINVAL, "invalid LED ID\n");
>> idem.
>
>
> idem? Sorry, I'm not following here.
My bad I though this was something which most people understand / know:
https://en.wikipedia.org/wiki/Idem
So what I was trying to say is:
"the same (don't use dev_err_probe()) applies here".
Regards,
Hans
>
>>
>> With those fixed:
>>
>> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
>>
>> Regards,
>>
>> Hans
>>
>>
>>
>>> }
>>> return value ? LED_ON : LED_OFF;
>>> }
>>> -
>>> static int tps68470_ledb_current_init(struct platform_device *pdev,
>>> struct tps68470_device *tps68470)
>>> {
>
next prev parent reply other threads:[~2023-03-23 9:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 16:09 [PATCH 0/8] Add WLED support to TPS68470 LED driver Daniel Scally
2023-03-22 16:09 ` [PATCH 1/8] platform/x86: int3472: Add platform data for LEDs Daniel Scally
2023-03-22 17:14 ` Hans de Goede
2023-03-22 16:09 ` [PATCH 2/8] platform/x86: int3472: Init LED registers using platform data Daniel Scally
2023-03-22 17:16 ` Hans de Goede
2023-03-22 16:09 ` [PATCH 3/8] platform/x86: int3472: Add TPS68470 LED Board Data Daniel Scally
2023-03-22 17:17 ` Hans de Goede
2023-03-22 16:09 ` [PATCH 4/8] platform/x86: int3472: Add tps68470-led as clock consumer Daniel Scally
2023-03-22 17:19 ` Hans de Goede
2023-03-22 16:09 ` [PATCH 5/8] leds: tps68470: Refactor tps68470_brightness_get() Daniel Scally
2023-03-22 17:22 ` Hans de Goede
2023-03-23 7:43 ` Dan Scally
2023-03-23 9:52 ` Hans de Goede [this message]
2023-03-23 9:53 ` Dan Scally
2023-03-22 16:09 ` [PATCH 6/8] leds: tps68470: Support the WLED driver Daniel Scally
2023-03-22 17:24 ` Hans de Goede
2023-03-23 11:22 ` Pavel Machek
2023-03-23 16:25 ` Dan Scally
2023-03-27 13:23 ` Hans de Goede
2023-03-22 16:09 ` [PATCH 7/8] platform/x86: int3472: Support LED lookups in board data Daniel Scally
2023-03-22 17:25 ` Hans de Goede
2023-03-22 16:09 ` [PATCH 8/8] platform/x86: int3472: Define LED lookup data for MS Surface Go Daniel Scally
2023-03-22 17:34 ` Hans de Goede
2023-03-23 10:31 ` Dan Scally
2023-03-23 11:15 ` Hans de Goede
2023-03-22 17:40 ` [PATCH 0/8] Add WLED support to TPS68470 LED driver Hans de Goede
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=ac0d584d-0d80-981d-e2eb-b68f03e333a9@redhat.com \
--to=hdegoede@redhat.com \
--cc=dan.scally@ideasonboard.com \
--cc=hpa@redhat.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=pavel@ucw.cz \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sboyd@kernel.org \
/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