2

I'm specifically asking about CONFIG_SND_MAX_CARDS in the kernel.

From the code using this config, for example in sound/usb/card.c for USB cards, soundcards are stored in plain arrays which are looped over.

Why does the kernel not use lists and have an unlimited number of soundcards?

I know unlimited is not possible because of hardware reasons (numbers of slots in the bus etc.), but having a dynamically allocated implementation would at least save users the hassle of specifying a maximum number at compile time.

Any ideas?

  • 2
    Plain arrays are straightforward and don't incur much overhead (in memory or in code complexity); lists are more complicated. I don't know whether the question has ever come up, but I'd imagine the amount of effort involved in switching to lists (and the continued maintenance burden thereafter) isn't worth it given the limited number of people who'd need more than 8 sound cards... – Stephen Kitt Jan 15 '16 at 12:57
2

In the good old times of ISA sound cards, it was not possible to create device nodes in /dev/ dynamically, so all devices had to be preallocated. This resulted in a limit of 8 sound cards, and the drivers were written with this limit in mind.

Later, when devfs and USB were introduced, this limit was removed. However, the easiest way to do this was to make the minimum amount of changes, i.e., to just change the upper limit.

Rewriting the code to allow an infinite number of cards would have been a lot of effort without any concrete benefit. (It is possible to increase the current default of 32 with a kernel configuration option, but people who try that usually find out that they do not have enough USB bandwith for that many devices.)

|improve this answer|||||
  • Would it be correct to clasify this as "technical debt"? – gimmesudo Jan 15 '16 at 22:00
  • "Debt" implies that the current implementation has a downside. If you have a system where having more than 32 cards actually makes sense,I'd like to see it. – CL. Jan 16 '16 at 0:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.