libnvdimm/pmem: Advance namespace seed for specific probe errors
[linux-2.6-block.git] / sound / isa / adlib.c
CommitLineData
09c434b8 1// SPDX-License-Identifier: GPL-2.0-only
cf40a310
RH
2/*
3 * AdLib FM card driver.
4 */
5
cf40a310
RH
6#include <linux/kernel.h>
7#include <linux/module.h>
ab7942b2 8#include <linux/isa.h>
cf40a310
RH
9#include <sound/core.h>
10#include <sound/initval.h>
11#include <sound/opl3.h>
12
13#define CRD_NAME "AdLib FM"
ab7942b2 14#define DEV_NAME "adlib"
cf40a310
RH
15
16MODULE_DESCRIPTION(CRD_NAME);
17MODULE_AUTHOR("Rene Herman");
18MODULE_LICENSE("GPL");
19
20static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
21static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
a67ff6a5 22static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;
cf40a310
RH
23static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
24
25module_param_array(index, int, NULL, 0444);
26MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
27module_param_array(id, charp, NULL, 0444);
28MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
29module_param_array(enable, bool, NULL, 0444);
30MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
e992ef57 31module_param_hw_array(port, long, ioport, NULL, 0444);
cf40a310
RH
32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
33
1bff292e 34static int snd_adlib_match(struct device *dev, unsigned int n)
ab7942b2
RH
35{
36 if (!enable[n])
37 return 0;
38
39 if (port[n] == SNDRV_AUTO_PORT) {
0418ff0c 40 dev_err(dev, "please specify port\n");
ab7942b2
RH
41 return 0;
42 }
43 return 1;
44}
cf40a310
RH
45
46static void snd_adlib_free(struct snd_card *card)
47{
48 release_and_free_resource(card->private_data);
49}
50
1bff292e 51static int snd_adlib_probe(struct device *dev, unsigned int n)
cf40a310
RH
52{
53 struct snd_card *card;
54 struct snd_opl3 *opl3;
ab7942b2 55 int error;
cf40a310 56
4323cc4d 57 error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card);
c95eadd2 58 if (error < 0) {
0418ff0c 59 dev_err(dev, "could not create card\n");
c95eadd2 60 return error;
cf40a310
RH
61 }
62
ab7942b2 63 card->private_data = request_region(port[n], 4, CRD_NAME);
cf40a310 64 if (!card->private_data) {
0418ff0c 65 dev_err(dev, "could not grab ports\n");
cf40a310 66 error = -EBUSY;
ab7942b2 67 goto out;
cf40a310
RH
68 }
69 card->private_free = snd_adlib_free;
70
ab7942b2
RH
71 strcpy(card->driver, DEV_NAME);
72 strcpy(card->shortname, CRD_NAME);
73 sprintf(card->longname, CRD_NAME " at %#lx", port[n]);
74
75 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
cf40a310 76 if (error < 0) {
0418ff0c 77 dev_err(dev, "could not create OPL\n");
ab7942b2 78 goto out;
cf40a310
RH
79 }
80
81 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
82 if (error < 0) {
0418ff0c 83 dev_err(dev, "could not create FM\n");
ab7942b2 84 goto out;
cf40a310
RH
85 }
86
cf40a310
RH
87 error = snd_card_register(card);
88 if (error < 0) {
0418ff0c 89 dev_err(dev, "could not register card\n");
ab7942b2 90 goto out;
cf40a310
RH
91 }
92
ab7942b2 93 dev_set_drvdata(dev, card);
cf40a310
RH
94 return 0;
95
ab7942b2
RH
96out: snd_card_free(card);
97 return error;
cf40a310
RH
98}
99
1bff292e 100static int snd_adlib_remove(struct device *dev, unsigned int n)
cf40a310 101{
ab7942b2 102 snd_card_free(dev_get_drvdata(dev));
cf40a310
RH
103 return 0;
104}
105
ab7942b2
RH
106static struct isa_driver snd_adlib_driver = {
107 .match = snd_adlib_match,
cf40a310 108 .probe = snd_adlib_probe,
1bff292e 109 .remove = snd_adlib_remove,
cf40a310
RH
110
111 .driver = {
ab7942b2 112 .name = DEV_NAME
cf40a310
RH
113 }
114};
115
1524c719 116module_isa_driver(snd_adlib_driver, SNDRV_CARDS);