Re: [PATCH] ALSA: Fix dynamic major number assignment
From: Takashi Iwai
Date: Wed Nov 25 2026 - 02:41:37 EST
On Wed, 25 Nov 2026 08:30:09 +0100,
Sreeraj S Kurup wrote:
>
> When major is set to 0, register_chrdev() allocates
> a major number and returns it.
>
> Store the allocated major number and update snd_major
> after successful registration.
>
> This ensures ALSA uses the correct major number for
> device registration and unregistration.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
We never thought of the dynamic major assignment there.
So major=0 should be treated simply as an error before passing to
register_chrdev().
Moreover, the current code was written before module_param_named() is
used widely, and that's why it has unnecessary assignments.
That is, we can drop major and cards_limit variables, and directly use
snd_major and snd_ecards_limit with initialization and
module_param_named().
thanks,
Takashi