Skip to content

Commit 33126f3

Browse files
Heikki Krogerusplbossart
authored andcommitted
ASoC: Intel: boards: use software node API in Atom boards
The function device_add_properties() is going to be removed. Replacing it with software node API equivalents. Co-developed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
1 parent d6c1c7c commit 33126f3

File tree

3 files changed

+98
-17
lines changed

3 files changed

+98
-17
lines changed

sound/soc/intel/boards/bytcht_es8316.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct byt_cht_es8316_private {
3838
struct snd_soc_jack jack;
3939
struct gpio_desc *speaker_en_gpio;
4040
bool speaker_en;
41+
struct device *codec_dev;
4142
};
4243

4344
enum {
@@ -461,6 +462,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
461462
const struct dmi_system_id *dmi_id;
462463
struct device *dev = &pdev->dev;
463464
struct snd_soc_acpi_mach *mach;
465+
struct fwnode_handle *fwnode;
464466
const char *platform_name;
465467
struct acpi_device *adev;
466468
struct device *codec_dev;
@@ -543,7 +545,16 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
543545
props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted");
544546

545547
if (cnt) {
546-
ret = device_add_properties(codec_dev, props);
548+
fwnode = fwnode_create_software_node(props, NULL);
549+
if (IS_ERR(fwnode)) {
550+
put_device(codec_dev);
551+
return PTR_ERR(fwnode);
552+
}
553+
554+
ret = device_add_software_node(codec_dev, to_software_node(fwnode));
555+
556+
fwnode_handle_put(fwnode);
557+
547558
if (ret) {
548559
put_device(codec_dev);
549560
return ret;
@@ -556,6 +567,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
556567
/* see comment in byt_cht_es8316_resume */
557568
GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
558569
put_device(codec_dev);
570+
priv->codec_dev = codec_dev;
559571

560572
if (IS_ERR(priv->speaker_en_gpio)) {
561573
ret = PTR_ERR(priv->speaker_en_gpio);
@@ -567,7 +579,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
567579
dev_err(dev, "get speaker GPIO failed: %d\n", ret);
568580
fallthrough;
569581
case -EPROBE_DEFER:
570-
return ret;
582+
goto err;
571583
}
572584
}
573585

@@ -605,10 +617,15 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
605617
if (ret) {
606618
gpiod_put(priv->speaker_en_gpio);
607619
dev_err(dev, "snd_soc_register_card failed: %d\n", ret);
608-
return ret;
620+
goto err;
609621
}
610622
platform_set_drvdata(pdev, &byt_cht_es8316_card);
611623
return 0;
624+
625+
err:
626+
device_remove_software_node(priv->codec_dev);
627+
628+
return ret;
612629
}
613630

614631
static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev)
@@ -617,7 +634,10 @@ static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev)
617634
struct byt_cht_es8316_private *priv = snd_soc_card_get_drvdata(card);
618635

619636
gpiod_put(priv->speaker_en_gpio);
637+
device_remove_software_node(priv->codec_dev);
638+
620639
return 0;
640+
621641
}
622642

623643
static struct platform_driver snd_byt_cht_es8316_mc_driver = {

sound/soc/intel/boards/bytcr_rt5640.c

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ enum {
8787
struct byt_rt5640_private {
8888
struct snd_soc_jack jack;
8989
struct clk *mclk;
90+
struct device *codec_dev;
9091
};
9192
static bool is_bytcr;
9293

@@ -912,9 +913,11 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
912913
* Note this MUST be called before snd_soc_register_card(), so that the props
913914
* are in place before the codec component driver's probe function parses them.
914915
*/
915-
static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)
916+
static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name,
917+
struct byt_rt5640_private *priv)
916918
{
917919
struct property_entry props[MAX_NO_PROPS] = {};
920+
struct fwnode_handle *fwnode;
918921
struct device *i2c_dev;
919922
int ret, cnt = 0;
920923

@@ -960,7 +963,18 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)
960963
if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV)
961964
props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted");
962965

963-
ret = device_add_properties(i2c_dev, props);
966+
fwnode = fwnode_create_software_node(props, NULL);
967+
if (IS_ERR(fwnode)) {
968+
/* put_device() is not handled in caller */
969+
put_device(i2c_dev);
970+
return PTR_ERR(fwnode);
971+
}
972+
973+
ret = device_add_software_node(i2c_dev, to_software_node(fwnode));
974+
975+
fwnode_handle_put(fwnode);
976+
priv->codec_dev = i2c_dev;
977+
964978
put_device(i2c_dev);
965979

966980
return ret;
@@ -1401,7 +1415,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
14011415
}
14021416

14031417
/* Must be called before register_card, also see declaration comment. */
1404-
ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name);
1418+
ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name, priv);
14051419
if (ret_val)
14061420
return ret_val;
14071421

@@ -1434,7 +1448,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
14341448
* for all other errors, including -EPROBE_DEFER
14351449
*/
14361450
if (ret_val != -ENOENT)
1437-
return ret_val;
1451+
goto err;
14381452
byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN;
14391453
}
14401454
}
@@ -1467,7 +1481,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
14671481
ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card,
14681482
platform_name);
14691483
if (ret_val)
1470-
return ret_val;
1484+
goto err;
14711485

14721486
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
14731487

