Message ID | 20230825222158.171007-2-oswald.buddenhagen@gmx.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ALSA: emu10k1: add support for high-bitrate modes of E-MU cards | expand |
Hi Oswald, kernel test robot noticed the following build warnings: [auto build test WARNING on c5baafafd8411c19e27c6a2c7237538a34b8ca31] url: https://github.com/intel-lab-lkp/linux/commits/Oswald-Buddenhagen/ALSA-add-snd_ctl_add_locked-export-snd_ctl_remove_locked/20230828-011105 base: c5baafafd8411c19e27c6a2c7237538a34b8ca31 patch link: https://lore.kernel.org/r/20230825222158.171007-2-oswald.buddenhagen%40gmx.de patch subject: [PATCH v5 1/8] ALSA: add snd_ctl_add_locked() & export snd_ctl_remove_locked() config: parisc-allyesconfig (https://download.01.org/0day-ci/archive/20230828/202308280222.TknsCq1k-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230828/202308280222.TknsCq1k-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/202308280222.TknsCq1k-lkp@intel.com/ All warnings (new ones prefixed by >>): >> sound/core/control.c:558: warning: Function parameter or member 'card' not described in 'snd_ctl_add_locked' >> sound/core/control.c:558: warning: Function parameter or member 'kcontrol' not described in 'snd_ctl_add_locked' >> sound/core/control.c:633: warning: Function parameter or member 'card' not described in 'snd_ctl_remove_locked' >> sound/core/control.c:633: warning: Function parameter or member 'kcontrol' not described in 'snd_ctl_remove_locked' vim +558 sound/core/control.c 552 553 /** 554 * snd_ctl_add_locked - same as snd_ctl_add(), but card->controls_rwsem 555 * is expected to be already locked if necessary. 556 */ 557 int snd_ctl_add_locked(struct snd_card *card, struct snd_kcontrol *kcontrol) > 558 { 559 return snd_ctl_add_replace_locked(card, kcontrol, CTL_ADD_EXCLUSIVE); 560 } 561 EXPORT_SYMBOL_GPL(snd_ctl_add_locked); 562 563 /** 564 * snd_ctl_add - add the control instance to the card 565 * @card: the card instance 566 * @kcontrol: the control instance to add 567 * 568 * Adds the control instance created via snd_ctl_new() or 569 * snd_ctl_new1() to the given card. Assigns also an unique 570 * numid used for fast search. 571 * 572 * It frees automatically the control which cannot be added. 573 * 574 * Return: Zero if successful, or a negative error code on failure. 575 * 576 */ 577 int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) 578 { 579 return snd_ctl_add_replace(card, kcontrol, CTL_ADD_EXCLUSIVE); 580 } 581 EXPORT_SYMBOL(snd_ctl_add); 582 583 /** 584 * snd_ctl_replace - replace the control instance of the card 585 * @card: the card instance 586 * @kcontrol: the control instance to replace 587 * @add_on_replace: add the control if not already added 588 * 589 * Replaces the given control. If the given control does not exist 590 * and the add_on_replace flag is set, the control is added. If the 591 * control exists, it is destroyed first. 592 * 593 * It frees automatically the control which cannot be added or replaced. 594 * 595 * Return: Zero if successful, or a negative error code on failure. 596 */ 597 int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, 598 bool add_on_replace) 599 { 600 return snd_ctl_add_replace(card, kcontrol, 601 add_on_replace ? CTL_ADD_ON_REPLACE : CTL_REPLACE); 602 } 603 EXPORT_SYMBOL(snd_ctl_replace); 604 605 static int __snd_ctl_remove(struct snd_card *card, 606 struct snd_kcontrol *kcontrol, 607 bool remove_hash) 608 { 609 unsigned int idx; 610 611 lockdep_assert_held_write(&card->controls_rwsem); 612 613 if (snd_BUG_ON(!card || !kcontrol)) 614 return -EINVAL; 615 list_del(&kcontrol->list); 616 617 if (remove_hash) 618 remove_hash_entries(card, kcontrol); 619 620 card->controls_count -= kcontrol->count; 621 for (idx = 0; idx < kcontrol->count; idx++) 622 snd_ctl_notify_one(card, SNDRV_CTL_EVENT_MASK_REMOVE, kcontrol, idx); 623 snd_ctl_free_one(kcontrol); 624 return 0; 625 } 626 627 /** 628 * snd_ctl_remove_locked - same as snd_ctl_remove(), but card->controls_rwsem 629 * is expected to be already locked if necessary. 630 */ 631 int snd_ctl_remove_locked(struct snd_card *card, 632 struct snd_kcontrol *kcontrol) > 633 { 634 return __snd_ctl_remove(card, kcontrol, true); 635 } 636 EXPORT_SYMBOL_GPL(snd_ctl_remove_locked); 637
diff --git a/include/sound/control.h b/include/sound/control.h index 9a4f4f7138da..7729b4ee1509 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -133,7 +133,9 @@ void snd_ctl_notify_one(struct snd_card * card, unsigned int mask, struct snd_kc struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data); void snd_ctl_free_one(struct snd_kcontrol * kcontrol); +int snd_ctl_add_locked(struct snd_card *card, struct snd_kcontrol *kcontrol); int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol); +int snd_ctl_remove_locked(struct snd_card *card, struct snd_kcontrol *kcontrol); int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol); int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace); int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id); diff --git a/sound/core/control.c b/sound/core/control.c index 59c8658966d4..9e807804e110 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -39,9 +39,6 @@ static LIST_HEAD(snd_control_compat_ioctls); #endif static struct snd_ctl_layer_ops *snd_ctl_layer; -static int snd_ctl_remove_locked(struct snd_card *card, - struct snd_kcontrol *kcontrol); - static int snd_ctl_open(struct inode *inode, struct file *file) { unsigned long flags; @@ -509,6 +506,27 @@ static int __snd_ctl_add_replace(struct snd_card *card, return 0; } +static int snd_ctl_add_replace_locked(struct snd_card *card, + struct snd_kcontrol *kcontrol, + enum snd_ctl_add_mode mode) +{ + int err = -EINVAL; + + if (! kcontrol) + return err; + if (snd_BUG_ON(!card || !kcontrol->info)) + goto error; + + err = __snd_ctl_add_replace(card, kcontrol, mode); + if (err < 0) + goto error; + return 0; + + error: + snd_ctl_free_one(kcontrol); + return err; +} + static int snd_ctl_add_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, enum snd_ctl_add_mode mode) @@ -532,6 +550,16 @@ static int snd_ctl_add_replace(struct snd_card *card, return err; } +/** + * snd_ctl_add_locked - same as snd_ctl_add(), but card->controls_rwsem + * is expected to be already locked if necessary. + */ +int snd_ctl_add_locked(struct snd_card *card, struct snd_kcontrol *kcontrol) +{ + return snd_ctl_add_replace_locked(card, kcontrol, CTL_ADD_EXCLUSIVE); +} +EXPORT_SYMBOL_GPL(snd_ctl_add_locked); + /** * snd_ctl_add - add the control instance to the card * @card: the card instance @@ -596,11 +624,16 @@ static int __snd_ctl_remove(struct snd_card *card, return 0; } -static inline int snd_ctl_remove_locked(struct snd_card *card, - struct snd_kcontrol *kcontrol) +/** + * snd_ctl_remove_locked - same as snd_ctl_remove(), but card->controls_rwsem + * is expected to be already locked if necessary. + */ +int snd_ctl_remove_locked(struct snd_card *card, + struct snd_kcontrol *kcontrol) { return __snd_ctl_remove(card, kcontrol, true); } +EXPORT_SYMBOL_GPL(snd_ctl_remove_locked); /** * snd_ctl_remove - remove the control from the card and release it
This will be used to dynamically change the available controls from another control's put() callback, which is already locked. One might want to add snd_ctl_replace_locked() for completeness, but I have no use for it now. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> --- applying this upstream would simplify applying the emu10k1 high bit-rate patchset locally, as it would limit the affected modules to the driver itself. v4: - adjust to recent locking changes - mark exports as internal v3: - fixed typo in commit message v2: - extended commit message --- include/sound/control.h | 2 ++ sound/core/control.c | 43 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-)