diff options
author | Mark Brown <broonie@linaro.org> | 2014-04-18 13:00:30 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-04-18 13:00:30 -0400 |
commit | 3819bfa23786fd1e8571fbb143e1b0b8f0fead86 (patch) | |
tree | 5620fc0d02dddd1e9f460d9875d5232c232c78b8 | |
parent | b2e69054ea1a36f2c1ace15a55240937aa091cba (diff) | |
parent | 8931bf6208776292b1b888dd8534229f63e2eaa2 (diff) |
Merge branch 'topic/devm' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-omap
-rw-r--r-- | include/sound/soc.h | 2 | ||||
-rw-r--r-- | sound/soc/soc-devres.c | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..34c34d6e095c 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -377,6 +377,8 @@ int snd_soc_resume(struct device *dev); | |||
377 | int snd_soc_poweroff(struct device *dev); | 377 | int snd_soc_poweroff(struct device *dev); |
378 | int snd_soc_register_platform(struct device *dev, | 378 | int snd_soc_register_platform(struct device *dev, |
379 | const struct snd_soc_platform_driver *platform_drv); | 379 | const struct snd_soc_platform_driver *platform_drv); |
380 | int devm_snd_soc_register_platform(struct device *dev, | ||
381 | const struct snd_soc_platform_driver *platform_drv); | ||
380 | void snd_soc_unregister_platform(struct device *dev); | 382 | void snd_soc_unregister_platform(struct device *dev); |
381 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | 383 | int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, |
382 | const struct snd_soc_platform_driver *platform_drv); | 384 | const struct snd_soc_platform_driver *platform_drv); |
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index 7ac745df1412..e94aa0277250 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c | |||
@@ -52,6 +52,40 @@ int devm_snd_soc_register_component(struct device *dev, | |||
52 | } | 52 | } |
53 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); | 53 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); |
54 | 54 | ||
55 | static void devm_platform_release(struct device *dev, void *res) | ||
56 | { | ||
57 | snd_soc_unregister_platform(*(struct device **)res); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * devm_snd_soc_register_platform - resource managed platform registration | ||
62 | * @dev: Device used to manage platform | ||
63 | * @platform: platform to register | ||
64 | * | ||
65 | * Register a platform driver with automatic unregistration when the device is | ||
66 | * unregistered. | ||
67 | */ | ||
68 | int devm_snd_soc_register_platform(struct device *dev, | ||
69 | const struct snd_soc_platform_driver *platform_drv) | ||
70 | { | ||
71 | struct device **ptr; | ||
72 | int ret; | ||
73 | |||
74 | ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL); | ||
75 | if (!ptr) | ||
76 | return -ENOMEM; | ||
77 | |||
78 | ret = snd_soc_register_platform(dev, platform_drv); | ||
79 | if (ret == 0) { | ||
80 | *ptr = dev; | ||
81 | devres_add(dev, ptr); | ||
82 | } else { | ||
83 | devres_free(ptr); | ||
84 | } | ||
85 | |||
86 | return ret; | ||
87 | } | ||
88 | |||
55 | static void devm_card_release(struct device *dev, void *res) | 89 | static void devm_card_release(struct device *dev, void *res) |
56 | { | 90 | { |
57 | snd_soc_unregister_card(*(struct snd_soc_card **)res); | 91 | snd_soc_unregister_card(*(struct snd_soc_card **)res); |