struct cs42l73_private *cs42l73 = i2c_get_clientdata(client);
snd_soc_unregister_codec(&client->dev);
- kfree(cs42l73);
+
+ /* No need for kfree(cs42l73), as it'll be automatically freed
+ * once driver detach. Refer devm_kzalloc() for details
+ */
return 0;
}
gpio_export(gpio->gpio, false);
#endif
/* Update initial jack status */
- clv_soc_jack_gpio_detect(gpio);
+ if (gpio->gpio == CS42L73_HPSENSE_GPIO)
+ clv_soc_jack_gpio_detect(gpio);
return 0;
err:
goto unalloc;
}
vsp_mode = 1;
- ipc_set_drvdata(ipcdev, mc_drv_ctx);
- dev_set_drvdata(&ipcdev->dev, &snd_soc_card_clv);
+ ipc_set_drvdata(ipcdev, &snd_soc_card_clv);
+ snd_soc_card_set_drvdata(&snd_soc_card_clv, mc_drv_ctx);
pr_debug("successfully exited probe\n");
return ret_val;
static int __devexit snd_clv_mc_remove(struct ipc_device *ipcdev)
{
- struct mfld_mc_private *mc_drv_ctx = ipc_get_drvdata(ipcdev);
+ struct snd_soc_card *soc_card = ipc_get_drvdata(ipcdev);
+ struct mfld_mc_private *mc_drv_ctx = snd_soc_card_get_drvdata(soc_card);
pr_debug("In %s\n", __func__);
+ kfree(mc_drv_ctx);
snd_soc_jack_free_gpios(&clv_jack, 1, &hs_jack_gpio);
snd_soc_jack_free_gpios(&clv_jack, 1, &hs_button_gpio);
- snd_soc_unregister_card(&snd_soc_card_clv);
- kfree(mc_drv_ctx);
+ snd_soc_card_set_drvdata(soc_card, NULL);
+ snd_soc_unregister_card(soc_card);
ipc_set_drvdata(ipcdev, NULL);
return 0;
}