diff mbox series

[1/2] ALSA: core: add snd_device_init

Message ID 20230824210339.1126993-2-cujomalainey@chromium.org (mailing list archive)
State New, archived
Headers show
Series Refactor snd primitives refcounters | expand

Commit Message

Curtis Malainey Aug. 24, 2023, 9:02 p.m. UTC
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(-)

Comments

kernel test robot Aug. 24, 2023, 10:23 p.m. UTC | #1
Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on next-20230824]
[cannot apply to tiwai-sound/for-linus broonie-sound/for-next linus/master v6.5-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/cujomalainey-chromium-org/ALSA-core-add-snd_device_init/20230825-050745
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20230824210339.1126993-2-cujomalainey%40chromium.org
patch subject: [PATCH 1/2] ALSA: core: add snd_device_init
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230825/202308250609.8A2yaCZs-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230825/202308250609.8A2yaCZs-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308250609.8A2yaCZs-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> sound/core/init.c:149: warning: Function parameter or member 'dev' not described in 'snd_device_init'
>> sound/core/init.c:149: warning: Excess function parameter 'dev_p' description in 'snd_device_init'


vim +149 sound/core/init.c

   140	
   141	/**
   142	 * snd_device_init - Initialize struct device for sound devices
   143	 * @dev_p: pointer to store the allocated device
   144	 * @card: card to assign, optional
   145	 *
   146	 * For releasing the allocated device, call put_device().
   147	 */
   148	void snd_device_init(struct device *dev, struct snd_card *card)
 > 149	{
   150		device_initialize(dev);
   151		if (card)
   152			dev->parent = &card->card_dev;
   153		dev->class = &sound_class;
   154		dev->release = default_release_alloc;
   155	}
   156	EXPORT_SYMBOL_GPL(snd_device_init);
   157
Takashi Iwai Aug. 25, 2023, 10:46 a.m. UTC | #2
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
diff mbox series

Patch

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);
 
 static int snd_card_init(struct snd_card *card, struct device *parent,
 			 int idx, const char *xid, struct module *module,