Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASoC: SOF: refine and unify sof_xxx_priv structs #31

Merged
merged 2 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions include/sound/sof.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

struct snd_sof_dsp_ops;

/* SOF probe type */
enum sof_device_type {
SOF_DEVICE_PCI = 0,
SOF_DEVICE_APCI,
SOF_DEVICE_SPI
};

/*
* SOF Platform data.
*/
Expand All @@ -32,10 +39,9 @@ struct snd_sof_pdata {
const char *drv_name;
const char *name;

/* parent devices */
/* parent device */
struct device *dev;
struct pci_dev *pci;
struct platform_device *pdev;
enum sof_device_type type;

/* descriptor */
const struct sof_dev_desc *desc;
Expand Down
11 changes: 3 additions & 8 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,9 @@ static int sof_probe(struct platform_device *pdev)

/* initialize sof device */
sdev->dev = &pdev->dev;
if (plat_data->pci) {
sdev->pci = plat_data->pci;
sdev->parent = &plat_data->pci->dev;
} else if (plat_data->pdev) {
sdev->parent = &plat_data->pdev->dev;
} else {
sdev->parent = plat_data->dev;
}
sdev->parent = plat_data->dev;
if (plat_data->type == SOF_DEVICE_PCI)
sdev->pci = container_of(plat_data->dev, struct pci_dev, dev);
sdev->ops = plat_data->machine->pdata;

sdev->pdata = plat_data;
Expand Down
18 changes: 7 additions & 11 deletions sound/soc/sof/sof-acpi-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static struct platform_device *
mfld_new_mach_data(struct snd_sof_pdata *sof_pdata)
{
struct snd_soc_acpi_mach pmach;
struct device *dev = &sof_pdata->pdev->dev;
struct device *dev = sof_pdata->dev;
const struct snd_soc_acpi_mach *mach = sof_pdata->machine;
struct platform_device *pdev = NULL;

Expand All @@ -134,17 +134,12 @@ static struct platform_device *
return pdev;
}

struct sof_acpi_priv {
struct snd_sof_pdata *sof_pdata;
struct platform_device *pdev_pcm;
};

static void sof_acpi_fw_cb(const struct firmware *fw, void *context)
{
struct sof_acpi_priv *priv = context;
struct sof_platform_priv *priv = context;
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;
const struct snd_soc_acpi_mach *mach = sof_pdata->machine;
struct device *dev = &sof_pdata->pdev->dev;
struct device *dev = sof_pdata->dev;

sof_pdata->fw = fw;
if (!fw) {
Expand Down Expand Up @@ -209,7 +204,7 @@ static int sof_acpi_probe(struct platform_device *pdev)
const struct sof_dev_desc *desc;
struct snd_soc_acpi_mach *mach;
struct snd_sof_pdata *sof_pdata;
struct sof_acpi_priv *priv;
struct sof_platform_priv *priv;
struct snd_sof_dsp_ops *ops;
struct platform_device *(*new_mach_data)(struct snd_sof_pdata *pdata);
int ret = 0;
Expand Down Expand Up @@ -278,7 +273,8 @@ static int sof_acpi_probe(struct platform_device *pdev)
*/
sof_pdata->desc = desc;
priv->sof_pdata = sof_pdata;
sof_pdata->pdev = pdev;
sof_pdata->dev = &pdev->dev;
sof_pdata->type = SOF_DEVICE_APCI;
dev_set_drvdata(&pdev->dev, priv);

/* do we need to generate any machine plat data ? */
Expand Down Expand Up @@ -315,7 +311,7 @@ static void sof_acpi_shutdown(struct platform_device *pdev)

static int sof_acpi_remove(struct platform_device *pdev)
{
struct sof_acpi_priv *priv = dev_get_drvdata(&pdev->dev);
struct sof_platform_priv *priv = dev_get_drvdata(&pdev->dev);
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;

platform_device_unregister(sof_pdata->pdev_mach);
Expand Down
13 changes: 4 additions & 9 deletions sound/soc/sof/sof-pci-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,9 @@ static struct sof_dev_desc kbl_desc = {
};
#endif

struct sof_pci_priv {
struct snd_sof_pdata *sof_pdata;
struct platform_device *pdev_pcm;
};

static void sof_pci_fw_cb(const struct firmware *fw, void *context)
{
struct sof_pci_priv *priv = context;
struct sof_platform_priv *priv = context;
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;
const struct snd_soc_acpi_mach *mach = sof_pdata->machine;
struct device *dev = sof_pdata->dev;
Expand Down Expand Up @@ -192,7 +187,7 @@ static int sof_pci_probe(struct pci_dev *pci,
(const struct sof_dev_desc *)pci_id->driver_data;
struct snd_soc_acpi_mach *mach;
struct snd_sof_pdata *sof_pdata;
struct sof_pci_priv *priv;
struct sof_platform_priv *priv;
struct snd_sof_dsp_ops *ops;
int ret = 0;

Expand Down Expand Up @@ -256,8 +251,8 @@ static int sof_pci_probe(struct pci_dev *pci,
sof_pdata->machine = mach;
sof_pdata->desc = (struct sof_dev_desc *)pci_id->driver_data;
priv->sof_pdata = sof_pdata;
sof_pdata->pci = pci;
sof_pdata->dev = &pci->dev;
sof_pdata->type = SOF_DEVICE_PCI;

/* register machine driver */
sof_pdata->pdev_mach =
Expand Down Expand Up @@ -299,7 +294,7 @@ static void sof_pci_shutdown(struct pci_dev *pci)

static void sof_pci_remove(struct pci_dev *pci)
{
struct sof_pci_priv *priv = pci_get_drvdata(pci);
struct sof_platform_priv *priv = pci_get_drvdata(pci);
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;

/* unregister machine driver */
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/sof-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,15 @@ struct snd_sof_dev {
void *private; /* core does not touch this */
};

/*
* SOF platform private struct used as drvdata of
* platform dev (e.g. pci/acpi/spi...) drvdata.
*/
struct sof_platform_priv {
struct snd_sof_pdata *sof_pdata;
struct platform_device *pdev_pcm;
};

/*
* Device Level.
*/
Expand Down
13 changes: 4 additions & 9 deletions sound/soc/sof/sof-spi-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@
#include <linux/of_device.h>
#include "sof-priv.h"

struct sof_spi_priv {
struct snd_sof_pdata *sof_pdata;
struct platform_device *pdev_pcm;
};

static void sof_spi_fw_cb(const struct firmware *fw, void *context)
{
struct sof_spi_priv *priv = context;
struct sof_platform_priv *priv = context;
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;
const struct snd_sof_machine *mach = sof_pdata->machine;
struct device *dev = sof_pdata->dev;
Expand Down Expand Up @@ -61,7 +56,7 @@ static int sof_spi_probe(struct spi_device *spi)
const struct snd_sof_machine *mach;
struct snd_sof_machine *m;
struct snd_sof_pdata *sof_pdata;
struct sof_spi_priv *priv;
struct sof_platform_priv *priv;
int ret = 0;

dev_dbg(&spi->dev, "SPI DSP detected");
Expand Down Expand Up @@ -94,8 +89,8 @@ static int sof_spi_probe(struct spi_device *spi)
sof_pdata->machine = mach;
sof_pdata->desc = (struct sof_dev_desc *)pci_id->driver_data;
priv->sof_pdata = sof_pdata;
sof_pdata->spi = spi;
sof_pdata->dev = dev;
sof_pdata->type = SOF_DEVICE_SPI;

/* register machine driver */
sof_pdata->pdev_mach =
Expand All @@ -117,7 +112,7 @@ static int sof_spi_probe(struct spi_device *spi)

static int sof_spi_remove(struct spi_device *spi)
{
struct sof_spi_priv *priv = spi_get_drvdata(spi);
struct sof_platform_priv *priv = spi_get_drvdata(spi);
struct snd_sof_pdata *sof_pdata = priv->sof_pdata;

platform_device_unregister(sof_pdata->pdev_mach);
Expand Down