From: Jaroslav Kysela <perex@perex.cz>
To: Maciej Strozek <mstrozek@opensource.cirrus.com>,
Takashi Iwai <tiwai@suse.de>
Cc: ALSA development <alsa-devel@alsa-project.org>,
patches@opensource.cirrus.com,
"linux-sound@vger.kernel.org" <linux-sound@vger.kernel.org>,
Kernel development <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: sound: Increase max size of components field
Date: Tue, 28 Oct 2025 12:39:38 +0100 [thread overview]
Message-ID: <9b05914d-34f0-4149-b715-b4af6bba6701@perex.cz> (raw)
In-Reply-To: <3cb73dae8e8ac1a29c856dc5c86064d568003316.camel@opensource.cirrus.com>
On 10/27/25 12:50, Maciej Strozek wrote:
> W dniu pon, 27.10.2025 o godzinie 10∶04 +0100, użytkownik Takashi Iwai
> napisał:
>> On Thu, 23 Oct 2025 13:56:26 +0200,
>> Jaroslav Kysela wrote:
>>>
>>> Or, we may introduce a separate ioctl for the components string.
>>> The
>>> stripped components string in struct snd_ctl_card_info may have a
>>> special ASCII mark like '>' at the end of string specifying the
>>> availability of the complete string through another ioctl. I would
>>> prefer this solution.
>>>
>>> Also, the components string may be dynamic in the kernel structure
>>> (pointer) to save some space. 256 bytes is not small number.
>>
>> As Jaroslav suggested, we need a different solution to keep the
>> compatibility.
>>
>> My gut feeling is for the option to provide a new ioctl as it can be
>> most straightforward, but we can discuss further which is the good
>> choice.
>>
>
> Thank you for the advice! Not sure if I understand Jaroslav's new ioctl
> approach properly, can you have a look at the quick draft below and say
> if this is (more or less) what you would expect? If it is OK then I
> will prepare a proper V2 patch here with a corresponding change for
> alsa-lib repo too.
>
>
> diff --git a/include/sound/core.h b/include/sound/core.h
> index 0eb2e3ee0dd5..c4e52fb1704b 100644
> --- a/include/sound/core.h
> +++ b/include/sound/core.h
> @@ -88,7 +88,9 @@ struct snd_card {
> char irq_descr[32]; /* Interrupt description */
> char mixername[80]; /* mixer name */
> char components[256]; /* card components delimited
> with
> - space
> */
> + space */
> + char *components_pointer; /* full components string */
Keep only this, remove the array and don't use the length member (null
terminated string).
> + size_t components_pointer_len; /* length of full components
> string */
> struct module *module; /* top-level module */
>
> void *private_data; /* private data for soundcard
> */
> @@ -297,6 +299,7 @@ int snd_card_info_init(void);
> int snd_card_add_dev_attr(struct snd_card *card,
> const struct attribute_group *group);
> int snd_component_add(struct snd_card *card, const char *component);
> +int snd_card_add_components(struct snd_card *card, const char
> *component);
> int snd_card_file_add(struct snd_card *card, struct file *file);
> int snd_card_file_remove(struct snd_card *card, struct file *file);
>
> diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
> index c302698fb685..7d53f6da59e2 100644
> --- a/include/uapi/sound/asound.h
> +++ b/include/uapi/sound/asound.h
...
> +struct snd_ctl_card_components {
> + int len;
> + unsigned char *components;
> };
Use array here. It makes things simpler. Perhaps, we can use 512 bytes /
characters here to avoid future problems.
> int snd_component_add(struct snd_card *card, const char *component)
> {
> char *ptr;
> int len = strlen(component);
> + int new_len;
> + char *buffer;
>
> ptr = strstr(card->components, component);
> if (ptr != NULL) {
> @@ -1035,8 +1040,28 @@ int snd_component_add(struct snd_card *card,
> const char *component)
> return 1;
> }
> if (strlen(card->components) + 1 + len + 1 > sizeof(card-
>> components)) {
I don't think that it's the right place to do the striping here. Just keep the
full string in snd_card structure and handle the split/trim in
snd_ctl_card_info().
The new ioctl should return the full components string.
Jaroslav
--
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
prev parent reply other threads:[~2025-10-28 11:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 9:27 Maciej Strozek
2025-10-23 11:56 ` Jaroslav Kysela
2025-10-27 9:04 ` Takashi Iwai
2025-10-27 11:50 ` Maciej Strozek
2025-10-27 12:32 ` Richard Fitzgerald
2025-10-28 0:42 ` Takashi Sakamoto
2025-10-28 11:14 ` Maciej Strozek
2025-10-28 11:39 ` Jaroslav Kysela [this message]
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=9b05914d-34f0-4149-b715-b4af6bba6701@perex.cz \
--to=perex@perex.cz \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mstrozek@opensource.cirrus.com \
--cc=patches@opensource.cirrus.com \
--cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®