提交 30c88f2c 编写于 作者: A Axel Lin 提交者: Mark Brown

ASoC: Convert ad193x to devm_kzalloc()

Signed-off-by: NAxel Lin <axel.lin@gmail.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 a5b68348
...@@ -385,14 +385,15 @@ static int __devinit ad193x_spi_probe(struct spi_device *spi) ...@@ -385,14 +385,15 @@ static int __devinit ad193x_spi_probe(struct spi_device *spi)
struct ad193x_priv *ad193x; struct ad193x_priv *ad193x;
int ret; int ret;
ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL); ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv),
GFP_KERNEL);
if (ad193x == NULL) if (ad193x == NULL)
return -ENOMEM; return -ENOMEM;
ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config); ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config);
if (IS_ERR(ad193x->regmap)) { if (IS_ERR(ad193x->regmap)) {
ret = PTR_ERR(ad193x->regmap); ret = PTR_ERR(ad193x->regmap);
goto err_free; goto err_out;
} }
spi_set_drvdata(spi, ad193x); spi_set_drvdata(spi, ad193x);
...@@ -406,9 +407,7 @@ static int __devinit ad193x_spi_probe(struct spi_device *spi) ...@@ -406,9 +407,7 @@ static int __devinit ad193x_spi_probe(struct spi_device *spi)
err_regmap_exit: err_regmap_exit:
regmap_exit(ad193x->regmap); regmap_exit(ad193x->regmap);
err_free: err_out:
kfree(ad193x);
return ret; return ret;
} }
...@@ -418,7 +417,6 @@ static int __devexit ad193x_spi_remove(struct spi_device *spi) ...@@ -418,7 +417,6 @@ static int __devexit ad193x_spi_remove(struct spi_device *spi)
snd_soc_unregister_codec(&spi->dev); snd_soc_unregister_codec(&spi->dev);
regmap_exit(ad193x->regmap); regmap_exit(ad193x->regmap);
kfree(ad193x);
return 0; return 0;
} }
...@@ -455,14 +453,15 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client, ...@@ -455,14 +453,15 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client,
struct ad193x_priv *ad193x; struct ad193x_priv *ad193x;
int ret; int ret;
ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL); ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv),
GFP_KERNEL);
if (ad193x == NULL) if (ad193x == NULL)
return -ENOMEM; return -ENOMEM;
ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config); ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config);
if (IS_ERR(ad193x->regmap)) { if (IS_ERR(ad193x->regmap)) {
ret = PTR_ERR(ad193x->regmap); ret = PTR_ERR(ad193x->regmap);
goto err_free; goto err_out;
} }
i2c_set_clientdata(client, ad193x); i2c_set_clientdata(client, ad193x);
...@@ -476,8 +475,7 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client, ...@@ -476,8 +475,7 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client,
err_regmap_exit: err_regmap_exit:
regmap_exit(ad193x->regmap); regmap_exit(ad193x->regmap);
err_free: err_out:
kfree(ad193x);
return ret; return ret;
} }
...@@ -487,7 +485,6 @@ static int __devexit ad193x_i2c_remove(struct i2c_client *client) ...@@ -487,7 +485,6 @@ static int __devexit ad193x_i2c_remove(struct i2c_client *client)
snd_soc_unregister_codec(&client->dev); snd_soc_unregister_codec(&client->dev);
regmap_exit(ad193x->regmap); regmap_exit(ad193x->regmap);
kfree(ad193x);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册