ALSA: timer: fix NULL pointer dereference in read()/ioctl() race
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / pci / oxygen / virtuoso.c
CommitLineData
1b8ff22f
CL
1/*
2 * C-Media CMI8788 driver for Asus Xonar cards
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.
9 *
10 * This driver is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
1b8ff22f
CL
20#include <linux/pci.h>
21#include <linux/delay.h>
da155d5b 22#include <linux/module.h>
1b8ff22f
CL
23#include <sound/core.h>
24#include <sound/initval.h>
25#include <sound/pcm.h>
65c3ac88 26#include "xonar.h"
1b8ff22f
CL
27
28MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
45bc307f 29MODULE_DESCRIPTION("Asus Virtuoso driver");
d023dc0a 30MODULE_LICENSE("GPL v2");
45bc307f 31MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}");
1b8ff22f
CL
32
33static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
34static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
a67ff6a5 35static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
1b8ff22f
CL
36
37module_param_array(index, int, NULL, 0444);
38MODULE_PARM_DESC(index, "card index");
39module_param_array(id, charp, NULL, 0444);
40MODULE_PARM_DESC(id, "ID string");
41module_param_array(enable, bool, NULL, 0444);
42MODULE_PARM_DESC(enable, "enable card");
43
cebe41d4 44static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = {
65c3ac88
CL
45 { OXYGEN_PCI_SUBID(0x1043, 0x8269) },
46 { OXYGEN_PCI_SUBID(0x1043, 0x8275) },
47 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) },
48 { OXYGEN_PCI_SUBID(0x1043, 0x8314) },
49 { OXYGEN_PCI_SUBID(0x1043, 0x8327) },
50 { OXYGEN_PCI_SUBID(0x1043, 0x834f) },
51 { OXYGEN_PCI_SUBID(0x1043, 0x835c) },
52 { OXYGEN_PCI_SUBID(0x1043, 0x835d) },
2b830bae 53 { OXYGEN_PCI_SUBID(0x1043, 0x835e) },
d1db38c0 54 { OXYGEN_PCI_SUBID(0x1043, 0x838e) },
44923632 55 { OXYGEN_PCI_SUBID(0x1043, 0x8522) },
07a0ed1d 56 { OXYGEN_PCI_SUBID(0x1043, 0x85f4) },
30459d7b 57 { OXYGEN_PCI_SUBID_BROKEN_EEPROM },
1b8ff22f
CL
58 { }
59};
60MODULE_DEVICE_TABLE(pci, xonar_ids);
61
f120a6fb
BP
62static int get_xonar_model(struct oxygen *chip,
63 const struct pci_device_id *id)
1b8ff22f 64{
65c3ac88
CL
65 if (get_xonar_pcm179x_model(chip, id) >= 0)
66 return 0;
67 if (get_xonar_cs43xx_model(chip, id) >= 0)
68 return 0;
d1db38c0
CL
69 if (get_xonar_wm87x6_model(chip, id) >= 0)
70 return 0;
65c3ac88 71 return -EINVAL;
30459d7b
CL
72}
73
f120a6fb
BP
74static int xonar_probe(struct pci_dev *pci,
75 const struct pci_device_id *pci_id)
30459d7b 76{
1b8ff22f
CL
77 static int dev;
78 int err;
79
80 if (dev >= SNDRV_CARDS)
81 return -ENODEV;
82 if (!enable[dev]) {
83 ++dev;
84 return -ENOENT;
85 }
bb718588 86 err = oxygen_pci_probe(pci, index[dev], id[dev], THIS_MODULE,
30459d7b 87 xonar_ids, get_xonar_model);
1b8ff22f
CL
88 if (err >= 0)
89 ++dev;
90 return err;
91}
92
93static struct pci_driver xonar_driver = {
3733e424 94 .name = KBUILD_MODNAME,
1b8ff22f
CL
95 .id_table = xonar_ids,
96 .probe = xonar_probe,
f120a6fb 97 .remove = oxygen_pci_remove,
c7561cd8 98#ifdef CONFIG_PM_SLEEP
68cb2b55
TI
99 .driver = {
100 .pm = &oxygen_pci_pm,
101 },
4a4bc53b 102#endif
4c25b932 103 .shutdown = oxygen_pci_shutdown,
1b8ff22f
CL
104};
105
e9f66d9b 106module_pci_driver(xonar_driver);