All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Petr Cvek <petr.cvek@tul.cz>
Cc: robert.jarzmik@free.fr, philipp.zabel@gmail.com,
	daniel@zonque.org, haojian.zhuang@gmail.com,
	sameo@linux.intel.com, lee.jones@linaro.org, cooloney@gmail.com,
	rpurdie@rpsys.net, linux@arm.linux.org.uk, sre@kernel.org,
	dbaryshkov@gmail.com, dwmw2@infradead.org,
	linux-leds@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 19/21] leds: leds-pasic3: Add support for PASIC3 LED controller
Date: Wed, 19 Aug 2015 10:49:08 +0200	[thread overview]
Message-ID: <55D44304.1000503@samsung.com> (raw)
In-Reply-To: <55D3A832.90705@tul.cz>

On 08/18/2015 11:48 PM, Petr Cvek wrote:
> Dne 18.8.2015 v 12:27 Jacek Anaszewski napsal(a):
>> Hi Petr,
>>
>> On 08/18/2015 12:06 AM, Petr Cvek wrote:
>>> +/*
>>> + * AIC3 (or PASIC3) LED driver for HTC Magician/Alpine/.. (not Compaq ASIC3)
>>
>> s/AIC3/ASIC3/
>>
>> I am a bit confused. What's the relation between ASIC3 and PASIC3?
>
> Actually both drivers should be renamed to AIC3 (or AIC only, as there is version 2). "HTC_AIC3" is written on the chip and "pasic3" is confusing with compaq asic3 driver, which claims in Kconfig help to be compatible with HTC machines. Compaq ASIC3 has much more functionality and from brief look it seems it has 16 bit registers (HTC_AIC3 has only LEDs, RESET and DS1WM and has 8 bit registers).

I see, thanks for the explanation.

>>> +spinlock_t lock;
>>
>> Please move it to the struct pasic3_leds_data.
>
> OK
>
>>
>>> +
>>> +static void brightness_set(struct led_classdev *cdev,
>>> +    enum led_brightness value)
>>> +{
>>> +    struct platform_device *pdev = to_platform_device(cdev->dev->parent);
>>> +    struct pasic3_led *led = dev_get_platdata(cdev->dev);
>>> +    struct pasic3_leds_pdata *pdata = dev_get_platdata(&pdev->dev);
>>> +    unsigned long flags;
>>> +    u8 val;
>>> +
>>> +    spin_lock_irqsave(&lock, flags);
>>> +
>>> +    if (value == LED_OFF) {
>>> +        val = pasic3_read_register(pdata->mfd_dev, PASIC3_CH_CONTROL);
>>> +        pasic3_write_register(pdata->mfd_dev, PASIC3_CH_CONTROL,
>>> +            val & ~(led->bit_blink_en | led->bit_force_on));
>>> +
>>> +        val = pasic3_read_register(pdata->mfd_dev, PASIC3_MASK_A);
>>> +        pasic3_write_register(pdata->mfd_dev, PASIC3_MASK_A,
>>> +            val & ~led->bit_mask);
>>> +
>>> +        if (pdata->power_gpio) {
>>> +            pdata->power_gpio_users--;
>>
>> Now it is possible that power_gpio_users will have negative value.
>> You should check the value before decrementing it.
>
>> Now you are setting power_gpio_users to 1 each time brightness is set,
>> whereas it should be set to 1 only if it was 0.
>>
>> This could be changed to:
>>
>> if (pdata->power_gpio_users == 0)
>>      gpio_set_value(pdata->power_gpio, 1);
>>
>> pdata->power_gpio_users++;
>
>>
>> Shouldn't you check if also power_gpio state doesn't need to be altered
>> here?
>>
>
>
> Can the same brightness_set() function be called multiple times with same value (like LED_ON)?

Yes it can. LED core doesn't check if the value isn't already set.

> I think I will change it to a different code altogether, power_gpio is shared variable and power can be shut off when two of three leds are disabled (green LED does not use power_gpio). Something like:
>
> enabled_leds |= BIT(hw_num);
>
> or
>
> enabled_leds &= ~BIT(hw_num);

OK, we'll discuss that after you'll submit the next version.

>
>>> +        ret = gpio_request(pdata->power_gpio,
>>> +            "Red-Blue LED Power");
>>
>> Please use devm_gpio_request. Then you will not need pasic3_led_remove.
>>
>
> OK
>
>


-- 
Best Regards,
Jacek Anaszewski

WARNING: multiple messages have this Message-ID (diff)
From: j.anaszewski@samsung.com (Jacek Anaszewski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 19/21] leds: leds-pasic3: Add support for PASIC3 LED controller
Date: Wed, 19 Aug 2015 10:49:08 +0200	[thread overview]
Message-ID: <55D44304.1000503@samsung.com> (raw)
In-Reply-To: <55D3A832.90705@tul.cz>

On 08/18/2015 11:48 PM, Petr Cvek wrote:
> Dne 18.8.2015 v 12:27 Jacek Anaszewski napsal(a):
>> Hi Petr,
>>
>> On 08/18/2015 12:06 AM, Petr Cvek wrote:
>>> +/*
>>> + * AIC3 (or PASIC3) LED driver for HTC Magician/Alpine/.. (not Compaq ASIC3)
>>
>> s/AIC3/ASIC3/
>>
>> I am a bit confused. What's the relation between ASIC3 and PASIC3?
>
> Actually both drivers should be renamed to AIC3 (or AIC only, as there is version 2). "HTC_AIC3" is written on the chip and "pasic3" is confusing with compaq asic3 driver, which claims in Kconfig help to be compatible with HTC machines. Compaq ASIC3 has much more functionality and from brief look it seems it has 16 bit registers (HTC_AIC3 has only LEDs, RESET and DS1WM and has 8 bit registers).

I see, thanks for the explanation.

>>> +spinlock_t lock;
>>
>> Please move it to the struct pasic3_leds_data.
>
> OK
>
>>
>>> +
>>> +static void brightness_set(struct led_classdev *cdev,
>>> +    enum led_brightness value)
>>> +{
>>> +    struct platform_device *pdev = to_platform_device(cdev->dev->parent);
>>> +    struct pasic3_led *led = dev_get_platdata(cdev->dev);
>>> +    struct pasic3_leds_pdata *pdata = dev_get_platdata(&pdev->dev);
>>> +    unsigned long flags;
>>> +    u8 val;
>>> +
>>> +    spin_lock_irqsave(&lock, flags);
>>> +
>>> +    if (value == LED_OFF) {
>>> +        val = pasic3_read_register(pdata->mfd_dev, PASIC3_CH_CONTROL);
>>> +        pasic3_write_register(pdata->mfd_dev, PASIC3_CH_CONTROL,
>>> +            val & ~(led->bit_blink_en | led->bit_force_on));
>>> +
>>> +        val = pasic3_read_register(pdata->mfd_dev, PASIC3_MASK_A);
>>> +        pasic3_write_register(pdata->mfd_dev, PASIC3_MASK_A,
>>> +            val & ~led->bit_mask);
>>> +
>>> +        if (pdata->power_gpio) {
>>> +            pdata->power_gpio_users--;
>>
>> Now it is possible that power_gpio_users will have negative value.
>> You should check the value before decrementing it.
>
>> Now you are setting power_gpio_users to 1 each time brightness is set,
>> whereas it should be set to 1 only if it was 0.
>>
>> This could be changed to:
>>
>> if (pdata->power_gpio_users == 0)
>>      gpio_set_value(pdata->power_gpio, 1);
>>
>> pdata->power_gpio_users++;
>
>>
>> Shouldn't you check if also power_gpio state doesn't need to be altered
>> here?
>>
>
>
> Can the same brightness_set() function be called multiple times with same value (like LED_ON)?

Yes it can. LED core doesn't check if the value isn't already set.

> I think I will change it to a different code altogether, power_gpio is shared variable and power can be shut off when two of three leds are disabled (green LED does not use power_gpio). Something like:
>
> enabled_leds |= BIT(hw_num);
>
> or
>
> enabled_leds &= ~BIT(hw_num);

OK, we'll discuss that after you'll submit the next version.

>
>>> +        ret = gpio_request(pdata->power_gpio,
>>> +            "Red-Blue LED Power");
>>
>> Please use devm_gpio_request. Then you will not need pasic3_led_remove.
>>
>
> OK
>
>


-- 
Best Regards,
Jacek Anaszewski

  parent reply	other threads:[~2015-08-19  8:49 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1439843482.git.petr.cvek@tul.cz>
2015-08-17 21:56 ` [PATCH v2 01/21] ARM: pxa: magician: Fix Kconfig for magician to always include htc-egpio Petr Cvek
2015-08-17 21:56   ` Petr Cvek
2015-08-18 18:31   ` Robert Jarzmik
2015-08-18 18:31     ` Robert Jarzmik
2015-08-18 20:02     ` Petr Cvek
2015-08-18 20:02       ` Petr Cvek
2015-08-19  7:29       ` Philipp Zabel
2015-08-19  7:29         ` Philipp Zabel
2015-08-24  3:39         ` Petr Cvek
2015-08-24  3:39           ` Petr Cvek
2015-08-17 21:56 ` [PATCH v2 02/21] ARM: pxa: magician: Fix indentation and whitespaces Petr Cvek
2015-08-17 21:56   ` Petr Cvek
2015-08-18 18:32   ` Robert Jarzmik
2015-08-18 18:32     ` Robert Jarzmik
2015-08-19  7:42   ` Philipp Zabel
2015-08-19  7:42     ` Philipp Zabel
2015-08-17 21:57 ` [PATCH v2 03/21] ARM: pxa: magician: Fix comments, debug functions and print strings Petr Cvek
2015-08-17 21:57   ` Petr Cvek
2015-08-18 18:39   ` Robert Jarzmik
2015-08-18 18:39     ` Robert Jarzmik
2015-08-18 23:09     ` Petr Cvek
2015-08-18 23:09       ` Petr Cvek
2015-08-19  7:57   ` Philipp Zabel
2015-08-19  7:57     ` Philipp Zabel
2015-08-17 21:58 ` [PATCH v2 04/21] ARM: pxa: magician: Add, fix and init (new) GPIOs Petr Cvek
2015-08-17 21:58   ` Petr Cvek
2015-08-18 19:01   ` Robert Jarzmik
2015-08-18 19:01     ` Robert Jarzmik
2015-08-18 22:46     ` Petr Cvek
2015-08-18 22:46       ` Petr Cvek
2015-08-17 21:58 ` [PATCH v2 05/21] ARM: pxa: magician: Add support for ADS7846 touchscreen Petr Cvek
2015-08-17 21:58   ` Petr Cvek
2015-08-19 18:41   ` Robert Jarzmik
2015-08-19 18:41     ` Robert Jarzmik
2015-08-17 21:59 ` [PATCH v2 06/21] ARM: pxa: magician: Add normal and power I2C definition Petr Cvek
2015-08-17 21:59   ` Petr Cvek
2015-08-19  8:02   ` Philipp Zabel
2015-08-19  8:02     ` Philipp Zabel
2015-08-19 18:41   ` Robert Jarzmik
2015-08-19 18:41     ` Robert Jarzmik
2015-08-17 21:59 ` [PATCH v2 07/21] ARM: pxa: magician: Fix IrDA pdata and redundant GPIO request Petr Cvek
2015-08-17 21:59   ` Petr Cvek
2015-08-19 18:41   ` Robert Jarzmik
2015-08-19 18:41     ` Robert Jarzmik
2015-08-17 22:00 ` [PATCH v2 08/21] ARM: pxa: magician: Add StrataFlash Vpp GPIO and alternative driver Petr Cvek
2015-08-17 22:00   ` Petr Cvek
2015-08-17 22:01 ` [PATCH v2 09/21] ARM: pxa: magician: Add OV9640 camera support Petr Cvek
2015-08-17 22:01   ` Petr Cvek
2015-08-20 19:48   ` Robert Jarzmik
2015-08-20 19:48     ` Robert Jarzmik
2015-08-20 20:26     ` Arnd Bergmann
2015-08-20 20:26       ` Arnd Bergmann
2015-08-20 22:39       ` Petr Cvek
2015-08-20 22:39         ` Petr Cvek
2015-08-21 13:45         ` Arnd Bergmann
2015-08-21 13:45           ` Arnd Bergmann
2015-08-21 17:36           ` Robert Jarzmik
2015-08-21 22:09             ` Petr Cvek
2015-08-21 22:09               ` Petr Cvek
2015-08-22 12:41               ` Robert Jarzmik
2015-08-22 12:41                 ` Robert Jarzmik
2015-08-24  6:53           ` Lee Jones
2015-08-24  6:53             ` Lee Jones
2015-08-17 22:01 ` [PATCH v2 10/21] ARM: pxa: magician: Add UDA1380 sound support Petr Cvek
2015-08-17 22:01   ` Petr Cvek
2015-08-20 19:51   ` Robert Jarzmik
2015-08-20 19:51     ` Robert Jarzmik
2015-08-20 23:01     ` Petr Cvek
2015-08-20 23:01       ` Petr Cvek
2015-08-28  8:48       ` Robert Jarzmik
2015-08-28  8:48         ` Robert Jarzmik
2015-08-17 22:01 ` [PATCH v2 11/21] ARM: pxa: magician: Add MAX1586 Vcore regulator support Petr Cvek
2015-08-17 22:01   ` Petr Cvek
2015-08-20 19:32   ` Robert Jarzmik
2015-08-20 19:32     ` Robert Jarzmik
2015-08-20 22:33     ` Petr Cvek
2015-08-20 22:33       ` Petr Cvek
2015-08-28  8:49       ` Robert Jarzmik
2015-08-28  8:49         ` Robert Jarzmik
2015-08-17 22:02 ` [PATCH v2 12/21] ARM: pxa: magician: Add PXA27x UDC support Petr Cvek
2015-08-17 22:02   ` Petr Cvek
2015-08-20 17:23   ` Robert Jarzmik
2015-08-20 17:23     ` Robert Jarzmik
2015-08-20 22:21     ` Petr Cvek
2015-08-20 22:21       ` Petr Cvek
2015-08-28  9:58       ` Robert Jarzmik
2015-08-28  9:58         ` Robert Jarzmik
2015-08-17 22:03 ` [PATCH v2 13/21] ARM: pxa: magician: Fix charging source and add NiCd backup charging Petr Cvek
2015-08-17 22:03   ` Petr Cvek
2015-08-17 22:18   ` Petr Cvek
2015-08-17 22:18     ` Petr Cvek
2015-08-17 22:03 ` [PATCH v2 14/21] ARM: pxa: magician: Fix PXA USB OHCI port enable flags Petr Cvek
2015-08-17 22:03   ` Petr Cvek
2015-08-17 22:03 ` [PATCH v2 15/21] ARM: pxa: magician: Fix PWM backlight regulator Petr Cvek
2015-08-17 22:03   ` Petr Cvek
2015-08-20 19:58   ` Robert Jarzmik
2015-08-20 19:58     ` Robert Jarzmik
2015-08-17 22:04 ` [PATCH v2 16/21] ARM: pxa: magician: Add support for alternative LCD backlight Petr Cvek
2015-08-17 22:04   ` Petr Cvek
2015-08-20 20:01   ` Robert Jarzmik
2015-08-20 20:01     ` Robert Jarzmik
2015-08-23 20:55     ` Petr Cvek
2015-08-23 20:55       ` Petr Cvek
2015-08-24  8:25       ` Robert Jarzmik
2015-08-24  8:25         ` Robert Jarzmik
2015-08-17 22:04 ` [PATCH v2 17/21] ARM: pxa: magician: Remove (temporarily) pasic3 LED support Petr Cvek
2015-08-17 22:04   ` Petr Cvek
2015-08-22 16:25   ` Robert Jarzmik
2015-08-22 16:25     ` Robert Jarzmik
2015-08-17 22:05 ` [PATCH v2 18/21] mfd: htc-pasic3: Prepare driver for leds-pasic3 Petr Cvek
2015-08-17 22:05   ` Petr Cvek
2015-08-18  6:52   ` Lee Jones
2015-08-18  6:52     ` Lee Jones
2015-08-18 21:01     ` Petr Cvek
2015-08-18 21:01       ` Petr Cvek
2015-08-19  6:58       ` Lee Jones
2015-08-19  6:58         ` Lee Jones
2015-08-17 22:06 ` [PATCH v2 19/21] leds: leds-pasic3: Add support for PASIC3 LED controller Petr Cvek
2015-08-17 22:06   ` Petr Cvek
2015-08-17 22:14   ` Petr Cvek
2015-08-17 22:14     ` Petr Cvek
2015-08-18 10:27   ` Jacek Anaszewski
2015-08-18 10:27     ` Jacek Anaszewski
2015-08-18 21:48     ` Petr Cvek
2015-08-18 21:48       ` Petr Cvek
2015-08-19  8:09       ` Philipp Zabel
2015-08-19  8:09         ` Philipp Zabel
2015-08-19  8:49       ` Jacek Anaszewski [this message]
2015-08-19  8:49         ` Jacek Anaszewski
2015-08-17 22:06 ` [PATCH v2 20/21] ARM: pxa: magician: Re-add pdata for new leds-pasic3 driver Petr Cvek
2015-08-17 22:06   ` Petr Cvek
2015-08-17 22:07 ` [PATCH v2 21/21] ARM: pxa: magician: Move platform_add_devices() to the end of magician_init() Petr Cvek
2015-08-17 22:07   ` Petr Cvek
2015-08-22 16:27   ` Robert Jarzmik
2015-08-22 16:27     ` Robert Jarzmik

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=55D44304.1000503@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=daniel@zonque.org \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=petr.cvek@tul.cz \
    --cc=philipp.zabel@gmail.com \
    --cc=robert.jarzmik@free.fr \
    --cc=rpurdie@rpsys.net \
    --cc=sameo@linux.intel.com \
    --cc=sre@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.