From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Dan Murphy <dmurphy@ti.com>, pavel@ucw.cz
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 07/15] leds: lp50xx: Add the LP50XX family of the RGB LED driver
Date: Sat, 28 Sep 2019 12:29:07 +0200 [thread overview]
Message-ID: <4186e454-48fd-1578-cd26-083b54c707ab@gmail.com> (raw)
In-Reply-To: <d4126720-25ea-7c15-2424-b7f16b25c3b4@ti.com>
Dan,
On 9/26/19 1:59 PM, Dan Murphy wrote:
> Jacek
>
> On 9/25/19 4:27 PM, Jacek Anaszewski wrote:
>> Dan,
>>
>> On 9/25/19 7:46 PM, Dan Murphy wrote:
>
> <big_snip>
>
>>> +
>>> +static int lp50xx_brightness_set(struct led_classdev *cdev,
>>> + enum led_brightness brightness)
>>> +{
>>> + struct lp50xx_led *led = container_of(cdev, struct lp50xx_led,
>>> led_dev);
>>> + const struct lp50xx_chip_info *led_chip = led->priv->chip_info;
>>> + struct led_mc_color_entry *color_data;
>>> + u8 led_offset, reg_val, reg_color_offset;
>>> + int ret = 0;
>>> +
>>> + mutex_lock(&led->priv->lock);
>>> +
>>> + if (led->ctrl_bank_enabled)
>>> + reg_val = led_chip->bank_brt_reg;
>>> + else
>>> + reg_val = led_chip->led_brightness0_reg +
>>> + led->led_number;
>>> +
>>> + ret = regmap_write(led->priv->regmap, reg_val, brightness);
>>> + if (ret) {
>>> + dev_err(&led->priv->client->dev,
>>> + "Cannot write brightness value %d\n", ret);
>>> + goto out;
>>> + }
>>> +
>>> + list_for_each_entry(color_data, &led->mc_cdev.color_list, list) {
>>> + if (color_data->led_color_id == LED_COLOR_ID_RED)
>>> + reg_color_offset = 0;
>>> + else if (color_data->led_color_id == LED_COLOR_ID_GREEN)
>>> + reg_color_offset = 1;
>>> + else if (color_data->led_color_id == LED_COLOR_ID_BLUE)
>>> + reg_color_offset = 2;
>>> + else
>>> + continue;
>> This else case is quite erroneous. Sheer continue is just ignoring
>> serious problem. I'd log the problem and return -EINVAL.
> Ack.
>>
>> Also, you could have a macro for mapping color_id to offset.
> If the code needed to do this more then once I could justify a macro.
> But this is the only instance of this check.
OK, at first glance I thought we could have a formula for that,
but this is not the case.
--
Best regards,
Jacek Anaszewski
next prev parent reply other threads:[~2019-09-28 10:29 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 17:46 [PATCH v9 00/15] Multicolor Framework Dan Murphy
2019-09-25 17:46 ` [PATCH v9 01/15] leds: multicolor: Add sysfs interface definition Dan Murphy
2019-09-25 20:58 ` Jacek Anaszewski
2019-09-26 11:10 ` Pavel Machek
2019-09-26 12:08 ` Dan Murphy
2019-09-25 17:46 ` [PATCH v9 02/15] dt: bindings: Add multicolor class dt bindings documention Dan Murphy
2019-09-25 17:46 ` [PATCH v9 03/15] dt-bindings: leds: Add multicolor ID to the color ID list Dan Murphy
2019-09-25 17:46 ` [PATCH v9 04/15] " Dan Murphy
2019-09-25 17:46 ` [PATCH v9 05/15] leds: multicolor: Introduce a multicolor class definition Dan Murphy
2019-09-25 21:12 ` Jacek Anaszewski
2019-09-26 11:52 ` Dan Murphy
2019-09-28 10:09 ` Jacek Anaszewski
2019-09-28 18:31 ` Jacek Anaszewski
2019-09-25 17:46 ` [PATCH v9 06/15] dt: bindings: lp50xx: Introduce the lp50xx family of RGB drivers Dan Murphy
2019-09-25 17:46 ` [PATCH v9 07/15] leds: lp50xx: Add the LP50XX family of the RGB LED driver Dan Murphy
2019-09-25 21:27 ` Jacek Anaszewski
2019-09-26 11:59 ` Dan Murphy
2019-09-28 10:29 ` Jacek Anaszewski [this message]
2019-09-25 17:46 ` [PATCH v9 08/15] dt: bindings: lp55xx: Be consistent in the document with LED Dan Murphy
2019-09-25 21:31 ` Jacek Anaszewski
2019-09-26 12:00 ` Dan Murphy
2019-09-25 17:46 ` [PATCH v9 09/15] dt: bindings: lp55xx: Update binding for Multicolor Framework Dan Murphy
2019-09-25 21:34 ` Jacek Anaszewski
2019-09-26 12:00 ` Dan Murphy
2019-09-25 17:46 ` [PATCH v9 10/15] ARM: dts: n900: Add reg property to the LP5523 channel node Dan Murphy
2019-09-25 17:46 ` [PATCH v9 11/15] ARM: dts: imx6dl-yapp4: Add reg property to the lp5562 " Dan Murphy
2019-09-25 18:00 ` Fabio Estevam
2019-09-25 18:16 ` Dan Murphy
2019-09-25 17:46 ` [PATCH v9 12/15] ARM: dts: ste-href: Add reg property to the LP5521 channel nodes Dan Murphy
2019-10-04 21:30 ` Linus Walleij
2019-09-25 17:46 ` [PATCH v9 13/15] leds: lp55xx: Update the lp55xx to use the multi color framework Dan Murphy
2019-09-25 22:00 ` Jacek Anaszewski
2019-09-26 12:02 ` Dan Murphy
2019-09-29 13:01 ` Jacek Anaszewski
2019-09-30 16:31 ` Dan Murphy
2019-09-30 20:34 ` Dan Murphy
2019-09-25 17:46 ` [PATCH v9 14/15] leds: lp55xx: Fix checkpatch file permissions issues Dan Murphy
2019-09-25 17:46 ` [PATCH v9 15/15] leds: lp5523: Fix checkpatch issues in the code Dan Murphy
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=4186e454-48fd-1578-cd26-083b54c707ab@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=dmurphy@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/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
all inboxes | Powered by JetHome®