After all components are assigned, register the card instance
by calling snd_card_register()
. Access
to the device files is enabled at this point. That is, before
snd_card_register()
is called, the
components are safely inaccessible from external side. If this
call fails, exit the probe function after releasing the card via
snd_card_free()
.
For releasing the card instance, you can call simply
snd_card_free()
. As mentioned earlier, all
components are released automatically by this call.
As further notes, the destructors (both
snd_mychip_dev_free
and
snd_mychip_free
) cannot be defined with
the __devexit
prefix, because they may be
called from the constructor, too, at the false path.
For a device which allows hotplugging, you can use
snd_card_free_when_closed
. This one will
postpone the destruction until all devices are closed.