ASoC: wm8753: fix initialization
[firefly-linux-kernel-4.4.55.git] / sound / soc / codecs / wm8753.c
index 21ed75de41f31ed9384aa904b6473add464eddcd..e27e7b62b365a0a79942956455d95d40dd4f2e5d 100644 (file)
@@ -1557,7 +1557,8 @@ static int __devinit wm8753_spi_probe(struct spi_device *spi)
        struct wm8753_priv *wm8753;
        int ret;
 
-       wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL);
+       wm8753 = devm_kzalloc(&spi->dev, sizeof(struct wm8753_priv),
+                             GFP_KERNEL);
        if (wm8753 == NULL)
                return -ENOMEM;
 
@@ -1577,10 +1578,12 @@ static int __devinit wm8753_spi_probe(struct spi_device *spi)
                dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret);
                goto err_regmap;
        }
+
+       return 0;
+
 err_regmap:
        regmap_exit(wm8753->regmap);
 err:
-       kfree(wm8753);
        return ret;
 }
 
@@ -1612,7 +1615,8 @@ static __devinit int wm8753_i2c_probe(struct i2c_client *i2c,
        struct wm8753_priv *wm8753;
        int ret;
 
-       wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL);
+       wm8753 = devm_kzalloc(&i2c->dev, sizeof(struct wm8753_priv),
+                             GFP_KERNEL);
        if (wm8753 == NULL)
                return -ENOMEM;
 
@@ -1632,10 +1636,12 @@ static __devinit int wm8753_i2c_probe(struct i2c_client *i2c,
                dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
                goto err_regmap;
        }
+
+       return 0;
+
 err_regmap:
        regmap_exit(wm8753->regmap);
 err:
-       kfree(wm8753);
        return ret;
 }
 
@@ -1645,7 +1651,6 @@ static __devexit int wm8753_i2c_remove(struct i2c_client *client)
 
        snd_soc_unregister_codec(&client->dev);
        regmap_exit(wm8753->regmap);
-       kfree(wm8753);
        return 0;
 }