From: Matt Ranostay <mranostay@gmail.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: linux-leds@vger.kernel.org,
Matt Ranostay <matt@ranostay.consulting>,
Tony Lindgren <tony@atomide.com>,
Peter Meerwald <p.meerwald@bct-electronic.com>,
Ricardo Ribalda <ricardo.ribalda@gmail.com>
Subject: Re: [PATCH v2] leds: pca963x: enable low-power state
Date: Wed, 19 Oct 2016 23:15:32 -0700 [thread overview]
Message-ID: <90AFFEE8-1022-4A0E-B88C-836DB225C468@gmail.com> (raw)
In-Reply-To: <b0662ce1-d6ba-19d3-2f8b-49b4dacc3d9b@samsung.com>
> On Oct 19, 2016, at 23:08, Jacek Anaszewski <j.anaszewski@samsung.com> wrote:
>
> Hi Matt,
>
> Thanks for the update.
> Let me cc also authors of the driver.
>
>> On 10/20/2016 02:03 AM, Matt Ranostay wrote:
>> Allow chip to enter low power state when no LEDs are being lit or in
>> blink mode.
>>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Jacek Anaszewski <j.anaszewski@samsung.com>
>> Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
>> ---
>> Changes from v1:
>> * remove runtime pm
>> * count leds that are off, if all then enter low-power state
>>
>> drivers/leds/leds-pca963x.c | 24 +++++++++++++++++++++---
>> 1 file changed, 21 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
>> index 407eba11e187..797dffc42c59 100644
>> --- a/drivers/leds/leds-pca963x.c
>> +++ b/drivers/leds/leds-pca963x.c
>> @@ -179,14 +179,32 @@ static void pca963x_blink(struct pca963x_led *pca963x)
>> mutex_unlock(&pca963x->chip->mutex);
>> }
>>
>> +static int pca963x_power_state(struct pca963x_led *pca963x)
>> +{
>> + int i, leds_on = 0;
>> +
>> + for (i = 0; i < pca963x->chip->chipdef->n_leds; i++) {
>> + if (pca963x->chip->leds[i].led_cdev.brightness > 0)
>> + leds_on++;
>> + }
>
> You could avoid executing this loop on every brightness setting,
> if you added a counter and incremented/decremented it when turning
> a LED on/off respectively. Then you could write PCA963X_MODE1 on
> counter transitions from 0 to 1 and from 1 to 0.
Thought of that but seems so low bandwidth it wouldn't matter. But have no issue adding a counter if required of course in v3
>
>> +
>> + return i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE1,
>> + leds_on ? 0 : BIT(4));
>> +}
>> +
>> static int pca963x_led_set(struct led_classdev *led_cdev,
>> enum led_brightness value)
>> {
>> struct pca963x_led *pca963x;
>> + int ret;
>>
>> pca963x = container_of(led_cdev, struct pca963x_led, led_cdev);
>>
>> - return pca963x_brightness(pca963x, value);
>> + ret = pca963x_brightness(pca963x, value);
>> + if (ret < 0)
>> + return ret;
>> +
>> + return pca963x_power_state(pca963x);
>> }
>>
>> static int pca963x_blink_set(struct led_classdev *led_cdev,
>> @@ -391,8 +409,8 @@ static int pca963x_probe(struct i2c_client *client,
>> goto exit;
>> }
>>
>> - /* Disable LED all-call address and set normal mode */
>> - i2c_smbus_write_byte_data(client, PCA963X_MODE1, 0x00);
>> + /* Disable LED all-call address, and power down initially */
>> + i2c_smbus_write_byte_data(client, PCA963X_MODE1, BIT(4));
>>
>> if (pdata) {
>> /* Configure output: open-drain or totem pole (push-pull) */
>>
>
>
> --
> Best regards,
> Jacek Anaszewski
prev parent reply other threads:[~2016-10-20 6:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20161020000405eucas1p1db947d4d5abdb1d0cd8fe65b1bfb69af@eucas1p1.samsung.com>
2016-10-20 0:03 ` [PATCH v2] leds: pca963x: enable low-power state Matt Ranostay
2016-10-20 6:08 ` Jacek Anaszewski
2016-10-20 6:15 ` Matt Ranostay [this message]
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=90AFFEE8-1022-4A0E-B88C-836DB225C468@gmail.com \
--to=mranostay@gmail.com \
--cc=j.anaszewski@samsung.com \
--cc=linux-leds@vger.kernel.org \
--cc=matt@ranostay.consulting \
--cc=p.meerwald@bct-electronic.com \
--cc=ricardo.ribalda@gmail.com \
--cc=tony@atomide.com \
/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