lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YLDaEnjGmCHrUMiz@gerhold.net>
Date:   Fri, 28 May 2021 13:54:58 +0200
From:   Stephan Gerhold <stephan@...hold.net>
To:     Vincent Knecht <vincent.knecht@...loo.org>
Cc:     Mark Brown <broonie@...nel.org>, phone-devel@...r.kernel.org,
        ~postmarketos/upstreaming@...ts.sr.ht,
        Liam Girdwood <lgirdwood@...il.com>,
        Rob Herring <robh+dt@...nel.org>,
        Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 4/4] ASoC: codecs: tfa989x: Add support for optional
 vddd-supply

On Fri, May 28, 2021 at 12:51:01PM +0200, Vincent Knecht wrote:
> Allow specifying Vddd regulator/supply to be enabled on I2C probing.
> 
> Signed-off-by: Vincent Knecht <vincent.knecht@...loo.org>

Reviewed-by: Stephan Gerhold <stephan@...hold.net>

> ---
>  sound/soc/codecs/tfa989x.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/sound/soc/codecs/tfa989x.c b/sound/soc/codecs/tfa989x.c
> index 6d94865c534b..643b45188b6f 100644
> --- a/sound/soc/codecs/tfa989x.c
> +++ b/sound/soc/codecs/tfa989x.c
> @@ -10,6 +10,7 @@
>  #include <linux/i2c.h>
>  #include <linux/module.h>
>  #include <linux/regmap.h>
> +#include <linux/regulator/consumer.h>
>  #include <sound/soc.h>
>  
>  #define TFA989X_STATUSREG		0x00
> @@ -51,6 +52,10 @@ struct tfa989x_rev {
>  	int (*init)(struct regmap *regmap);
>  };
>  
> +struct tfa989x {
> +	struct regulator *vddd_supply;
> +};
> +
>  static bool tfa989x_writeable_reg(struct device *dev, unsigned int reg)
>  {
>  	return reg > TFA989X_REVISIONNUMBER;
> @@ -242,10 +247,18 @@ static int tfa989x_dsp_bypass(struct regmap *regmap)
>  				 BIT(TFA989X_SYS_CTRL_AMPC));
>  }
>  
> +static void tfa989x_regulator_disable(void *data)
> +{
> +	struct tfa989x *tfa989x = data;
> +
> +	regulator_disable(tfa989x->vddd_supply);
> +}
> +
>  static int tfa989x_i2c_probe(struct i2c_client *i2c)
>  {
>  	struct device *dev = &i2c->dev;
>  	const struct tfa989x_rev *rev;
> +	struct tfa989x *tfa989x;
>  	struct regmap *regmap;
>  	unsigned int val;
>  	int ret;
> @@ -256,10 +269,31 @@ static int tfa989x_i2c_probe(struct i2c_client *i2c)
>  		return -ENODEV;
>  	}
>  
> +	tfa989x = devm_kzalloc(dev, sizeof(*tfa989x), GFP_KERNEL);
> +	if (!tfa989x)
> +		return -ENOMEM;
> +
> +	i2c_set_clientdata(i2c, tfa989x);
> +
> +	tfa989x->vddd_supply = devm_regulator_get(dev, "vddd");
> +	if (IS_ERR(tfa989x->vddd_supply))
> +		return dev_err_probe(dev, PTR_ERR(tfa989x->vddd_supply),
> +				     "Failed to get vddd regulator\n");
> +
>  	regmap = devm_regmap_init_i2c(i2c, &tfa989x_regmap);
>  	if (IS_ERR(regmap))
>  		return PTR_ERR(regmap);
>  
> +	ret = regulator_enable(tfa989x->vddd_supply);
> +	if (ret) {
> +		dev_err(dev, "Failed to enable vddd regulator: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = devm_add_action_or_reset(dev, tfa989x_regulator_disable, tfa989x);
> +	if (ret)
> +		return ret;
> +
>  	/* Bypass regcache for reset and init sequence */
>  	regcache_cache_bypass(regmap, true);
>  
> -- 
> 2.31.1
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