@@ -1489,17 +1503,33 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
14891503
if (ret_val) {
14901504
dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
14911505
ret_val);
1492-
return ret_val;
1506+
goto err;
14931507
}
14941508
platform_set_drvdata(pdev, &byt_rt5640_card);
14951509
return ret_val;
1510+
1511+
err:
1512+
device_remove_software_node(priv->codec_dev);
1513+
1514+
return ret_val;
1515+
}
1516+
1517+
static int snd_byt_rt5640_mc_remove(struct platform_device *pdev)
1518+
{
1519+
struct snd_soc_card *card = platform_get_drvdata(pdev);
1520+
struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
1521+
1522+
device_remove_software_node(priv->codec_dev);
1523+
1524+
return 0;
14961525
}
14971526

14981527
static struct platform_driver snd_byt_rt5640_mc_driver = {
14991528
.driver = {
15001529
.name = "bytcr_rt5640",
15011530
},
15021531
.probe = snd_byt_rt5640_mc_probe,
1532+
.remove = snd_byt_rt5640_mc_remove
15031533
};
15041534

15051535
module_platform_driver(snd_byt_rt5640_mc_driver);

sound/soc/intel/boards/bytcr_rt5651.c

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct byt_rt5651_private {
8585
struct gpio_desc *ext_amp_gpio;
8686
struct gpio_desc *hp_detect;
8787
struct snd_soc_jack jack;
88+
struct device *codec_dev;
8889
};
8990

9091
static const struct acpi_gpio_mapping *byt_rt5651_gpios;
@@ -527,10 +528,13 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {
527528
* Note this MUST be called before snd_soc_register_card(), so that the props
528529
* are in place before the codec component driver's probe function parses them.
529530
*/
530-
static int byt_rt5651_add_codec_device_props(struct device *i2c_dev)
531+
static int byt_rt5651_add_codec_device_props(struct device *i2c_dev,
532+
struct byt_rt5651_private *priv)
531533
{
532534
struct property_entry props[MAX_NO_PROPS] = {};
535+
struct fwnode_handle *fwnode;
533536
int cnt = 0;
537+
int ret;
534538

535539
props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source",
536540
BYT_RT5651_JDSRC(byt_rt5651_quirk));
@@ -547,7 +551,18 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev)
547551
if (byt_rt5651_quirk & BYT_RT5651_JD_NOT_INV)
548552
props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted");
549553

550-
return device_add_properties(i2c_dev, props);
554+
fwnode = fwnode_create_software_node(props, NULL);
555+
if (IS_ERR(fwnode)) {
556+
/* put_device(i2c_dev) is handled in caller */
557+
return PTR_ERR(fwnode);
558+
}
559+
560+
ret = device_add_software_node(i2c_dev, to_software_node(fwnode));
561+
562+
fwnode_handle_put(fwnode);
563+
priv->codec_dev = i2c_dev;
564+
565+
return ret;
551566
}
552567

553568
static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
@@ -994,7 +1009,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
9941009
}
9951010

9961011
/* Must be called before register_card, also see declaration comment. */
997-
ret_val = byt_rt5651_add_codec_device_props(codec_dev);
1012+
ret_val = byt_rt5651_add_codec_device_props(codec_dev, priv);
9981013
if (ret_val) {
9991014
put_device(codec_dev);
10001015
return ret_val;
@@ -1023,7 +1038,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
10231038
fallthrough;
10241039
case -EPROBE_DEFER:
10251040
put_device(codec_dev);
1026-
return ret_val;
1041+
goto err;
10271042
}
10281043
}
10291044
priv->hp_detect = devm_fwnode_gpiod_get(&pdev->dev,
@@ -1043,7 +1058,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
10431058
fallthrough;
10441059
case -EPROBE_DEFER:
10451060
put_device(codec_dev);
1046-
return ret_val;
1061+
goto err;
10471062
}
10481063
}
10491064
}
@@ -1073,7 +1088,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
10731088
* for all other errors, including -EPROBE_DEFER
10741089
*/
10751090
if (ret_val != -ENOENT)
1076-
return ret_val;
1091+
goto err;
10771092
byt_rt5651_quirk &= ~BYT_RT5651_MCLK_EN;
10781093
}
10791094
}
@@ -1102,7 +1117,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
11021117
ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5651_card,
11031118
platform_name);
11041119
if (ret_val)
1105-
return ret_val;
1120+
goto err;
11061121

11071122
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
11081123

@@ -1124,17 +1139,33 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
11241139
if (ret_val) {
11251140
dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
11261141
ret_val);
1127-
return ret_val;
1142+
goto err;
11281143
}
11291144
platform_set_drvdata(pdev, &byt_rt5651_card);
11301145
return ret_val;
1146+
1147+
err:
1148+
device_remove_software_node(priv->codec_dev);
1149+
1150+
return ret_val;
1151+
}
1152+
1153+
static int snd_byt_rt5651_mc_remove(struct platform_device *pdev)
1154+
{
1155+
struct snd_soc_card *card = platform_get_drvdata(pdev);
1156+
struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
1157+
1158+
device_remove_software_node(priv->codec_dev);
1159+
1160+
return 0;
11311161
}
11321162

11331163
static struct platform_driver snd_byt_rt5651_mc_driver = {
11341164
.driver = {
11351165
.name = "bytcr_rt5651",
11361166
},
11371167
.probe = snd_byt_rt5651_mc_probe,
1168+
.remove = snd_byt_rt5651_mc_remove,
11381169
};
11391170

11401171
module_platform_driver(snd_byt_rt5651_mc_driver);

0 commit comments

Comments
 (0)