Skip to content

Commit 18abb37

Browse files
sudeep-hollabroonie
authored andcommitted
ASoC: soc-utils: Transition to the faux device interface
The ASoC soc-utils driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the driver to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will simplify the code, reducing its footprint while maintaining functionality. Cc: Mark Brown <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: [email protected] Signed-off-by: Sudeep Holla <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 77ad261 commit 18abb37

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

sound/soc/soc-utils.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Author: Mark Brown <[email protected]>
88
// Liam Girdwood <[email protected]>
99

10-
#include <linux/platform_device.h>
10+
#include <linux/device/faux.h>
1111
#include <linux/export.h>
1212
#include <linux/math.h>
1313
#include <sound/core.h>
@@ -262,48 +262,38 @@ struct snd_soc_dai_link_component snd_soc_dummy_dlc = {
262262
};
263263
EXPORT_SYMBOL_GPL(snd_soc_dummy_dlc);
264264

265-
static int snd_soc_dummy_probe(struct platform_device *pdev)
265+
static int snd_soc_dummy_probe(struct faux_device *fdev)
266266
{
267267
int ret;
268268

269-
ret = devm_snd_soc_register_component(&pdev->dev,
269+
ret = devm_snd_soc_register_component(&fdev->dev,
270270
&dummy_codec, &dummy_dai, 1);
271271
if (ret < 0)
272272
return ret;
273273

274-
ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform,
274+
ret = devm_snd_soc_register_component(&fdev->dev, &dummy_platform,
275275
NULL, 0);
276276

277277
return ret;
278278
}
279279

280-
static struct platform_driver soc_dummy_driver = {
281-
.driver = {
282-
.name = "snd-soc-dummy",
283-
},
280+
static struct faux_device_ops soc_dummy_ops = {
284281
.probe = snd_soc_dummy_probe,
285282
};
286283

287-
static struct platform_device *soc_dummy_dev;
284+
static struct faux_device *soc_dummy_dev;
288285

289286
int __init snd_soc_util_init(void)
290287
{
291-
int ret;
292-
293-
soc_dummy_dev =
294-
platform_device_register_simple("snd-soc-dummy", -1, NULL, 0);
295-
if (IS_ERR(soc_dummy_dev))
296-
return PTR_ERR(soc_dummy_dev);
288+
soc_dummy_dev = faux_device_create("snd-soc-dummy", NULL,
289+
&soc_dummy_ops);
290+
if (!soc_dummy_dev)
291+
return -ENODEV;
297292

298-
ret = platform_driver_register(&soc_dummy_driver);
299-
if (ret != 0)
300-
platform_device_unregister(soc_dummy_dev);
301-
302-
return ret;
293+
return 0;
303294
}
304295

305296
void snd_soc_util_exit(void)
306297
{
307-
platform_driver_unregister(&soc_dummy_driver);
308-
platform_device_unregister(soc_dummy_dev);
298+
faux_device_destroy(soc_dummy_dev);
309299
}

0 commit comments

Comments
 (0)