[alsa-devel] [PATCH] ASoC: sgtl5000: Convert to use regmap directly

Mark Brown broonie at kernel.org
Sun May 5 12:21:48 CEST 2013


On Sat, May 04, 2013 at 03:39:34PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam at freescale.com>
> 
> Signed-off-by: Fabio Estevam <fabio.estevam at freescale.com>

Applied, thanks - this can be taken a step further and

> +static const struct regmap_config sgtl5000_regmap = {
> +	.reg_bits = 16,
> +	.val_bits = 16,
> +
> +	.max_register = SGTL5000_MAX_REG_OFFSET,
> +	.volatile_reg = sgtl5000_volatile,
> +	.readable_reg = sgtl5000_readable,
> +
> +	.cache_type = REGCACHE_RBTREE,
> +	.reg_defaults = sgtl5000_reg_defaults,
> +	.num_reg_defaults = ARRAY_SIZE(sgtl5000_reg_defaults),
> +};

Based on the comments in the commit you mentioned before do we need to
have some sort of register striding in there?

>  static int sgtl5000_i2c_probe(struct i2c_client *client,
>  			      const struct i2c_device_id *id)
>  {
> @@ -1415,6 +1485,13 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
>  	if (!sgtl5000)
>  		return -ENOMEM;
>  
> +	sgtl5000->regmap = devm_regmap_init_i2c(client, &sgtl5000_regmap);
> +	if (IS_ERR(sgtl5000->regmap)) {
> +		ret = PTR_ERR(sgtl5000->regmap);
> +		dev_err(&client->dev, "Failed to allocate regmap: %d\n", ret);
> +		return ret;
> +	}
> +

Now we have register I/O in the probe the regulator setup, device
identification and so on can be pulled out here.  This is more idiomatic
for the device model if nothing else.

There's definitely still a bug in this driver with regard to not syncing
the cache too...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20130505/e3eba14e/attachment.sig>


More information about the Alsa-devel mailing list