[alsa-devel] [PATCH 1/2] ASoC: fsl_audmix: remove "model" attribute
Viorel Suman
viorel.suman at nxp.com
Tue Apr 9 10:35:34 CEST 2019
Use "of_device_id.data" to specify the machine driver,
instead of "model" DTS attribute.
Signed-off-by: Viorel Suman <viorel.suman at nxp.com>
---
sound/soc/fsl/fsl_audmix.c | 61 ++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 29 deletions(-)
diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c
index dabde03..2d10d8b 100644
--- a/sound/soc/fsl/fsl_audmix.c
+++ b/sound/soc/fsl/fsl_audmix.c
@@ -445,61 +445,70 @@ static const struct regmap_config fsl_audmix_regmap_config = {
.cache_type = REGCACHE_FLAT,
};
+static const struct of_device_id fsl_audmix_ids[] = {
+ {
+ .compatible = "fsl,imx8qm-audmix",
+ .data = "imx-audmix",
+ },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, fsl_audmix_ids);
+
static int fsl_audmix_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct fsl_audmix *priv;
struct resource *res;
+ const char *mdrv;
+ const struct of_device_id *of_id;
void __iomem *regs;
int ret;
- const char *sprop;
- priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+ of_id = of_match_device(fsl_audmix_ids, dev);
+ if (!of_id || !of_id->data)
+ return -EINVAL;
+
+ mdrv = of_id->data;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
/* Get the addresses */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- regs = devm_ioremap_resource(&pdev->dev, res);
+ regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs))
return PTR_ERR(regs);
- priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "ipg", regs,
+ priv->regmap = devm_regmap_init_mmio_clk(dev, "ipg", regs,
&fsl_audmix_regmap_config);
if (IS_ERR(priv->regmap)) {
- dev_err(&pdev->dev, "failed to init regmap\n");
+ dev_err(dev, "failed to init regmap\n");
return PTR_ERR(priv->regmap);
}
- priv->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
+ priv->ipg_clk = devm_clk_get(dev, "ipg");
if (IS_ERR(priv->ipg_clk)) {
- dev_err(&pdev->dev, "failed to get ipg clock\n");
+ dev_err(dev, "failed to get ipg clock\n");
return PTR_ERR(priv->ipg_clk);
}
platform_set_drvdata(pdev, priv);
- pm_runtime_enable(&pdev->dev);
+ pm_runtime_enable(dev);
- ret = devm_snd_soc_register_component(&pdev->dev, &fsl_audmix_component,
+ ret = devm_snd_soc_register_component(dev, &fsl_audmix_component,
fsl_audmix_dai,
ARRAY_SIZE(fsl_audmix_dai));
if (ret) {
- dev_err(&pdev->dev, "failed to register ASoC DAI\n");
+ dev_err(dev, "failed to register ASoC DAI\n");
return ret;
}
- sprop = of_get_property(pdev->dev.of_node, "model", NULL);
- if (sprop) {
- priv->pdev = platform_device_register_data(&pdev->dev, sprop, 0,
- NULL, 0);
- if (IS_ERR(priv->pdev)) {
- ret = PTR_ERR(priv->pdev);
- dev_err(&pdev->dev,
- "failed to register platform %s: %d\n", sprop,
- ret);
- }
- } else {
- dev_err(&pdev->dev, "[model] attribute missing.\n");
- ret = -EINVAL;
+ priv->pdev = platform_device_register_data(dev, mdrv, 0, NULL, 0);
+ if (IS_ERR(priv->pdev)) {
+ ret = PTR_ERR(priv->pdev);
+ dev_err(dev, "failed to register platform %s: %d\n",
+ mdrv, ret);
}
return ret;
@@ -553,12 +562,6 @@ static const struct dev_pm_ops fsl_audmix_pm = {
pm_runtime_force_resume)
};
-static const struct of_device_id fsl_audmix_ids[] = {
- { .compatible = "fsl,imx8qm-audmix", },
- { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, fsl_audmix_ids);
-
static struct platform_driver fsl_audmix_driver = {
.probe = fsl_audmix_probe,
.remove = fsl_audmix_remove,
--
2.7.4
More information about the Alsa-devel
mailing list