mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
ASoC: meson: preparation for Card capsuling
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> says: These are v2 patch-set of meson preparation for Card capsuling. I will post Card capsuling patch. To makes its review easy, tidyup meson drivers to reduce un-related diff as preparation. No functional change, but is preparation for cleanup driver. Link: https://patch.msgid.link/87bjbytkej.wl-kuninori.morimoto.gx@renesas.com
This commit is contained in:
commit
3629acb34c
|
|
@ -107,6 +107,7 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
|
|||
struct snd_soc_dai_link *pad;
|
||||
struct snd_soc_dai_link *lb;
|
||||
struct snd_soc_dai_link_component *dlc;
|
||||
struct device *dev = card->dev;
|
||||
int ret;
|
||||
|
||||
/* extend links */
|
||||
|
|
@ -117,11 +118,11 @@ static int axg_card_add_tdm_loopback(struct snd_soc_card *card,
|
|||
pad = &card->dai_link[*index];
|
||||
lb = &card->dai_link[*index + 1];
|
||||
|
||||
lb->name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-lb", pad->name);
|
||||
lb->name = devm_kasprintf(dev, GFP_KERNEL, "%s-lb", pad->name);
|
||||
if (!lb->name)
|
||||
return -ENOMEM;
|
||||
|
||||
dlc = devm_kzalloc(card->dev, sizeof(*dlc), GFP_KERNEL);
|
||||
dlc = devm_kzalloc(dev, sizeof(*dlc), GFP_KERNEL);
|
||||
if (!dlc)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -158,13 +159,14 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
|
|||
struct device_node *node,
|
||||
struct axg_dai_link_tdm_data *be)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
char propname[32];
|
||||
u32 tx, rx;
|
||||
int i;
|
||||
|
||||
be->tx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES,
|
||||
be->tx_mask = devm_kcalloc(dev, AXG_TDM_NUM_LANES,
|
||||
sizeof(*be->tx_mask), GFP_KERNEL);
|
||||
be->rx_mask = devm_kcalloc(card->dev, AXG_TDM_NUM_LANES,
|
||||
be->rx_mask = devm_kcalloc(dev, AXG_TDM_NUM_LANES,
|
||||
sizeof(*be->rx_mask), GFP_KERNEL);
|
||||
if (!be->tx_mask || !be->rx_mask)
|
||||
return -ENOMEM;
|
||||
|
|
@ -191,7 +193,7 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
|
|||
|
||||
/* ... but the interface should at least have one direction */
|
||||
if (!tx && !rx) {
|
||||
dev_err(card->dev, "tdm link has no cpu slots\n");
|
||||
dev_err(dev, "tdm link has no cpu slots\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +209,7 @@ static int axg_card_parse_cpu_tdm_slots(struct snd_soc_card *card,
|
|||
* Error if the slots can't accommodate the largest mask or
|
||||
* if it is just too big
|
||||
*/
|
||||
dev_err(card->dev, "bad slot number\n");
|
||||
dev_err(dev, "bad slot number\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -222,8 +224,9 @@ static int axg_card_parse_codecs_masks(struct snd_soc_card *card,
|
|||
struct axg_dai_link_tdm_data *be)
|
||||
{
|
||||
struct axg_dai_link_tdm_mask *codec_mask;
|
||||
struct device *dev = card->dev;
|
||||
|
||||
codec_mask = devm_kcalloc(card->dev, link->num_codecs,
|
||||
codec_mask = devm_kcalloc(dev, link->num_codecs,
|
||||
sizeof(*codec_mask), GFP_KERNEL);
|
||||
if (!codec_mask)
|
||||
return -ENOMEM;
|
||||
|
|
@ -249,10 +252,11 @@ static int axg_card_parse_tdm(struct snd_soc_card *card,
|
|||
struct meson_card *priv = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_dai_link *link = &card->dai_link[*index];
|
||||
struct axg_dai_link_tdm_data *be;
|
||||
struct device *dev = card->dev;
|
||||
int ret;
|
||||
|
||||
/* Allocate tdm link parameters */
|
||||
be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
|
||||
be = devm_kzalloc(dev, sizeof(*be), GFP_KERNEL);
|
||||
if (!be)
|
||||
return -ENOMEM;
|
||||
priv->link_data[*index] = be;
|
||||
|
|
@ -266,7 +270,7 @@ static int axg_card_parse_tdm(struct snd_soc_card *card,
|
|||
|
||||
ret = axg_card_parse_cpu_tdm_slots(card, link, node, be);
|
||||
if (ret) {
|
||||
dev_err(card->dev, "error parsing tdm link slots\n");
|
||||
dev_err(dev, "error parsing tdm link slots\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -310,9 +314,10 @@ static int axg_card_add_link(struct snd_soc_card *card, struct device_node *np,
|
|||
{
|
||||
struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
|
||||
struct snd_soc_dai_link_component *cpu;
|
||||
struct device *dev = card->dev;
|
||||
int ret;
|
||||
|
||||
cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
|
||||
cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL);
|
||||
if (!cpu)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,10 @@ static int gx_card_parse_i2s(struct snd_soc_card *card,
|
|||
struct meson_card *priv = snd_soc_card_get_drvdata(card);
|
||||
struct snd_soc_dai_link *link = &card->dai_link[*index];
|
||||
struct gx_dai_link_i2s_data *be;
|
||||
struct device *dev = card->dev;
|
||||
|
||||
/* Allocate i2s link parameters */
|
||||
be = devm_kzalloc(card->dev, sizeof(*be), GFP_KERNEL);
|
||||
be = devm_kzalloc(dev, sizeof(*be), GFP_KERNEL);
|
||||
if (!be)
|
||||
return -ENOMEM;
|
||||
priv->link_data[*index] = be;
|
||||
|
|
@ -81,9 +82,10 @@ static int gx_card_add_link(struct snd_soc_card *card, struct device_node *np,
|
|||
{
|
||||
struct snd_soc_dai_link *dai_link = &card->dai_link[*index];
|
||||
struct snd_soc_dai_link_component *cpu;
|
||||
struct device *dev = card->dev;
|
||||
int ret;
|
||||
|
||||
cpu = devm_kzalloc(card->dev, sizeof(*cpu), GFP_KERNEL);
|
||||
cpu = devm_kzalloc(dev, sizeof(*cpu), GFP_KERNEL);
|
||||
if (!cpu)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ int meson_card_parse_dai(struct snd_soc_card *card,
|
|||
struct device_node *node,
|
||||
struct snd_soc_dai_link_component *dlc)
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
int ret;
|
||||
|
||||
if (!dlc || !node)
|
||||
|
|
@ -78,7 +79,7 @@ int meson_card_parse_dai(struct snd_soc_card *card,
|
|||
|
||||
ret = snd_soc_of_get_dlc(node, NULL, dlc, 0);
|
||||
if (ret)
|
||||
return dev_err_probe(card->dev, ret, "can't parse dai\n");
|
||||
return dev_err_probe(dev, ret, "can't parse dai\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -89,7 +90,8 @@ static int meson_card_set_link_name(struct snd_soc_card *card,
|
|||
struct device_node *node,
|
||||
const char *prefix)
|
||||
{
|
||||
char *name = devm_kasprintf(card->dev, GFP_KERNEL, "%s.%s",
|
||||
struct device *dev = card->dev;
|
||||
char *name = devm_kasprintf(dev, GFP_KERNEL, "%s.%s",
|
||||
prefix, node->full_name);
|
||||
if (!name)
|
||||
return -ENOMEM;
|
||||
|
|
@ -132,16 +134,17 @@ int meson_card_set_be_link(struct snd_soc_card *card,
|
|||
struct device_node *node)
|
||||
{
|
||||
struct snd_soc_dai_link_component *codec;
|
||||
struct device *dev = card->dev;
|
||||
int ret, num_codecs;
|
||||
|
||||
num_codecs = of_get_child_count(node);
|
||||
if (!num_codecs) {
|
||||
dev_err(card->dev, "be link %s has no codec\n",
|
||||
dev_err(dev, "be link %s has no codec\n",
|
||||
node->full_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
codec = devm_kcalloc(card->dev, num_codecs, sizeof(*codec), GFP_KERNEL);
|
||||
codec = devm_kcalloc(dev, num_codecs, sizeof(*codec), GFP_KERNEL);
|
||||
if (!codec)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -158,7 +161,7 @@ int meson_card_set_be_link(struct snd_soc_card *card,
|
|||
|
||||
ret = meson_card_set_link_name(card, link, node, "be");
|
||||
if (ret)
|
||||
dev_err(card->dev, "error setting %pOFn link name\n", node);
|
||||
dev_err(dev, "error setting %pOFn link name\n", node);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -189,12 +192,13 @@ EXPORT_SYMBOL_GPL(meson_card_set_fe_link);
|
|||
static int meson_card_add_links(struct snd_soc_card *card)
|
||||
{
|
||||
struct meson_card *priv = snd_soc_card_get_drvdata(card);
|
||||
struct device_node *node = card->dev->of_node;
|
||||
struct device *dev = card->dev;
|
||||
struct device_node *node = dev->of_node;
|
||||
int num, i, ret;
|
||||
|
||||
num = of_get_child_count(node);
|
||||
if (!num) {
|
||||
dev_err(card->dev, "card has no links\n");
|
||||
dev_err(dev, "card has no links\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -219,8 +223,10 @@ static int meson_card_parse_of_optional(struct snd_soc_card *card,
|
|||
int (*func)(struct snd_soc_card *c,
|
||||
const char *p))
|
||||
{
|
||||
struct device *dev = card->dev;
|
||||
|
||||
/* If property is not provided, don't fail ... */
|
||||
if (!of_property_present(card->dev->of_node, propname))
|
||||
if (!of_property_present(dev->of_node, propname))
|
||||
return 0;
|
||||
|
||||
/* ... but do fail if it is provided and the parsing fails */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user