2021-03-05 17:36:34

by Lucas Tanure

[permalink] [raw]
Subject: [PATCH v2 06/15] ASoC: cs42l42: Remove power if the driver is being removed

Ensure the power supplies are turned off when removing the driver

Signed-off-by: Lucas Tanure <[email protected]>
---
Changes in v2:
- Use PM functions to shutdown the codec
- Disable IRQ before pm_suspend

sound/soc/codecs/cs42l42.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 811b7b1c9732e..78274537a22af 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -25,6 +25,7 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_device.h>
+#include <linux/pm_runtime.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -1840,10 +1841,9 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client,

static int cs42l42_i2c_remove(struct i2c_client *i2c_client)
{
- struct cs42l42_private *cs42l42 = i2c_get_clientdata(i2c_client);
-
- /* Hold down reset */
- gpiod_set_value_cansleep(cs42l42->reset_gpio, 0);
+ disable_irq(i2c_client->irq);
+ pm_runtime_suspend(&i2c_client->dev);
+ pm_runtime_disable(&i2c_client->dev);

return 0;
}
--
2.30.1


2021-03-05 18:54:41

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v2 06/15] ASoC: cs42l42: Remove power if the driver is being removed

On Fri, Mar 05, 2021 at 05:34:33PM +0000, Lucas Tanure wrote:

> - /* Hold down reset */
> - gpiod_set_value_cansleep(cs42l42->reset_gpio, 0);
> + disable_irq(i2c_client->irq);
> + pm_runtime_suspend(&i2c_client->dev);
> + pm_runtime_disable(&i2c_client->dev);

You should be unregistering the interrupt, not disabling it - this will
better support any shared IRQ usage that appears and is much, much more
idiomatic.


Attachments:
(No filename) (428.00 B)
signature.asc (499.00 B)
Download all attachments