Skip to content

Commit

Permalink
ASoC: mxs-saif: remove function in platform_data
Browse files Browse the repository at this point in the history
Add master_mode and master_id in platfrom_data since it's board
specific and board knows it.
Then we can remove the function pointer in platfrom_data to make
the driver more devicetree friendly.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
  • Loading branch information
Dong Aisheng authored and Shawn Guo committed Dec 2, 2011
1 parent 5611cc4 commit 7788258
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions include/sound/saif.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define __SOUND_SAIF_H__

struct mxs_saif_platform_data {
int (*init) (void);
int (*get_master_id) (unsigned int saif_id);
bool master_mode; /* if true use master mode */
int master_id; /* id of the master if in slave mode */
};
#endif
20 changes: 9 additions & 11 deletions sound/soc/mxs/mxs-saif.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,26 +625,24 @@ static int mxs_saif_probe(struct platform_device *pdev)
if (pdev->id >= ARRAY_SIZE(mxs_saif))
return -EINVAL;

pdata = pdev->dev.platform_data;
if (pdata && pdata->init) {
ret = pdata->init();
if (ret)
return ret;
}

saif = kzalloc(sizeof(*saif), GFP_KERNEL);
if (!saif)
return -ENOMEM;

mxs_saif[pdev->id] = saif;
saif->id = pdev->id;

saif->master_id = saif->id;
if (pdata && pdata->get_master_id) {
saif->master_id = pdata->get_master_id(saif->id);
pdata = pdev->dev.platform_data;
if (pdata && !pdata->master_mode) {
saif->master_id = pdata->master_id;
if (saif->master_id < 0 ||
saif->master_id >= ARRAY_SIZE(mxs_saif))
saif->master_id >= ARRAY_SIZE(mxs_saif) ||
saif->master_id == saif->id) {
dev_err(&pdev->dev, "get wrong master id\n");
return -EINVAL;
}
} else {
saif->master_id = saif->id;
}

saif->clk = clk_get(&pdev->dev, NULL);
Expand Down

0 comments on commit 7788258

Please sign in to comment.