From: Takashi Iwai <tiwai@suse.de>
To: cujomalainey@chromium.org
Cc: alsa-devel@alsa-project.org, "Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Thierry Reding" <treding@nvidia.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Ivan Orlov" <ivan.orlov0322@gmail.com>
Subject: Re: [PATCH 1/2] ALSA: core: add snd_device_init
Date: Fri, 25 Aug 2023 12:46:17 +0200 [thread overview]
Message-ID: <87msyf762u.wl-tiwai@suse.de> (raw)
In-Reply-To: <20230824210339.1126993-2-cujomalainey@chromium.org>
On Thu, 24 Aug 2023 23:02:52 +0200,
cujomalainey@chromium.org wrote:
>
> From: Curtis Malainey <cujomalainey@chromium.org>
>
> Begin allowing refactored modules to allocate their own device but use a
> common initialization procedure for their devices.
>
> Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
> ---
> include/sound/core.h | 1 +
> sound/core/init.c | 19 ++++++++++++++++---
> 2 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/include/sound/core.h b/include/sound/core.h
> index dfef0c9d4b9f7..a4744e142c7e3 100644
> --- a/include/sound/core.h
> +++ b/include/sound/core.h
> @@ -240,6 +240,7 @@ extern struct dentry *sound_debugfs_root;
> void snd_request_card(int card);
>
> int snd_device_alloc(struct device **dev_p, struct snd_card *card);
> +void snd_device_init(struct device *dev, struct snd_card *card);
>
> int snd_register_device(int type, struct snd_card *card, int dev,
> const struct file_operations *f_ops,
> diff --git a/sound/core/init.c b/sound/core/init.c
> index d61bde1225f23..37a8e4791f781 100644
> --- a/sound/core/init.c
> +++ b/sound/core/init.c
> @@ -132,15 +132,28 @@ int snd_device_alloc(struct device **dev_p, struct snd_card *card)
> dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> if (!dev)
> return -ENOMEM;
> + snd_device_init(dev, card);
> + *dev_p = dev;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_device_alloc);
> +
> +/**
> + * snd_device_init - Initialize struct device for sound devices
> + * @dev_p: pointer to store the allocated device
> + * @card: card to assign, optional
> + *
> + * For releasing the allocated device, call put_device().
> + */
> +void snd_device_init(struct device *dev, struct snd_card *card)
> +{
> device_initialize(dev);
> if (card)
> dev->parent = &card->card_dev;
> dev->class = &sound_class;
> dev->release = default_release_alloc;
> - *dev_p = dev;
> - return 0;
> }
> -EXPORT_SYMBOL_GPL(snd_device_alloc);
> +EXPORT_SYMBOL_GPL(snd_device_init);
This will call kfree() at the default release. It should be avoided
for this case, no?
Also, it's worth that this practically a kind of revive of the old API
that was dropped in the commit 01ed7f3535a2.
thanks,
Takashi
next prev parent reply other threads:[~2023-08-25 10:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 21:02 [PATCH 0/2][RFC] Refactor snd primitives refcounters cujomalainey
2023-08-24 21:02 ` [PATCH 1/2] ALSA: core: add snd_device_init cujomalainey
2023-08-24 22:23 ` kernel test robot
2023-08-25 10:46 ` Takashi Iwai [this message]
2023-08-24 21:02 ` [PATCH 2/2] ALSA: core: split control primitives out of snd_card cujomalainey
2023-08-24 21:15 ` Mark Brown
2023-08-25 10:57 ` Takashi Iwai
2023-09-03 22:38 ` kernel test robot
2023-08-25 11:15 ` [PATCH 0/2][RFC] Refactor snd primitives refcounters Takashi Iwai
2023-08-25 17:42 ` Curtis Malainey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87msyf762u.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=cujomalainey@chromium.org \
--cc=ivan.orlov0322@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=treding@nvidia.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.