Commit 38fec727 authored by Timur Tabi's avatar Timur Tabi Committed by Mark Brown

ASoC: mpc8610: replace of_device with platform_device

'struct of_device' no longer exists, and its functionality has been merged
into platform_device.  Update the MPC8610 HPCD audio drivers (fsl_ssi, fsl_dma,
and mpc8610_hpcd) accordingly.

Also add a #include for slab.h, which is now needed for kmalloc and kfree.
Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent bf557a50
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -895,11 +896,11 @@ static struct snd_pcm_ops fsl_dma_ops = { ...@@ -895,11 +896,11 @@ static struct snd_pcm_ops fsl_dma_ops = {
.pointer = fsl_dma_pointer, .pointer = fsl_dma_pointer,
}; };
static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, static int __devinit fsl_soc_dma_probe(struct platform_device *pdev,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct dma_object *dma; struct dma_object *dma;
struct device_node *np = of_dev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device_node *ssi_np; struct device_node *ssi_np;
struct resource res; struct resource res;
const uint32_t *iprop; const uint32_t *iprop;
...@@ -908,13 +909,13 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, ...@@ -908,13 +909,13 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
/* Find the SSI node that points to us. */ /* Find the SSI node that points to us. */
ssi_np = find_ssi_node(np); ssi_np = find_ssi_node(np);
if (!ssi_np) { if (!ssi_np) {
dev_err(&of_dev->dev, "cannot find parent SSI node\n"); dev_err(&pdev->dev, "cannot find parent SSI node\n");
return -ENODEV; return -ENODEV;
} }
ret = of_address_to_resource(ssi_np, 0, &res); ret = of_address_to_resource(ssi_np, 0, &res);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not determine resources for %s\n", dev_err(&pdev->dev, "could not determine resources for %s\n",
ssi_np->full_name); ssi_np->full_name);
of_node_put(ssi_np); of_node_put(ssi_np);
return ret; return ret;
...@@ -922,7 +923,7 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, ...@@ -922,7 +923,7 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL); dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
if (!dma) { if (!dma) {
dev_err(&of_dev->dev, "could not allocate dma object\n"); dev_err(&pdev->dev, "could not allocate dma object\n");
of_node_put(ssi_np); of_node_put(ssi_np);
return -ENOMEM; return -ENOMEM;
} }
...@@ -945,9 +946,9 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, ...@@ -945,9 +946,9 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
of_node_put(ssi_np); of_node_put(ssi_np);
ret = snd_soc_register_platform(&of_dev->dev, &dma->dai); ret = snd_soc_register_platform(&pdev->dev, &dma->dai);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not register platform\n"); dev_err(&pdev->dev, "could not register platform\n");
kfree(dma); kfree(dma);
return ret; return ret;
} }
...@@ -955,16 +956,16 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, ...@@ -955,16 +956,16 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma->channel = of_iomap(np, 0); dma->channel = of_iomap(np, 0);
dma->irq = irq_of_parse_and_map(np, 0); dma->irq = irq_of_parse_and_map(np, 0);
dev_set_drvdata(&of_dev->dev, dma); dev_set_drvdata(&pdev->dev, dma);
return 0; return 0;
} }
static int __devexit fsl_soc_dma_remove(struct of_device *of_dev) static int __devexit fsl_soc_dma_remove(struct platform_device *pdev)
{ {
struct dma_object *dma = dev_get_drvdata(&of_dev->dev); struct dma_object *dma = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_platform(&of_dev->dev); snd_soc_unregister_platform(&pdev->dev);
iounmap(dma->channel); iounmap(dma->channel);
irq_dispose_mapping(dma->irq); irq_dispose_mapping(dma->irq);
kfree(dma); kfree(dma);
......
...@@ -624,13 +624,13 @@ static void make_lowercase(char *s) ...@@ -624,13 +624,13 @@ static void make_lowercase(char *s)
} }
} }
static int __devinit fsl_ssi_probe(struct of_device *of_dev, static int __devinit fsl_ssi_probe(struct platform_device *pdev,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct fsl_ssi_private *ssi_private; struct fsl_ssi_private *ssi_private;
int ret = 0; int ret = 0;
struct device_attribute *dev_attr = NULL; struct device_attribute *dev_attr = NULL;
struct device_node *np = of_dev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const char *p, *sprop; const char *p, *sprop;
const uint32_t *iprop; const uint32_t *iprop;
struct resource res; struct resource res;
...@@ -645,14 +645,14 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -645,14 +645,14 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
/* Check for a codec-handle property. */ /* Check for a codec-handle property. */
if (!of_get_property(np, "codec-handle", NULL)) { if (!of_get_property(np, "codec-handle", NULL)) {
dev_err(&of_dev->dev, "missing codec-handle property\n"); dev_err(&pdev->dev, "missing codec-handle property\n");
return -ENODEV; return -ENODEV;
} }
/* We only support the SSI in "I2S Slave" mode */ /* We only support the SSI in "I2S Slave" mode */
sprop = of_get_property(np, "fsl,mode", NULL); sprop = of_get_property(np, "fsl,mode", NULL);
if (!sprop || strcmp(sprop, "i2s-slave")) { if (!sprop || strcmp(sprop, "i2s-slave")) {
dev_notice(&of_dev->dev, "mode %s is unsupported\n", sprop); dev_notice(&pdev->dev, "mode %s is unsupported\n", sprop);
return -ENODEV; return -ENODEV;
} }
...@@ -661,7 +661,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -661,7 +661,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p), ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p),
GFP_KERNEL); GFP_KERNEL);
if (!ssi_private) { if (!ssi_private) {
dev_err(&of_dev->dev, "could not allocate DAI object\n"); dev_err(&pdev->dev, "could not allocate DAI object\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -675,7 +675,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -675,7 +675,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
/* Get the addresses and IRQ */ /* Get the addresses and IRQ */
ret = of_address_to_resource(np, 0, &res); ret = of_address_to_resource(np, 0, &res);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not determine device resources\n"); dev_err(&pdev->dev, "could not determine device resources\n");
kfree(ssi_private); kfree(ssi_private);
return ret; return ret;
} }
...@@ -703,19 +703,19 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -703,19 +703,19 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
dev_attr->attr.mode = S_IRUGO; dev_attr->attr.mode = S_IRUGO;
dev_attr->show = fsl_sysfs_ssi_show; dev_attr->show = fsl_sysfs_ssi_show;
ret = device_create_file(&of_dev->dev, dev_attr); ret = device_create_file(&pdev->dev, dev_attr);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not create sysfs %s file\n", dev_err(&pdev->dev, "could not create sysfs %s file\n",
ssi_private->dev_attr.attr.name); ssi_private->dev_attr.attr.name);
goto error; goto error;
} }
/* Register with ASoC */ /* Register with ASoC */
dev_set_drvdata(&of_dev->dev, ssi_private); dev_set_drvdata(&pdev->dev, ssi_private);
ret = snd_soc_register_dai(&of_dev->dev, &ssi_private->cpu_dai_drv); ret = snd_soc_register_dai(&pdev->dev, &ssi_private->cpu_dai_drv);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "failed to register DAI: %d\n", ret); dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
goto error; goto error;
} }
...@@ -733,20 +733,20 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -733,20 +733,20 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
make_lowercase(name); make_lowercase(name);
ssi_private->pdev = ssi_private->pdev =
platform_device_register_data(&of_dev->dev, name, 0, NULL, 0); platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
if (IS_ERR(ssi_private->pdev)) { if (IS_ERR(ssi_private->pdev)) {
ret = PTR_ERR(ssi_private->pdev); ret = PTR_ERR(ssi_private->pdev);
dev_err(&of_dev->dev, "failed to register platform: %d\n", ret); dev_err(&pdev->dev, "failed to register platform: %d\n", ret);
goto error; goto error;
} }
return 0; return 0;
error: error:
snd_soc_unregister_dai(&of_dev->dev); snd_soc_unregister_dai(&pdev->dev);
dev_set_drvdata(&of_dev->dev, NULL); dev_set_drvdata(&pdev->dev, NULL);
if (dev_attr) if (dev_attr)
device_remove_file(&of_dev->dev, dev_attr); device_remove_file(&pdev->dev, dev_attr);
irq_dispose_mapping(ssi_private->irq); irq_dispose_mapping(ssi_private->irq);
iounmap(ssi_private->ssi); iounmap(ssi_private->ssi);
kfree(ssi_private); kfree(ssi_private);
...@@ -754,16 +754,16 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -754,16 +754,16 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
return ret; return ret;
} }
static int fsl_ssi_remove(struct of_device *of_dev) static int fsl_ssi_remove(struct platform_device *pdev)
{ {
struct fsl_ssi_private *ssi_private = dev_get_drvdata(&of_dev->dev); struct fsl_ssi_private *ssi_private = dev_get_drvdata(&pdev->dev);
platform_device_unregister(ssi_private->pdev); platform_device_unregister(ssi_private->pdev);
snd_soc_unregister_dai(&of_dev->dev); snd_soc_unregister_dai(&pdev->dev);
device_remove_file(&of_dev->dev, &ssi_private->dev_attr); device_remove_file(&pdev->dev, &ssi_private->dev_attr);
kfree(ssi_private); kfree(ssi_private);
dev_set_drvdata(&of_dev->dev, NULL); dev_set_drvdata(&pdev->dev, NULL);
return 0; return 0;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/slab.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <asm/fsl_guts.h> #include <asm/fsl_guts.h>
...@@ -323,9 +324,10 @@ static int get_dma_channel(struct device_node *ssi_np, ...@@ -323,9 +324,10 @@ static int get_dma_channel(struct device_node *ssi_np,
static int mpc8610_hpcd_probe(struct platform_device *pdev) static int mpc8610_hpcd_probe(struct platform_device *pdev)
{ {
struct device *dev = pdev->dev.parent; struct device *dev = pdev->dev.parent;
/* of_dev is the OF device for the SSI node that probed us */ /* ssi_pdev is the platform device for the SSI node that probed us */
struct of_device *of_dev = container_of(dev, struct of_device, dev); struct platform_device *ssi_pdev =
struct device_node *np = of_dev->dev.of_node; container_of(dev, struct platform_device, dev);
struct device_node *np = ssi_pdev->dev.of_node;
struct device_node *codec_np = NULL; struct device_node *codec_np = NULL;
struct platform_device *sound_device = NULL; struct platform_device *sound_device = NULL;
struct mpc8610_hpcd_data *machine_data; struct mpc8610_hpcd_data *machine_data;
...@@ -348,7 +350,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) ...@@ -348,7 +350,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
if (!machine_data) if (!machine_data)
return -ENOMEM; return -ENOMEM;
machine_data->dai[0].cpu_dai_name = dev_name(&of_dev->dev); machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
machine_data->dai[0].ops = &mpc8610_hpcd_ops; machine_data->dai[0].ops = &mpc8610_hpcd_ops;
/* Determine the codec name, it will be used as the codec DAI name */ /* Determine the codec name, it will be used as the codec DAI name */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment