* [PATCH] ASoC: Dynamically allocate the rtd device for a non-empty release
@ 2012-01-09 7:02 Mark Brown
2012-01-09 10:14 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2012-01-09 7:02 UTC (permalink / raw)
To: Greg KH, Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
Greg, you asked for this to be included in 3.3 but I really don't see
any reason for doing so - this isn't exactly new code and there aren't
any practical issues being reported. Is there any actual rush?
include/sound/soc.h | 6 +++---
sound/soc/soc-core.c | 34 +++++++++++++++++++++-------------
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index a7425e9..0a56767 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -862,7 +862,7 @@ struct snd_soc_card {
/* SoC machine DAI configuration, glues a codec and cpu DAI together */
struct snd_soc_pcm_runtime {
- struct device dev;
+ struct device *dev;
struct snd_soc_card *card;
struct snd_soc_dai_link *dai_link;
struct mutex pcm_mutex;
@@ -954,12 +954,12 @@ static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platfo
static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
void *data)
{
- dev_set_drvdata(&rtd->dev, data);
+ dev_set_drvdata(rtd->dev, data);
}
static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
{
- return dev_get_drvdata(&rtd->dev);
+ return dev_get_drvdata(rtd->dev);
}
static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index dcc4b62..9d8a631 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -884,9 +884,9 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num, int order)
/* unregister the rtd device */
if (rtd->dev_registered) {
- device_remove_file(&rtd->dev, &dev_attr_pmdown_time);
- device_remove_file(&rtd->dev, &dev_attr_codec_reg);
- device_unregister(&rtd->dev);
+ device_remove_file(rtd->dev, &dev_attr_pmdown_time);
+ device_remove_file(rtd->dev, &dev_attr_codec_reg);
+ device_unregister(rtd->dev);
rtd->dev_registered = 0;
}
@@ -1061,7 +1061,10 @@ err_probe:
return ret;
}
-static void rtd_release(struct device *dev) {}
+static void rtd_release(struct device *dev)
+{
+ kfree(dev);
+}
static int soc_post_component_init(struct snd_soc_card *card,
struct snd_soc_codec *codec,
@@ -1104,11 +1107,16 @@ static int soc_post_component_init(struct snd_soc_card *card,
/* register the rtd device */
rtd->codec = codec;
- rtd->dev.parent = card->dev;
- rtd->dev.release = rtd_release;
- rtd->dev.init_name = name;
+
+ rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
+ if (!rtd->dev)
+ return -ENOMEM;
+ device_initialize(rtd->dev);
+ rtd->dev->parent = card->dev;
+ rtd->dev->release = rtd_release;
+ rtd->dev->init_name = name;
mutex_init(&rtd->pcm_mutex);
- ret = device_register(&rtd->dev);
+ ret = device_add(rtd->dev);
if (ret < 0) {
dev_err(card->dev,
"asoc: failed to register runtime device: %d\n", ret);
@@ -1117,14 +1125,14 @@ static int soc_post_component_init(struct snd_soc_card *card,
rtd->dev_registered = 1;
/* add DAPM sysfs entries for this codec */
- ret = snd_soc_dapm_sys_add(&rtd->dev);
+ ret = snd_soc_dapm_sys_add(rtd->dev);
if (ret < 0)
dev_err(codec->dev,
"asoc: failed to add codec dapm sysfs entries: %d\n",
ret);
/* add codec sysfs entries */
- ret = device_create_file(&rtd->dev, &dev_attr_codec_reg);
+ ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
if (ret < 0)
dev_err(codec->dev,
"asoc: failed to add codec sysfs files: %d\n", ret);
@@ -1213,7 +1221,7 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order)
if (ret)
return ret;
- ret = device_create_file(&rtd->dev, &dev_attr_pmdown_time);
+ ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
if (ret < 0)
printk(KERN_WARNING "asoc: failed to add pmdown_time sysfs\n");
@@ -1311,8 +1319,8 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
/* unregister the rtd device */
if (rtd->dev_registered) {
- device_remove_file(&rtd->dev, &dev_attr_codec_reg);
- device_unregister(&rtd->dev);
+ device_remove_file(rtd->dev, &dev_attr_codec_reg);
+ device_del(rtd->dev);
rtd->dev_registered = 0;
}
--
1.7.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Dynamically allocate the rtd device for a non-empty release
2012-01-09 7:02 [PATCH] ASoC: Dynamically allocate the rtd device for a non-empty release Mark Brown
@ 2012-01-09 10:14 ` Takashi Iwai
2012-01-09 21:14 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2012-01-09 10:14 UTC (permalink / raw)
To: Mark Brown; +Cc: Greg KH, alsa-devel, patches, Liam Girdwood
At Sun, 8 Jan 2012 23:02:30 -0800,
Mark Brown wrote:
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>
> Greg, you asked for this to be included in 3.3 but I really don't see
> any reason for doing so - this isn't exactly new code and there aren't
> any practical issues being reported. Is there any actual rush?
Since it's no urgent fix, rc1 is the best merge point. Of course, I
know it's a bit too late for merge, but the code doesn't look so
awfully intrusive. So, I find it's OK.
thanks,
Takashi
>
> include/sound/soc.h | 6 +++---
> sound/soc/soc-core.c | 34 +++++++++++++++++++++-------------
> 2 files changed, 24 insertions(+), 16 deletions(-)
>
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index a7425e9..0a56767 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -862,7 +862,7 @@ struct snd_soc_card {
>
> /* SoC machine DAI configuration, glues a codec and cpu DAI together */
> struct snd_soc_pcm_runtime {
> - struct device dev;
> + struct device *dev;
> struct snd_soc_card *card;
> struct snd_soc_dai_link *dai_link;
> struct mutex pcm_mutex;
> @@ -954,12 +954,12 @@ static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platfo
> static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
> void *data)
> {
> - dev_set_drvdata(&rtd->dev, data);
> + dev_set_drvdata(rtd->dev, data);
> }
>
> static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
> {
> - return dev_get_drvdata(&rtd->dev);
> + return dev_get_drvdata(rtd->dev);
> }
>
> static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index dcc4b62..9d8a631 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -884,9 +884,9 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num, int order)
>
> /* unregister the rtd device */
> if (rtd->dev_registered) {
> - device_remove_file(&rtd->dev, &dev_attr_pmdown_time);
> - device_remove_file(&rtd->dev, &dev_attr_codec_reg);
> - device_unregister(&rtd->dev);
> + device_remove_file(rtd->dev, &dev_attr_pmdown_time);
> + device_remove_file(rtd->dev, &dev_attr_codec_reg);
> + device_unregister(rtd->dev);
> rtd->dev_registered = 0;
> }
>
> @@ -1061,7 +1061,10 @@ err_probe:
> return ret;
> }
>
> -static void rtd_release(struct device *dev) {}
> +static void rtd_release(struct device *dev)
> +{
> + kfree(dev);
> +}
>
> static int soc_post_component_init(struct snd_soc_card *card,
> struct snd_soc_codec *codec,
> @@ -1104,11 +1107,16 @@ static int soc_post_component_init(struct snd_soc_card *card,
>
> /* register the rtd device */
> rtd->codec = codec;
> - rtd->dev.parent = card->dev;
> - rtd->dev.release = rtd_release;
> - rtd->dev.init_name = name;
> +
> + rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
> + if (!rtd->dev)
> + return -ENOMEM;
> + device_initialize(rtd->dev);
> + rtd->dev->parent = card->dev;
> + rtd->dev->release = rtd_release;
> + rtd->dev->init_name = name;
> mutex_init(&rtd->pcm_mutex);
> - ret = device_register(&rtd->dev);
> + ret = device_add(rtd->dev);
> if (ret < 0) {
> dev_err(card->dev,
> "asoc: failed to register runtime device: %d\n", ret);
> @@ -1117,14 +1125,14 @@ static int soc_post_component_init(struct snd_soc_card *card,
> rtd->dev_registered = 1;
>
> /* add DAPM sysfs entries for this codec */
> - ret = snd_soc_dapm_sys_add(&rtd->dev);
> + ret = snd_soc_dapm_sys_add(rtd->dev);
> if (ret < 0)
> dev_err(codec->dev,
> "asoc: failed to add codec dapm sysfs entries: %d\n",
> ret);
>
> /* add codec sysfs entries */
> - ret = device_create_file(&rtd->dev, &dev_attr_codec_reg);
> + ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
> if (ret < 0)
> dev_err(codec->dev,
> "asoc: failed to add codec sysfs files: %d\n", ret);
> @@ -1213,7 +1221,7 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order)
> if (ret)
> return ret;
>
> - ret = device_create_file(&rtd->dev, &dev_attr_pmdown_time);
> + ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
> if (ret < 0)
> printk(KERN_WARNING "asoc: failed to add pmdown_time sysfs\n");
>
> @@ -1311,8 +1319,8 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
>
> /* unregister the rtd device */
> if (rtd->dev_registered) {
> - device_remove_file(&rtd->dev, &dev_attr_codec_reg);
> - device_unregister(&rtd->dev);
> + device_remove_file(rtd->dev, &dev_attr_codec_reg);
> + device_del(rtd->dev);
> rtd->dev_registered = 0;
> }
>
> --
> 1.7.7.3
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Dynamically allocate the rtd device for a non-empty release
2012-01-09 10:14 ` Takashi Iwai
@ 2012-01-09 21:14 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-01-09 21:14 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Greg KH, alsa-devel, patches, Liam Girdwood
On Mon, Jan 09, 2012 at 11:14:56AM +0100, Takashi Iwai wrote:
> Mark Brown wrote:
> > Greg, you asked for this to be included in 3.3 but I really don't see
> > any reason for doing so - this isn't exactly new code and there aren't
> > any practical issues being reported. Is there any actual rush?
> Since it's no urgent fix, rc1 is the best merge point. Of course, I
> know it's a bit too late for merge, but the code doesn't look so
> awfully intrusive. So, I find it's OK.
I'm still not thrilled by it but whatever.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-09 21:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 7:02 [PATCH] ASoC: Dynamically allocate the rtd device for a non-empty release Mark Brown
2012-01-09 10:14 ` Takashi Iwai
2012-01-09 21:14 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).