.. | .. |
---|
1052 | 1052 | } |
---|
1053 | 1053 | |
---|
1054 | 1054 | #ifdef CONFIG_PM_SLEEP |
---|
1055 | | -static int cygnus_ssp_suspend(struct snd_soc_dai *cpu_dai) |
---|
| 1055 | +static int __cygnus_ssp_suspend(struct snd_soc_dai *cpu_dai) |
---|
1056 | 1056 | { |
---|
1057 | 1057 | struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(cpu_dai); |
---|
| 1058 | + |
---|
| 1059 | + if (!snd_soc_dai_active(cpu_dai)) |
---|
| 1060 | + return 0; |
---|
1058 | 1061 | |
---|
1059 | 1062 | if (!aio->is_slave) { |
---|
1060 | 1063 | u32 val; |
---|
.. | .. |
---|
1078 | 1081 | return 0; |
---|
1079 | 1082 | } |
---|
1080 | 1083 | |
---|
1081 | | -static int cygnus_ssp_resume(struct snd_soc_dai *cpu_dai) |
---|
| 1084 | +static int cygnus_ssp_suspend(struct snd_soc_component *component) |
---|
| 1085 | +{ |
---|
| 1086 | + struct snd_soc_dai *dai; |
---|
| 1087 | + int ret = 0; |
---|
| 1088 | + |
---|
| 1089 | + for_each_component_dais(component, dai) |
---|
| 1090 | + ret |= __cygnus_ssp_suspend(dai); |
---|
| 1091 | + |
---|
| 1092 | + return ret; |
---|
| 1093 | +} |
---|
| 1094 | + |
---|
| 1095 | +static int __cygnus_ssp_resume(struct snd_soc_dai *cpu_dai) |
---|
1082 | 1096 | { |
---|
1083 | 1097 | struct cygnus_aio_port *aio = cygnus_dai_get_portinfo(cpu_dai); |
---|
1084 | 1098 | int error; |
---|
| 1099 | + |
---|
| 1100 | + if (!snd_soc_dai_active(cpu_dai)) |
---|
| 1101 | + return 0; |
---|
1085 | 1102 | |
---|
1086 | 1103 | if (!aio->is_slave) { |
---|
1087 | 1104 | if (aio->clk_trace.cap_clk_en) { |
---|
.. | .. |
---|
1109 | 1126 | |
---|
1110 | 1127 | return 0; |
---|
1111 | 1128 | } |
---|
| 1129 | + |
---|
| 1130 | +static int cygnus_ssp_resume(struct snd_soc_component *component) |
---|
| 1131 | +{ |
---|
| 1132 | + struct snd_soc_dai *dai; |
---|
| 1133 | + int ret = 0; |
---|
| 1134 | + |
---|
| 1135 | + for_each_component_dais(component, dai) |
---|
| 1136 | + ret |= __cygnus_ssp_resume(dai); |
---|
| 1137 | + |
---|
| 1138 | + return ret; |
---|
| 1139 | +} |
---|
| 1140 | + |
---|
1112 | 1141 | #else |
---|
1113 | 1142 | #define cygnus_ssp_suspend NULL |
---|
1114 | 1143 | #define cygnus_ssp_resume NULL |
---|
.. | .. |
---|
1149 | 1178 | SNDRV_PCM_FMTBIT_S32_LE, \ |
---|
1150 | 1179 | }, \ |
---|
1151 | 1180 | .ops = &cygnus_ssp_dai_ops, \ |
---|
1152 | | - .suspend = cygnus_ssp_suspend, \ |
---|
1153 | | - .resume = cygnus_ssp_resume, \ |
---|
1154 | 1181 | } |
---|
1155 | 1182 | |
---|
1156 | 1183 | static const struct snd_soc_dai_driver cygnus_ssp_dai_info[] = { |
---|
.. | .. |
---|
1169 | 1196 | SNDRV_PCM_FMTBIT_S32_LE, |
---|
1170 | 1197 | }, |
---|
1171 | 1198 | .ops = &cygnus_spdif_dai_ops, |
---|
1172 | | - .suspend = cygnus_ssp_suspend, |
---|
1173 | | - .resume = cygnus_ssp_resume, |
---|
1174 | 1199 | }; |
---|
1175 | 1200 | |
---|
1176 | 1201 | static struct snd_soc_dai_driver cygnus_ssp_dai[CYGNUS_MAX_PORTS]; |
---|
1177 | 1202 | |
---|
1178 | 1203 | static const struct snd_soc_component_driver cygnus_ssp_component = { |
---|
1179 | 1204 | .name = "cygnus-audio", |
---|
| 1205 | + .suspend = cygnus_ssp_suspend, |
---|
| 1206 | + .resume = cygnus_ssp_resume, |
---|
1180 | 1207 | }; |
---|
1181 | 1208 | |
---|
1182 | 1209 | /* |
---|
.. | .. |
---|
1334 | 1361 | cygaud->active_ports = 0; |
---|
1335 | 1362 | |
---|
1336 | 1363 | dev_dbg(dev, "Registering %d DAIs\n", active_port_count); |
---|
1337 | | - err = snd_soc_register_component(dev, &cygnus_ssp_component, |
---|
| 1364 | + err = devm_snd_soc_register_component(dev, &cygnus_ssp_component, |
---|
1338 | 1365 | cygnus_ssp_dai, active_port_count); |
---|
1339 | 1366 | if (err) { |
---|
1340 | 1367 | dev_err(dev, "snd_soc_register_dai failed\n"); |
---|
.. | .. |
---|
1342 | 1369 | } |
---|
1343 | 1370 | |
---|
1344 | 1371 | cygaud->irq_num = platform_get_irq(pdev, 0); |
---|
1345 | | - if (cygaud->irq_num <= 0) { |
---|
1346 | | - dev_err(dev, "platform_get_irq failed\n"); |
---|
1347 | | - err = cygaud->irq_num; |
---|
1348 | | - goto err_irq; |
---|
1349 | | - } |
---|
| 1372 | + if (cygaud->irq_num <= 0) |
---|
| 1373 | + return cygaud->irq_num; |
---|
1350 | 1374 | |
---|
1351 | 1375 | err = audio_clk_init(pdev, cygaud); |
---|
1352 | 1376 | if (err) { |
---|
1353 | 1377 | dev_err(dev, "audio clock initialization failed\n"); |
---|
1354 | | - goto err_irq; |
---|
| 1378 | + return err; |
---|
1355 | 1379 | } |
---|
1356 | 1380 | |
---|
1357 | 1381 | err = cygnus_soc_platform_register(dev, cygaud); |
---|
1358 | 1382 | if (err) { |
---|
1359 | 1383 | dev_err(dev, "platform reg error %d\n", err); |
---|
1360 | | - goto err_irq; |
---|
| 1384 | + return err; |
---|
1361 | 1385 | } |
---|
1362 | 1386 | |
---|
1363 | 1387 | return 0; |
---|
1364 | | - |
---|
1365 | | -err_irq: |
---|
1366 | | - snd_soc_unregister_component(dev); |
---|
1367 | | - return err; |
---|
1368 | 1388 | } |
---|
1369 | 1389 | |
---|
1370 | 1390 | static int cygnus_ssp_remove(struct platform_device *pdev) |
---|
1371 | 1391 | { |
---|
1372 | 1392 | cygnus_soc_platform_unregister(&pdev->dev); |
---|
1373 | | - snd_soc_unregister_component(&pdev->dev); |
---|
1374 | 1393 | |
---|
1375 | 1394 | return 0; |
---|
1376 | 1395 | } |
---|