Linux-LEDs Archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Amitesh Singh <singh.amitesh@gmail.com>
Cc: pavel@ucw.cz, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] leds/pca963x: implement power management
Date: Fri, 2 Feb 2024 12:36:25 +0000	[thread overview]
Message-ID: <20240202123625.GB1379817@google.com> (raw)
In-Reply-To: <20240129111505.196068-1-singh.amitesh@gmail.com>

Please use the following and observe the correct subject format:

`git log --oneline --no-merges -- drivers/leds`

On Mon, 29 Jan 2024, Amitesh Singh wrote:

> This implements power management for pca9633

44 chars is an odd place to '\n'.

This will give you a good idea of what is generally accepted:

`git log`

> which enables device sleep and resume on system-wide
> sleep/hibernation
> 
> Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
> ---
>  drivers/leds/leds-pca963x.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> index 47223c850e4b..227f24ba2ca2 100644
> --- a/drivers/leds/leds-pca963x.c
> +++ b/drivers/leds/leds-pca963x.c
> @@ -39,6 +39,7 @@
>  #define PCA963X_LED_PWM		0x2	/* Controlled through PWM */
>  #define PCA963X_LED_GRP_PWM	0x3	/* Controlled through PWM/GRPPWM */
>  
> +#define PCA963X_MODE1_SLEEP     0x04    /* Normal mode or Low Power mode, oscillator off */

Tabs first, then line up with spaces.

>  #define PCA963X_MODE2_OUTDRV	0x04	/* Open-drain or totem pole */
>  #define PCA963X_MODE2_INVRT	0x10	/* Normal or inverted direction */
>  #define PCA963X_MODE2_DMBLNK	0x20	/* Enable blinking */
> @@ -380,6 +381,34 @@ static int pca963x_register_leds(struct i2c_client *client,
>  	return ret;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int pca963x_suspend(struct device *dev)
> +{
> +	struct pca963x *chip = dev_get_drvdata(dev);
> +	u8 reg;
> +
> +	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
> +	reg = reg | BIT(PCA963X_MODE1_SLEEP);
> +	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
> +
> +	return 0;
> +}
> +
> +static int pca963x_resume(struct device *dev)
> +{
> +	struct pca963x *chip = dev_get_drvdata(dev);
> +	u8 reg;
> +
> +	reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1);
> +	reg = reg & ~BIT(PCA963X_MODE1_SLEEP);
> +	i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg);
> +
> +	return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume);

Can you use DEFINE_SIMPLE_DEV_PM_OPS() and remove the #ifdefs?

>  static const struct of_device_id of_pca963x_match[] = {
>  	{ .compatible = "nxp,pca9632", },
>  	{ .compatible = "nxp,pca9633", },
> @@ -430,6 +459,7 @@ static struct i2c_driver pca963x_driver = {
>  	.driver = {
>  		.name	= "leds-pca963x",
>  		.of_match_table = of_pca963x_match,
> +		.pm = &pca963x_pm

If so, you'll also need pm_sleep_ptr() here.

See these commits for examples:

02313a90095fb ("mfd: tc3589x: Remove #ifdef guards for PM related functions")
f7f292fe819b6 ("mfd: stmpe: Remove #ifdef guards for PM related functions")
4d8a6ae23af64 ("mfd: stmfx: Remove #ifdef guards for PM related functions")
69bbab91835ac ("mfd: sprd-sc27xx: Remove #ifdef guards for PM related functions")
4060c6e50a77a ("mfd: motorola-cpcap: Remove #ifdef guards for PM related functions")
ef72ed420ea16 ("mfd: max77686: Remove #ifdef guards for PM related functions")
8a8d0485f5791 ("mfd: max14577: Remove #ifdef guards for PM related functions")
50d3ac7d3ce47 ("mfd: arizona: Remove #ifdef guards for PM related functions")
daf7ea817fda9 ("mfd: t7l66xb: Remove #ifdef guards for PM related functions")
9b990dc9f09fc ("mfd: max77620: Remove #ifdef guards for PM related functions")
9dd3baecebc3d ("mfd: wm8994: Remove #ifdef guards for PM related functions")
d115e88c29754 ("mfd: tps6586x: Remove #ifdef guards for PM related functions")
2d81212cb0c81 ("mfd: tc6387xb: Remove #ifdef guards for PM related functions")
3833239b5ba22 ("mfd: sm501: Remove #ifdef guards for PM related functions")
270a7c3eba574 ("mfd: sec: Remove #ifdef guards for PM related functions")
ff84723e5291c ("mfd: mcp-sa11x0: Remove #ifdef guards for PM related functions")
fdefee3073bc6 ("mfd: 88pm860x: Remove #ifdef guards for PM related functions")
03bf96cf8ecbd ("mfd: ucb1x00: Remove #ifdef guards for PM related functions")
e4b9a17c99d0b ("mfd: stpmic1: Remove #ifdef guards for PM related functions")
2662b90fd58b8 ("mfd: rc5t583-irq: Remove #ifdef guards for PM related functions")
245cb473e5388 ("mfd: pcf50633: Remove #ifdef guards for PM related functions")
e1243e0d72185 ("mfd: mt6397-irq: Remove #ifdef guards for PM related functions")
52c9d7193ba43 ("mfd: max8925-i2c: Remove #ifdef guards for PM related functions")
5745a90a930c8 ("mfd: adp5520: Remove #ifdef guards for PM related functions")
dce97f81fea6f ("mfd: aat2870: Remove #ifdef guards for PM related functions")
19755a0acb883 ("mfd: 88pm80x: Remove #ifdef guards for PM related functions")

>  	},
>  	.probe = pca963x_probe,
>  	.id_table = pca963x_id,
> -- 
> 2.43.0
> 

-- 
Lee Jones [李琼斯]

      reply	other threads:[~2024-02-02 12:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29 11:15 [PATCH v2] leds/pca963x: implement power management Amitesh Singh
2024-02-02 12:36 ` Lee Jones [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=20240202123625.GB1379817@google.com \
    --to=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=singh.amitesh@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).