mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
ALSA: adlib: Allocate resources with device-managed APIs
This patch converts the resource management in ISA adlib driver with devres as a clean up. Each manual resource management is converted with the corresponding devres helper. The remove callback became superfluous and dropped. This should give no user-visible functional changes. Link: https://lore.kernel.org/r/20210715075941.23332-57-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
e031577eef
commit
5d50e348a4
@ -43,30 +43,23 @@ static int snd_adlib_match(struct device *dev, unsigned int n)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void snd_adlib_free(struct snd_card *card)
|
||||
{
|
||||
release_and_free_resource(card->private_data);
|
||||
}
|
||||
|
||||
static int snd_adlib_probe(struct device *dev, unsigned int n)
|
||||
{
|
||||
struct snd_card *card;
|
||||
struct snd_opl3 *opl3;
|
||||
int error;
|
||||
|
||||
error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
|
||||
error = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "could not create card\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
card->private_data = request_region(port[n], 4, CRD_NAME);
|
||||
card->private_data = devm_request_region(dev, port[n], 4, CRD_NAME);
|
||||
if (!card->private_data) {
|
||||
dev_err(dev, "could not grab ports\n");
|
||||
error = -EBUSY;
|
||||
goto out;
|
||||
return -EBUSY;
|
||||
}
|
||||
card->private_free = snd_adlib_free;
|
||||
|
||||
strcpy(card->driver, DEV_NAME);
|
||||
strcpy(card->shortname, CRD_NAME);
|
||||
@ -75,37 +68,28 @@ static int snd_adlib_probe(struct device *dev, unsigned int n)
|
||||
error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "could not create OPL\n");
|
||||
goto out;
|
||||
return error;
|
||||
}
|
||||
|
||||
error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "could not create FM\n");
|
||||
goto out;
|
||||
return error;
|
||||
}
|
||||
|
||||
error = snd_card_register(card);
|
||||
if (error < 0) {
|
||||
dev_err(dev, "could not register card\n");
|
||||
goto out;
|
||||
return error;
|
||||
}
|
||||
|
||||
dev_set_drvdata(dev, card);
|
||||
return 0;
|
||||
|
||||
out: snd_card_free(card);
|
||||
return error;
|
||||
}
|
||||
|
||||
static void snd_adlib_remove(struct device *dev, unsigned int n)
|
||||
{
|
||||
snd_card_free(dev_get_drvdata(dev));
|
||||
}
|
||||
|
||||
static struct isa_driver snd_adlib_driver = {
|
||||
.match = snd_adlib_match,
|
||||
.probe = snd_adlib_probe,
|
||||
.remove = snd_adlib_remove,
|
||||
|
||||
.driver = {
|
||||
.name = DEV_NAME
|
||||
|
Loading…
Reference in New Issue
Block a user