diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2008-10-17 12:20:26 -0400 |
---|---|---|
committer | Arjan van de Ven <arjan@linux.intel.com> | 2008-10-17 12:20:26 -0400 |
commit | 651dab4264e4ba0e563f5ff56f748127246e9065 (patch) | |
tree | 016630974bdcb00fe529b673f96d389e0fd6dc94 /sound/core | |
parent | 40b8606253552109815786e5d4b0de98782d31f5 (diff) | |
parent | 2e532d68a2b3e2aa6b19731501222069735c741c (diff) |
Merge commit 'linus/master' into merge-linus
Conflicts:
arch/x86/kvm/i8254.c
Diffstat (limited to 'sound/core')
45 files changed, 896 insertions, 495 deletions
diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 335d45ecde6a..66348c92f88d 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig | |||
@@ -12,6 +12,12 @@ config SND_HWDEP | |||
12 | config SND_RAWMIDI | 12 | config SND_RAWMIDI |
13 | tristate | 13 | tristate |
14 | 14 | ||
15 | # To be effective this also requires INPUT - users should say: | ||
16 | # select SND_JACK if INPUT=y || INPUT=SND | ||
17 | # to avoid having to force INPUT on. | ||
18 | config SND_JACK | ||
19 | bool | ||
20 | |||
15 | config SND_SEQUENCER | 21 | config SND_SEQUENCER |
16 | tristate "Sequencer support" | 22 | tristate "Sequencer support" |
17 | select SND_TIMER | 23 | select SND_TIMER |
@@ -38,6 +44,7 @@ config SND_SEQ_DUMMY | |||
38 | will be called snd-seq-dummy. | 44 | will be called snd-seq-dummy. |
39 | 45 | ||
40 | config SND_OSSEMUL | 46 | config SND_OSSEMUL |
47 | select SOUND_OSS_CORE | ||
41 | bool | 48 | bool |
42 | 49 | ||
43 | config SND_MIXER_OSS | 50 | config SND_MIXER_OSS |
@@ -101,6 +108,9 @@ config SND_RTCTIMER | |||
101 | To compile this driver as a module, choose M here: the module | 108 | To compile this driver as a module, choose M here: the module |
102 | will be called snd-rtctimer. | 109 | will be called snd-rtctimer. |
103 | 110 | ||
111 | Note that this option is exclusive with the new RTC drivers | ||
112 | (CONFIG_RTC_CLASS) since this requires the old API. | ||
113 | |||
104 | config SND_SEQ_RTCTIMER_DEFAULT | 114 | config SND_SEQ_RTCTIMER_DEFAULT |
105 | bool "Use RTC as default sequencer timer" | 115 | bool "Use RTC as default sequencer timer" |
106 | depends on SND_RTCTIMER && SND_SEQUENCER | 116 | depends on SND_RTCTIMER && SND_SEQUENCER |
diff --git a/sound/core/Makefile b/sound/core/Makefile index da8e685eef9c..d57125a5687d 100644 --- a/sound/core/Makefile +++ b/sound/core/Makefile | |||
@@ -7,6 +7,7 @@ snd-y := sound.o init.o memory.o info.o control.o misc.o device.o | |||
7 | snd-$(CONFIG_ISA_DMA_API) += isadma.o | 7 | snd-$(CONFIG_ISA_DMA_API) += isadma.o |
8 | snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o | 8 | snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o |
9 | snd-$(CONFIG_SND_VMASTER) += vmaster.o | 9 | snd-$(CONFIG_SND_VMASTER) += vmaster.o |
10 | snd-$(CONFIG_SND_JACK) += jack.o | ||
10 | 11 | ||
11 | snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ | 12 | snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ |
12 | pcm_memory.o | 13 | pcm_memory.o |
diff --git a/sound/core/control.c b/sound/core/control.c index 281b2e2ef0ea..6d71f9a7ccbb 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
@@ -139,7 +139,8 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask, | |||
139 | struct snd_ctl_file *ctl; | 139 | struct snd_ctl_file *ctl; |
140 | struct snd_kctl_event *ev; | 140 | struct snd_kctl_event *ev; |
141 | 141 | ||
142 | snd_assert(card != NULL && id != NULL, return); | 142 | if (snd_BUG_ON(!card || !id)) |
143 | return; | ||
143 | read_lock(&card->ctl_files_rwlock); | 144 | read_lock(&card->ctl_files_rwlock); |
144 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) | 145 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
145 | card->mixer_oss_change_count++; | 146 | card->mixer_oss_change_count++; |
@@ -188,8 +189,8 @@ static struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, | |||
188 | struct snd_kcontrol *kctl; | 189 | struct snd_kcontrol *kctl; |
189 | unsigned int idx; | 190 | unsigned int idx; |
190 | 191 | ||
191 | snd_assert(control != NULL, return NULL); | 192 | if (snd_BUG_ON(!control || !control->count)) |
192 | snd_assert(control->count > 0, return NULL); | 193 | return NULL; |
193 | kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); | 194 | kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); |
194 | if (kctl == NULL) { | 195 | if (kctl == NULL) { |
195 | snd_printk(KERN_ERR "Cannot allocate control instance\n"); | 196 | snd_printk(KERN_ERR "Cannot allocate control instance\n"); |
@@ -218,8 +219,8 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, | |||
218 | struct snd_kcontrol kctl; | 219 | struct snd_kcontrol kctl; |
219 | unsigned int access; | 220 | unsigned int access; |
220 | 221 | ||
221 | snd_assert(ncontrol != NULL, return NULL); | 222 | if (snd_BUG_ON(!ncontrol || !ncontrol->info)) |
222 | snd_assert(ncontrol->info != NULL, return NULL); | 223 | return NULL; |
223 | memset(&kctl, 0, sizeof(kctl)); | 224 | memset(&kctl, 0, sizeof(kctl)); |
224 | kctl.id.iface = ncontrol->iface; | 225 | kctl.id.iface = ncontrol->iface; |
225 | kctl.id.device = ncontrol->device; | 226 | kctl.id.device = ncontrol->device; |
@@ -315,8 +316,8 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) | |||
315 | 316 | ||
316 | if (! kcontrol) | 317 | if (! kcontrol) |
317 | return err; | 318 | return err; |
318 | snd_assert(card != NULL, goto error); | 319 | if (snd_BUG_ON(!card || !kcontrol->info)) |
319 | snd_assert(kcontrol->info != NULL, goto error); | 320 | goto error; |
320 | id = kcontrol->id; | 321 | id = kcontrol->id; |
321 | down_write(&card->controls_rwsem); | 322 | down_write(&card->controls_rwsem); |
322 | if (snd_ctl_find_id(card, &id)) { | 323 | if (snd_ctl_find_id(card, &id)) { |
@@ -367,7 +368,8 @@ int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) | |||
367 | struct snd_ctl_elem_id id; | 368 | struct snd_ctl_elem_id id; |
368 | unsigned int idx; | 369 | unsigned int idx; |
369 | 370 | ||
370 | snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); | 371 | if (snd_BUG_ON(!card || !kcontrol)) |
372 | return -EINVAL; | ||
371 | list_del(&kcontrol->list); | 373 | list_del(&kcontrol->list); |
372 | card->controls_count -= kcontrol->count; | 374 | card->controls_count -= kcontrol->count; |
373 | id = kcontrol->id; | 375 | id = kcontrol->id; |
@@ -487,7 +489,8 @@ struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numi | |||
487 | { | 489 | { |
488 | struct snd_kcontrol *kctl; | 490 | struct snd_kcontrol *kctl; |
489 | 491 | ||
490 | snd_assert(card != NULL && numid != 0, return NULL); | 492 | if (snd_BUG_ON(!card || !numid)) |
493 | return NULL; | ||
491 | list_for_each_entry(kctl, &card->controls, list) { | 494 | list_for_each_entry(kctl, &card->controls, list) { |
492 | if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) | 495 | if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) |
493 | return kctl; | 496 | return kctl; |
@@ -514,7 +517,8 @@ struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, | |||
514 | { | 517 | { |
515 | struct snd_kcontrol *kctl; | 518 | struct snd_kcontrol *kctl; |
516 | 519 | ||
517 | snd_assert(card != NULL && id != NULL, return NULL); | 520 | if (snd_BUG_ON(!card || !id)) |
521 | return NULL; | ||
518 | if (id->numid != 0) | 522 | if (id->numid != 0) |
519 | return snd_ctl_find_numid(card, id->numid); | 523 | return snd_ctl_find_numid(card, id->numid); |
520 | list_for_each_entry(kctl, &card->controls, list) { | 524 | list_for_each_entry(kctl, &card->controls, list) { |
@@ -647,7 +651,7 @@ static int snd_ctl_elem_info(struct snd_ctl_file *ctl, | |||
647 | #endif | 651 | #endif |
648 | result = kctl->info(kctl, info); | 652 | result = kctl->info(kctl, info); |
649 | if (result >= 0) { | 653 | if (result >= 0) { |
650 | snd_assert(info->access == 0, ); | 654 | snd_BUG_ON(info->access); |
651 | index_offset = snd_ctl_get_ioff(kctl, &info->id); | 655 | index_offset = snd_ctl_get_ioff(kctl, &info->id); |
652 | vd = &kctl->vd[index_offset]; | 656 | vd = &kctl->vd[index_offset]; |
653 | snd_ctl_build_ioff(&info->id, kctl, index_offset); | 657 | snd_ctl_build_ioff(&info->id, kctl, index_offset); |
@@ -1160,7 +1164,8 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
1160 | 1164 | ||
1161 | ctl = file->private_data; | 1165 | ctl = file->private_data; |
1162 | card = ctl->card; | 1166 | card = ctl->card; |
1163 | snd_assert(card != NULL, return -ENXIO); | 1167 | if (snd_BUG_ON(!card)) |
1168 | return -ENXIO; | ||
1164 | switch (cmd) { | 1169 | switch (cmd) { |
1165 | case SNDRV_CTL_IOCTL_PVERSION: | 1170 | case SNDRV_CTL_IOCTL_PVERSION: |
1166 | return put_user(SNDRV_CTL_VERSION, ip) ? -EFAULT : 0; | 1171 | return put_user(SNDRV_CTL_VERSION, ip) ? -EFAULT : 0; |
@@ -1222,7 +1227,8 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer, | |||
1222 | ssize_t result = 0; | 1227 | ssize_t result = 0; |
1223 | 1228 | ||
1224 | ctl = file->private_data; | 1229 | ctl = file->private_data; |
1225 | snd_assert(ctl != NULL && ctl->card != NULL, return -ENXIO); | 1230 | if (snd_BUG_ON(!ctl || !ctl->card)) |
1231 | return -ENXIO; | ||
1226 | if (!ctl->subscribed) | 1232 | if (!ctl->subscribed) |
1227 | return -EBADFD; | 1233 | return -EBADFD; |
1228 | if (count < sizeof(struct snd_ctl_event)) | 1234 | if (count < sizeof(struct snd_ctl_event)) |
@@ -1328,7 +1334,8 @@ static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, | |||
1328 | { | 1334 | { |
1329 | struct snd_kctl_ioctl *p; | 1335 | struct snd_kctl_ioctl *p; |
1330 | 1336 | ||
1331 | snd_assert(fcn != NULL, return -EINVAL); | 1337 | if (snd_BUG_ON(!fcn)) |
1338 | return -EINVAL; | ||
1332 | down_write(&snd_ioctl_rwsem); | 1339 | down_write(&snd_ioctl_rwsem); |
1333 | list_for_each_entry(p, lists, list) { | 1340 | list_for_each_entry(p, lists, list) { |
1334 | if (p->fioctl == fcn) { | 1341 | if (p->fioctl == fcn) { |
@@ -1404,9 +1411,11 @@ static int snd_ctl_dev_register(struct snd_device *device) | |||
1404 | int err, cardnum; | 1411 | int err, cardnum; |
1405 | char name[16]; | 1412 | char name[16]; |
1406 | 1413 | ||
1407 | snd_assert(card != NULL, return -ENXIO); | 1414 | if (snd_BUG_ON(!card)) |
1415 | return -ENXIO; | ||
1408 | cardnum = card->number; | 1416 | cardnum = card->number; |
1409 | snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); | 1417 | if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) |
1418 | return -ENXIO; | ||
1410 | sprintf(name, "controlC%i", cardnum); | 1419 | sprintf(name, "controlC%i", cardnum); |
1411 | if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, | 1420 | if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, |
1412 | &snd_ctl_f_ops, card, name)) < 0) | 1421 | &snd_ctl_f_ops, card, name)) < 0) |
@@ -1423,16 +1432,18 @@ static int snd_ctl_dev_disconnect(struct snd_device *device) | |||
1423 | struct snd_ctl_file *ctl; | 1432 | struct snd_ctl_file *ctl; |
1424 | int err, cardnum; | 1433 | int err, cardnum; |
1425 | 1434 | ||
1426 | snd_assert(card != NULL, return -ENXIO); | 1435 | if (snd_BUG_ON(!card)) |
1436 | return -ENXIO; | ||
1427 | cardnum = card->number; | 1437 | cardnum = card->number; |
1428 | snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); | 1438 | if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) |
1439 | return -ENXIO; | ||
1429 | 1440 | ||
1430 | down_read(&card->controls_rwsem); | 1441 | read_lock(&card->ctl_files_rwlock); |
1431 | list_for_each_entry(ctl, &card->ctl_files, list) { | 1442 | list_for_each_entry(ctl, &card->ctl_files, list) { |
1432 | wake_up(&ctl->change_sleep); | 1443 | wake_up(&ctl->change_sleep); |
1433 | kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); | 1444 | kill_fasync(&ctl->fasync, SIGIO, POLL_ERR); |
1434 | } | 1445 | } |
1435 | up_read(&card->controls_rwsem); | 1446 | read_unlock(&card->ctl_files_rwlock); |
1436 | 1447 | ||
1437 | if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, | 1448 | if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, |
1438 | card, -1)) < 0) | 1449 | card, -1)) < 0) |
@@ -1469,7 +1480,8 @@ int snd_ctl_create(struct snd_card *card) | |||
1469 | .dev_disconnect = snd_ctl_dev_disconnect, | 1480 | .dev_disconnect = snd_ctl_dev_disconnect, |
1470 | }; | 1481 | }; |
1471 | 1482 | ||
1472 | snd_assert(card != NULL, return -ENXIO); | 1483 | if (snd_BUG_ON(!card)) |
1484 | return -ENXIO; | ||
1473 | return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); | 1485 | return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); |
1474 | } | 1486 | } |
1475 | 1487 | ||
diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 6101259ad860..368dc9c4aef8 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c | |||
@@ -398,7 +398,8 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns | |||
398 | int err; | 398 | int err; |
399 | 399 | ||
400 | ctl = file->private_data; | 400 | ctl = file->private_data; |
401 | snd_assert(ctl && ctl->card, return -ENXIO); | 401 | if (snd_BUG_ON(!ctl || !ctl->card)) |
402 | return -ENXIO; | ||
402 | 403 | ||
403 | switch (cmd) { | 404 | switch (cmd) { |
404 | case SNDRV_CTL_IOCTL_PVERSION: | 405 | case SNDRV_CTL_IOCTL_PVERSION: |
diff --git a/sound/core/device.c b/sound/core/device.c index 202dac0e4d89..c58d8227254c 100644 --- a/sound/core/device.c +++ b/sound/core/device.c | |||
@@ -45,9 +45,8 @@ int snd_device_new(struct snd_card *card, snd_device_type_t type, | |||
45 | { | 45 | { |
46 | struct snd_device *dev; | 46 | struct snd_device *dev; |
47 | 47 | ||
48 | snd_assert(card != NULL, return -ENXIO); | 48 | if (snd_BUG_ON(!card || !device_data || !ops)) |
49 | snd_assert(device_data != NULL, return -ENXIO); | 49 | return -ENXIO; |
50 | snd_assert(ops != NULL, return -ENXIO); | ||
51 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 50 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
52 | if (dev == NULL) { | 51 | if (dev == NULL) { |
53 | snd_printk(KERN_ERR "Cannot allocate device\n"); | 52 | snd_printk(KERN_ERR "Cannot allocate device\n"); |
@@ -80,8 +79,8 @@ int snd_device_free(struct snd_card *card, void *device_data) | |||
80 | { | 79 | { |
81 | struct snd_device *dev; | 80 | struct snd_device *dev; |
82 | 81 | ||
83 | snd_assert(card != NULL, return -ENXIO); | 82 | if (snd_BUG_ON(!card || !device_data)) |
84 | snd_assert(device_data != NULL, return -ENXIO); | 83 | return -ENXIO; |
85 | list_for_each_entry(dev, &card->devices, list) { | 84 | list_for_each_entry(dev, &card->devices, list) { |
86 | if (dev->device_data != device_data) | 85 | if (dev->device_data != device_data) |
87 | continue; | 86 | continue; |
@@ -123,8 +122,8 @@ int snd_device_disconnect(struct snd_card *card, void *device_data) | |||
123 | { | 122 | { |
124 | struct snd_device *dev; | 123 | struct snd_device *dev; |
125 | 124 | ||
126 | snd_assert(card != NULL, return -ENXIO); | 125 | if (snd_BUG_ON(!card || !device_data)) |
127 | snd_assert(device_data != NULL, return -ENXIO); | 126 | return -ENXIO; |
128 | list_for_each_entry(dev, &card->devices, list) { | 127 | list_for_each_entry(dev, &card->devices, list) { |
129 | if (dev->device_data != device_data) | 128 | if (dev->device_data != device_data) |
130 | continue; | 129 | continue; |
@@ -159,8 +158,8 @@ int snd_device_register(struct snd_card *card, void *device_data) | |||
159 | struct snd_device *dev; | 158 | struct snd_device *dev; |
160 | int err; | 159 | int err; |
161 | 160 | ||
162 | snd_assert(card != NULL, return -ENXIO); | 161 | if (snd_BUG_ON(!card || !device_data)) |
163 | snd_assert(device_data != NULL, return -ENXIO); | 162 | return -ENXIO; |
164 | list_for_each_entry(dev, &card->devices, list) { | 163 | list_for_each_entry(dev, &card->devices, list) { |
165 | if (dev->device_data != device_data) | 164 | if (dev->device_data != device_data) |
166 | continue; | 165 | continue; |
@@ -188,7 +187,8 @@ int snd_device_register_all(struct snd_card *card) | |||
188 | struct snd_device *dev; | 187 | struct snd_device *dev; |
189 | int err; | 188 | int err; |
190 | 189 | ||
191 | snd_assert(card != NULL, return -ENXIO); | 190 | if (snd_BUG_ON(!card)) |
191 | return -ENXIO; | ||
192 | list_for_each_entry(dev, &card->devices, list) { | 192 | list_for_each_entry(dev, &card->devices, list) { |
193 | if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { | 193 | if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { |
194 | if ((err = dev->ops->dev_register(dev)) < 0) | 194 | if ((err = dev->ops->dev_register(dev)) < 0) |
@@ -208,7 +208,8 @@ int snd_device_disconnect_all(struct snd_card *card) | |||
208 | struct snd_device *dev; | 208 | struct snd_device *dev; |
209 | int err = 0; | 209 | int err = 0; |
210 | 210 | ||
211 | snd_assert(card != NULL, return -ENXIO); | 211 | if (snd_BUG_ON(!card)) |
212 | return -ENXIO; | ||
212 | list_for_each_entry(dev, &card->devices, list) { | 213 | list_for_each_entry(dev, &card->devices, list) { |
213 | if (snd_device_disconnect(card, dev->device_data) < 0) | 214 | if (snd_device_disconnect(card, dev->device_data) < 0) |
214 | err = -ENXIO; | 215 | err = -ENXIO; |
@@ -226,7 +227,8 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) | |||
226 | int err; | 227 | int err; |
227 | unsigned int range_low, range_high; | 228 | unsigned int range_low, range_high; |
228 | 229 | ||
229 | snd_assert(card != NULL, return -ENXIO); | 230 | if (snd_BUG_ON(!card)) |
231 | return -ENXIO; | ||
230 | range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; | 232 | range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; |
231 | range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; | 233 | range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; |
232 | __again: | 234 | __again: |
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 6d6589f93899..195cafc5a553 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c | |||
@@ -353,9 +353,10 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, | |||
353 | .dev_disconnect = snd_hwdep_dev_disconnect, | 353 | .dev_disconnect = snd_hwdep_dev_disconnect, |
354 | }; | 354 | }; |
355 | 355 | ||
356 | snd_assert(rhwdep != NULL, return -EINVAL); | 356 | if (snd_BUG_ON(!card)) |
357 | *rhwdep = NULL; | 357 | return -ENXIO; |
358 | snd_assert(card != NULL, return -ENXIO); | 358 | if (rhwdep) |
359 | *rhwdep = NULL; | ||
359 | hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL); | 360 | hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL); |
360 | if (hwdep == NULL) { | 361 | if (hwdep == NULL) { |
361 | snd_printk(KERN_ERR "hwdep: cannot allocate\n"); | 362 | snd_printk(KERN_ERR "hwdep: cannot allocate\n"); |
@@ -374,13 +375,15 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, | |||
374 | } | 375 | } |
375 | init_waitqueue_head(&hwdep->open_wait); | 376 | init_waitqueue_head(&hwdep->open_wait); |
376 | mutex_init(&hwdep->open_mutex); | 377 | mutex_init(&hwdep->open_mutex); |
377 | *rhwdep = hwdep; | 378 | if (rhwdep) |
379 | *rhwdep = hwdep; | ||
378 | return 0; | 380 | return 0; |
379 | } | 381 | } |
380 | 382 | ||
381 | static int snd_hwdep_free(struct snd_hwdep *hwdep) | 383 | static int snd_hwdep_free(struct snd_hwdep *hwdep) |
382 | { | 384 | { |
383 | snd_assert(hwdep != NULL, return -ENXIO); | 385 | if (!hwdep) |
386 | return 0; | ||
384 | if (hwdep->private_free) | 387 | if (hwdep->private_free) |
385 | hwdep->private_free(hwdep); | 388 | hwdep->private_free(hwdep); |
386 | kfree(hwdep); | 389 | kfree(hwdep); |
@@ -440,7 +443,8 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device) | |||
440 | { | 443 | { |
441 | struct snd_hwdep *hwdep = device->device_data; | 444 | struct snd_hwdep *hwdep = device->device_data; |
442 | 445 | ||
443 | snd_assert(hwdep != NULL, return -ENXIO); | 446 | if (snd_BUG_ON(!hwdep)) |
447 | return -ENXIO; | ||
444 | mutex_lock(®ister_mutex); | 448 | mutex_lock(®ister_mutex); |
445 | if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { | 449 | if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { |
446 | mutex_unlock(®ister_mutex); | 450 | mutex_unlock(®ister_mutex); |
diff --git a/sound/core/info.c b/sound/core/info.c index c67773ad9298..527b207462b0 100644 --- a/sound/core/info.c +++ b/sound/core/info.c | |||
@@ -217,7 +217,8 @@ static ssize_t snd_info_entry_read(struct file *file, char __user *buffer, | |||
217 | loff_t pos; | 217 | loff_t pos; |
218 | 218 | ||
219 | data = file->private_data; | 219 | data = file->private_data; |
220 | snd_assert(data != NULL, return -ENXIO); | 220 | if (snd_BUG_ON(!data)) |
221 | return -ENXIO; | ||
221 | pos = *offset; | 222 | pos = *offset; |
222 | if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) | 223 | if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) |
223 | return -EIO; | 224 | return -EIO; |
@@ -258,7 +259,8 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer | |||
258 | loff_t pos; | 259 | loff_t pos; |
259 | 260 | ||
260 | data = file->private_data; | 261 | data = file->private_data; |
261 | snd_assert(data != NULL, return -ENXIO); | 262 | if (snd_BUG_ON(!data)) |
263 | return -ENXIO; | ||
262 | entry = data->entry; | 264 | entry = data->entry; |
263 | pos = *offset; | 265 | pos = *offset; |
264 | if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) | 266 | if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) |
@@ -614,7 +616,8 @@ int snd_info_card_create(struct snd_card *card) | |||
614 | char str[8]; | 616 | char str[8]; |
615 | struct snd_info_entry *entry; | 617 | struct snd_info_entry *entry; |
616 | 618 | ||
617 | snd_assert(card != NULL, return -ENXIO); | 619 | if (snd_BUG_ON(!card)) |
620 | return -ENXIO; | ||
618 | 621 | ||
619 | sprintf(str, "card%i", card->number); | 622 | sprintf(str, "card%i", card->number); |
620 | if ((entry = snd_info_create_module_entry(card->module, str, NULL)) == NULL) | 623 | if ((entry = snd_info_create_module_entry(card->module, str, NULL)) == NULL) |
@@ -636,7 +639,8 @@ int snd_info_card_register(struct snd_card *card) | |||
636 | { | 639 | { |
637 | struct proc_dir_entry *p; | 640 | struct proc_dir_entry *p; |
638 | 641 | ||
639 | snd_assert(card != NULL, return -ENXIO); | 642 | if (snd_BUG_ON(!card)) |
643 | return -ENXIO; | ||
640 | 644 | ||
641 | if (!strcmp(card->id, card->proc_root->name)) | 645 | if (!strcmp(card->id, card->proc_root->name)) |
642 | return 0; | 646 | return 0; |
@@ -654,7 +658,8 @@ int snd_info_card_register(struct snd_card *card) | |||
654 | */ | 658 | */ |
655 | void snd_info_card_disconnect(struct snd_card *card) | 659 | void snd_info_card_disconnect(struct snd_card *card) |
656 | { | 660 | { |
657 | snd_assert(card != NULL, return); | 661 | if (!card) |
662 | return; | ||
658 | mutex_lock(&info_mutex); | 663 | mutex_lock(&info_mutex); |
659 | if (card->proc_root_link) { | 664 | if (card->proc_root_link) { |
660 | snd_remove_proc_entry(snd_proc_root, card->proc_root_link); | 665 | snd_remove_proc_entry(snd_proc_root, card->proc_root_link); |
@@ -671,7 +676,8 @@ void snd_info_card_disconnect(struct snd_card *card) | |||
671 | */ | 676 | */ |
672 | int snd_info_card_free(struct snd_card *card) | 677 | int snd_info_card_free(struct snd_card *card) |
673 | { | 678 | { |
674 | snd_assert(card != NULL, return -ENXIO); | 679 | if (!card) |
680 | return 0; | ||
675 | snd_info_free_entry(card->proc_root); | 681 | snd_info_free_entry(card->proc_root); |
676 | card->proc_root = NULL; | 682 | card->proc_root = NULL; |
677 | return 0; | 683 | return 0; |
@@ -849,7 +855,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry) | |||
849 | return; | 855 | return; |
850 | list_del_init(&entry->list); | 856 | list_del_init(&entry->list); |
851 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; | 857 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; |
852 | snd_assert(root, return); | 858 | snd_BUG_ON(!root); |
853 | snd_remove_proc_entry(root, entry->p); | 859 | snd_remove_proc_entry(root, entry->p); |
854 | entry->p = NULL; | 860 | entry->p = NULL; |
855 | } | 861 | } |
@@ -947,7 +953,8 @@ int snd_info_register(struct snd_info_entry * entry) | |||
947 | { | 953 | { |
948 | struct proc_dir_entry *root, *p = NULL; | 954 | struct proc_dir_entry *root, *p = NULL; |
949 | 955 | ||
950 | snd_assert(entry != NULL, return -ENXIO); | 956 | if (snd_BUG_ON(!entry)) |
957 | return -ENXIO; | ||
951 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; | 958 | root = entry->parent == NULL ? snd_proc_root : entry->parent->p; |
952 | mutex_lock(&info_mutex); | 959 | mutex_lock(&info_mutex); |
953 | p = snd_create_proc_entry(entry->name, entry->mode, root); | 960 | p = snd_create_proc_entry(entry->name, entry->mode, root); |
diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c index e35789a92752..e4af138d651a 100644 --- a/sound/core/info_oss.c +++ b/sound/core/info_oss.c | |||
@@ -43,8 +43,10 @@ int snd_oss_info_register(int dev, int num, char *string) | |||
43 | { | 43 | { |
44 | char *x; | 44 | char *x; |
45 | 45 | ||
46 | snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO); | 46 | if (snd_BUG_ON(dev < 0 || dev >= SNDRV_OSS_INFO_DEV_COUNT)) |
47 | snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO); | 47 | return -ENXIO; |
48 | if (snd_BUG_ON(num < 0 || num >= SNDRV_CARDS)) | ||
49 | return -ENXIO; | ||
48 | mutex_lock(&strings); | 50 | mutex_lock(&strings); |
49 | if (string == NULL) { | 51 | if (string == NULL) { |
50 | if ((x = snd_sndstat_strings[num][dev]) != NULL) { | 52 | if ((x = snd_sndstat_strings[num][dev]) != NULL) { |
diff --git a/sound/core/init.c b/sound/core/init.c index df46bbc25dc2..ef2352c2e451 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -545,12 +545,13 @@ int snd_card_register(struct snd_card *card) | |||
545 | { | 545 | { |
546 | int err; | 546 | int err; |
547 | 547 | ||
548 | snd_assert(card != NULL, return -EINVAL); | 548 | if (snd_BUG_ON(!card)) |
549 | return -EINVAL; | ||
549 | #ifndef CONFIG_SYSFS_DEPRECATED | 550 | #ifndef CONFIG_SYSFS_DEPRECATED |
550 | if (!card->card_dev) { | 551 | if (!card->card_dev) { |
551 | card->card_dev = device_create_drvdata(sound_class, card->dev, | 552 | card->card_dev = device_create(sound_class, card->dev, |
552 | MKDEV(0, 0), NULL, | 553 | MKDEV(0, 0), NULL, |
553 | "card%i", card->number); | 554 | "card%i", card->number); |
554 | if (IS_ERR(card->card_dev)) | 555 | if (IS_ERR(card->card_dev)) |
555 | card->card_dev = NULL; | 556 | card->card_dev = NULL; |
556 | } | 557 | } |
diff --git a/sound/core/jack.c b/sound/core/jack.c new file mode 100644 index 000000000000..8133a2b173a5 --- /dev/null +++ b/sound/core/jack.c | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * Jack abstraction layer | ||
3 | * | ||
4 | * Copyright 2008 Wolfson Microelectronics | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/input.h> | ||
23 | #include <sound/jack.h> | ||
24 | #include <sound/core.h> | ||
25 | |||
26 | static int snd_jack_dev_free(struct snd_device *device) | ||
27 | { | ||
28 | struct snd_jack *jack = device->device_data; | ||
29 | |||
30 | /* If the input device is registered with the input subsystem | ||
31 | * then we need to use a different deallocator. */ | ||
32 | if (jack->registered) | ||
33 | input_unregister_device(jack->input_dev); | ||
34 | else | ||
35 | input_free_device(jack->input_dev); | ||
36 | |||
37 | kfree(jack); | ||
38 | |||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static int snd_jack_dev_register(struct snd_device *device) | ||
43 | { | ||
44 | struct snd_jack *jack = device->device_data; | ||
45 | struct snd_card *card = device->card; | ||
46 | int err; | ||
47 | |||
48 | snprintf(jack->name, sizeof(jack->name), "%s %s", | ||
49 | card->longname, jack->id); | ||
50 | jack->input_dev->name = jack->name; | ||
51 | |||
52 | /* Default to the sound card device. */ | ||
53 | if (!jack->input_dev->dev.parent) | ||
54 | jack->input_dev->dev.parent = card->dev; | ||
55 | |||
56 | err = input_register_device(jack->input_dev); | ||
57 | if (err == 0) | ||
58 | jack->registered = 1; | ||
59 | |||
60 | return err; | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * snd_jack_new - Create a new jack | ||
65 | * @card: the card instance | ||
66 | * @id: an identifying string for this jack | ||
67 | * @type: a bitmask of enum snd_jack_type values that can be detected by | ||
68 | * this jack | ||
69 | * @jjack: Used to provide the allocated jack object to the caller. | ||
70 | * | ||
71 | * Creates a new jack object. | ||
72 | * | ||
73 | * Returns zero if successful, or a negative error code on failure. | ||
74 | * On success jjack will be initialised. | ||
75 | */ | ||
76 | int snd_jack_new(struct snd_card *card, const char *id, int type, | ||
77 | struct snd_jack **jjack) | ||
78 | { | ||
79 | struct snd_jack *jack; | ||
80 | int err; | ||
81 | static struct snd_device_ops ops = { | ||
82 | .dev_free = snd_jack_dev_free, | ||
83 | .dev_register = snd_jack_dev_register, | ||
84 | }; | ||
85 | |||
86 | jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL); | ||
87 | if (jack == NULL) | ||
88 | return -ENOMEM; | ||
89 | |||
90 | jack->id = id; | ||
91 | |||
92 | jack->input_dev = input_allocate_device(); | ||
93 | if (jack->input_dev == NULL) { | ||
94 | err = -ENOMEM; | ||
95 | goto fail_input; | ||
96 | } | ||
97 | |||
98 | jack->input_dev->phys = "ALSA"; | ||
99 | |||
100 | jack->type = type; | ||
101 | |||
102 | if (type & SND_JACK_HEADPHONE) | ||
103 | input_set_capability(jack->input_dev, EV_SW, | ||
104 | SW_HEADPHONE_INSERT); | ||
105 | if (type & SND_JACK_MICROPHONE) | ||
106 | input_set_capability(jack->input_dev, EV_SW, | ||
107 | SW_MICROPHONE_INSERT); | ||
108 | |||
109 | err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); | ||
110 | if (err < 0) | ||
111 | goto fail_input; | ||
112 | |||
113 | *jjack = jack; | ||
114 | |||
115 | return 0; | ||
116 | |||
117 | fail_input: | ||
118 | input_free_device(jack->input_dev); | ||
119 | kfree(jack); | ||
120 | return err; | ||
121 | } | ||
122 | EXPORT_SYMBOL(snd_jack_new); | ||
123 | |||
124 | /** | ||
125 | * snd_jack_set_parent - Set the parent device for a jack | ||
126 | * | ||
127 | * @jack: The jack to configure | ||
128 | * @parent: The device to set as parent for the jack. | ||
129 | * | ||
130 | * Set the parent for the jack input device in the device tree. This | ||
131 | * function is only valid prior to registration of the jack. If no | ||
132 | * parent is configured then the parent device will be the sound card. | ||
133 | */ | ||
134 | void snd_jack_set_parent(struct snd_jack *jack, struct device *parent) | ||
135 | { | ||
136 | WARN_ON(jack->registered); | ||
137 | |||
138 | jack->input_dev->dev.parent = parent; | ||
139 | } | ||
140 | EXPORT_SYMBOL(snd_jack_set_parent); | ||
141 | |||
142 | /** | ||
143 | * snd_jack_report - Report the current status of a jack | ||
144 | * | ||
145 | * @jack: The jack to report status for | ||
146 | * @status: The current status of the jack | ||
147 | */ | ||
148 | void snd_jack_report(struct snd_jack *jack, int status) | ||
149 | { | ||
150 | if (jack->type & SND_JACK_HEADPHONE) | ||
151 | input_report_switch(jack->input_dev, SW_HEADPHONE_INSERT, | ||
152 | status & SND_JACK_HEADPHONE); | ||
153 | if (jack->type & SND_JACK_MICROPHONE) | ||
154 | input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT, | ||
155 | status & SND_JACK_MICROPHONE); | ||
156 | |||
157 | input_sync(jack->input_dev); | ||
158 | } | ||
159 | EXPORT_SYMBOL(snd_jack_report); | ||
160 | |||
161 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | ||
162 | MODULE_DESCRIPTION("Jack detection support for ALSA"); | ||
163 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index f5d6d8d12979..1b3534d67686 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c | |||
@@ -33,9 +33,6 @@ | |||
33 | #include <linux/moduleparam.h> | 33 | #include <linux/moduleparam.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <sound/memalloc.h> | 35 | #include <sound/memalloc.h> |
36 | #ifdef CONFIG_SBUS | ||
37 | #include <asm/sbus.h> | ||
38 | #endif | ||
39 | 36 | ||
40 | 37 | ||
41 | MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>"); | 38 | MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>"); |
@@ -46,14 +43,6 @@ MODULE_LICENSE("GPL"); | |||
46 | /* | 43 | /* |
47 | */ | 44 | */ |
48 | 45 | ||
49 | void *snd_malloc_sgbuf_pages(struct device *device, | ||
50 | size_t size, struct snd_dma_buffer *dmab, | ||
51 | size_t *res_size); | ||
52 | int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab); | ||
53 | |||
54 | /* | ||
55 | */ | ||
56 | |||
57 | static DEFINE_MUTEX(list_mutex); | 46 | static DEFINE_MUTEX(list_mutex); |
58 | static LIST_HEAD(mem_list_head); | 47 | static LIST_HEAD(mem_list_head); |
59 | 48 | ||
@@ -67,18 +56,6 @@ struct snd_mem_list { | |||
67 | /* id for pre-allocated buffers */ | 56 | /* id for pre-allocated buffers */ |
68 | #define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1 | 57 | #define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1 |
69 | 58 | ||
70 | #ifdef CONFIG_SND_DEBUG | ||
71 | #define __ASTRING__(x) #x | ||
72 | #define snd_assert(expr, args...) do {\ | ||
73 | if (!(expr)) {\ | ||
74 | printk(KERN_ERR "snd-malloc: BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\ | ||
75 | args;\ | ||
76 | }\ | ||
77 | } while (0) | ||
78 | #else | ||
79 | #define snd_assert(expr, args...) /**/ | ||
80 | #endif | ||
81 | |||
82 | /* | 59 | /* |
83 | * | 60 | * |
84 | * Generic memory allocators | 61 | * Generic memory allocators |
@@ -111,8 +88,10 @@ void *snd_malloc_pages(size_t size, gfp_t gfp_flags) | |||
111 | int pg; | 88 | int pg; |
112 | void *res; | 89 | void *res; |
113 | 90 | ||
114 | snd_assert(size > 0, return NULL); | 91 | if (WARN_ON(!size)) |
115 | snd_assert(gfp_flags != 0, return NULL); | 92 | return NULL; |
93 | if (WARN_ON(!gfp_flags)) | ||
94 | return NULL; | ||
116 | gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */ | 95 | gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */ |
117 | pg = get_order(size); | 96 | pg = get_order(size); |
118 | if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) | 97 | if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) |
@@ -152,8 +131,8 @@ static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *d | |||
152 | void *res; | 131 | void *res; |
153 | gfp_t gfp_flags; | 132 | gfp_t gfp_flags; |
154 | 133 | ||
155 | snd_assert(size > 0, return NULL); | 134 | if (WARN_ON(!dma)) |
156 | snd_assert(dma != NULL, return NULL); | 135 | return NULL; |
157 | pg = get_order(size); | 136 | pg = get_order(size); |
158 | gfp_flags = GFP_KERNEL | 137 | gfp_flags = GFP_KERNEL |
159 | | __GFP_COMP /* compound page lets parts be mapped */ | 138 | | __GFP_COMP /* compound page lets parts be mapped */ |
@@ -180,39 +159,6 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr, | |||
180 | } | 159 | } |
181 | #endif /* CONFIG_HAS_DMA */ | 160 | #endif /* CONFIG_HAS_DMA */ |
182 | 161 | ||
183 | #ifdef CONFIG_SBUS | ||
184 | |||
185 | static void *snd_malloc_sbus_pages(struct device *dev, size_t size, | ||
186 | dma_addr_t *dma_addr) | ||
187 | { | ||
188 | struct sbus_dev *sdev = (struct sbus_dev *)dev; | ||
189 | int pg; | ||
190 | void *res; | ||
191 | |||
192 | snd_assert(size > 0, return NULL); | ||
193 | snd_assert(dma_addr != NULL, return NULL); | ||
194 | pg = get_order(size); | ||
195 | res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr); | ||
196 | if (res != NULL) | ||
197 | inc_snd_pages(pg); | ||
198 | return res; | ||
199 | } | ||
200 | |||
201 | static void snd_free_sbus_pages(struct device *dev, size_t size, | ||
202 | void *ptr, dma_addr_t dma_addr) | ||
203 | { | ||
204 | struct sbus_dev *sdev = (struct sbus_dev *)dev; | ||
205 | int pg; | ||
206 | |||
207 | if (ptr == NULL) | ||
208 | return; | ||
209 | pg = get_order(size); | ||
210 | dec_snd_pages(pg); | ||
211 | sbus_free_consistent(sdev, PAGE_SIZE * (1 << pg), ptr, dma_addr); | ||
212 | } | ||
213 | |||
214 | #endif /* CONFIG_SBUS */ | ||
215 | |||
216 | /* | 162 | /* |
217 | * | 163 | * |
218 | * ALSA generic memory management | 164 | * ALSA generic memory management |
@@ -236,8 +182,10 @@ static void snd_free_sbus_pages(struct device *dev, size_t size, | |||
236 | int snd_dma_alloc_pages(int type, struct device *device, size_t size, | 182 | int snd_dma_alloc_pages(int type, struct device *device, size_t size, |
237 | struct snd_dma_buffer *dmab) | 183 | struct snd_dma_buffer *dmab) |
238 | { | 184 | { |
239 | snd_assert(size > 0, return -ENXIO); | 185 | if (WARN_ON(!size)) |
240 | snd_assert(dmab != NULL, return -ENXIO); | 186 | return -ENXIO; |
187 | if (WARN_ON(!dmab)) | ||
188 | return -ENXIO; | ||
241 | 189 | ||
242 | dmab->dev.type = type; | 190 | dmab->dev.type = type; |
243 | dmab->dev.dev = device; | 191 | dmab->dev.dev = device; |
@@ -247,11 +195,6 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, | |||
247 | dmab->area = snd_malloc_pages(size, (unsigned long)device); | 195 | dmab->area = snd_malloc_pages(size, (unsigned long)device); |
248 | dmab->addr = 0; | 196 | dmab->addr = 0; |
249 | break; | 197 | break; |
250 | #ifdef CONFIG_SBUS | ||
251 | case SNDRV_DMA_TYPE_SBUS: | ||
252 | dmab->area = snd_malloc_sbus_pages(device, size, &dmab->addr); | ||
253 | break; | ||
254 | #endif | ||
255 | #ifdef CONFIG_HAS_DMA | 198 | #ifdef CONFIG_HAS_DMA |
256 | case SNDRV_DMA_TYPE_DEV: | 199 | case SNDRV_DMA_TYPE_DEV: |
257 | dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); | 200 | dmab->area = snd_malloc_dev_pages(device, size, &dmab->addr); |
@@ -292,15 +235,17 @@ int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size, | |||
292 | { | 235 | { |
293 | int err; | 236 | int err; |
294 | 237 | ||
295 | snd_assert(size > 0, return -ENXIO); | ||
296 | snd_assert(dmab != NULL, return -ENXIO); | ||
297 | |||
298 | while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) { | 238 | while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) { |
239 | size_t aligned_size; | ||
299 | if (err != -ENOMEM) | 240 | if (err != -ENOMEM) |
300 | return err; | 241 | return err; |
301 | size >>= 1; | ||
302 | if (size <= PAGE_SIZE) | 242 | if (size <= PAGE_SIZE) |
303 | return -ENOMEM; | 243 | return -ENOMEM; |
244 | aligned_size = PAGE_SIZE << get_order(size); | ||
245 | if (size != aligned_size) | ||
246 | size = aligned_size; | ||
247 | else | ||
248 | size >>= 1; | ||
304 | } | 249 | } |
305 | if (! dmab->area) | 250 | if (! dmab->area) |
306 | return -ENOMEM; | 251 | return -ENOMEM; |
@@ -320,11 +265,6 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab) | |||
320 | case SNDRV_DMA_TYPE_CONTINUOUS: | 265 | case SNDRV_DMA_TYPE_CONTINUOUS: |
321 | snd_free_pages(dmab->area, dmab->bytes); | 266 | snd_free_pages(dmab->area, dmab->bytes); |
322 | break; | 267 | break; |
323 | #ifdef CONFIG_SBUS | ||
324 | case SNDRV_DMA_TYPE_SBUS: | ||
325 | snd_free_sbus_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); | ||
326 | break; | ||
327 | #endif | ||
328 | #ifdef CONFIG_HAS_DMA | 268 | #ifdef CONFIG_HAS_DMA |
329 | case SNDRV_DMA_TYPE_DEV: | 269 | case SNDRV_DMA_TYPE_DEV: |
330 | snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); | 270 | snd_free_dev_pages(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr); |
@@ -353,7 +293,8 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id) | |||
353 | { | 293 | { |
354 | struct snd_mem_list *mem; | 294 | struct snd_mem_list *mem; |
355 | 295 | ||
356 | snd_assert(dmab, return 0); | 296 | if (WARN_ON(!dmab)) |
297 | return 0; | ||
357 | 298 | ||
358 | mutex_lock(&list_mutex); | 299 | mutex_lock(&list_mutex); |
359 | list_for_each_entry(mem, &mem_list_head, list) { | 300 | list_for_each_entry(mem, &mem_list_head, list) { |
@@ -387,7 +328,8 @@ int snd_dma_reserve_buf(struct snd_dma_buffer *dmab, unsigned int id) | |||
387 | { | 328 | { |
388 | struct snd_mem_list *mem; | 329 | struct snd_mem_list *mem; |
389 | 330 | ||
390 | snd_assert(dmab, return -EINVAL); | 331 | if (WARN_ON(!dmab)) |
332 | return -EINVAL; | ||
391 | mem = kmalloc(sizeof(*mem), GFP_KERNEL); | 333 | mem = kmalloc(sizeof(*mem), GFP_KERNEL); |
392 | if (! mem) | 334 | if (! mem) |
393 | return -ENOMEM; | 335 | return -ENOMEM; |
@@ -431,7 +373,7 @@ static int snd_mem_proc_read(struct seq_file *seq, void *offset) | |||
431 | long pages = snd_allocated_pages >> (PAGE_SHIFT-12); | 373 | long pages = snd_allocated_pages >> (PAGE_SHIFT-12); |
432 | struct snd_mem_list *mem; | 374 | struct snd_mem_list *mem; |
433 | int devno; | 375 | int devno; |
434 | static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG", "SBUS" }; | 376 | static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" }; |
435 | 377 | ||
436 | mutex_lock(&list_mutex); | 378 | mutex_lock(&list_mutex); |
437 | seq_printf(seq, "pages : %li bytes (%li pages per %likB)\n", | 379 | seq_printf(seq, "pages : %li bytes (%li pages per %likB)\n", |
diff --git a/sound/core/oss/copy.c b/sound/core/oss/copy.c index 9ded30d0e97d..05b58d4fc2b7 100644 --- a/sound/core/oss/copy.c +++ b/sound/core/oss/copy.c | |||
@@ -32,17 +32,18 @@ static snd_pcm_sframes_t copy_transfer(struct snd_pcm_plugin *plugin, | |||
32 | unsigned int channel; | 32 | unsigned int channel; |
33 | unsigned int nchannels; | 33 | unsigned int nchannels; |
34 | 34 | ||
35 | snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); | 35 | if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) |
36 | return -ENXIO; | ||
36 | if (frames == 0) | 37 | if (frames == 0) |
37 | return 0; | 38 | return 0; |
38 | nchannels = plugin->src_format.channels; | 39 | nchannels = plugin->src_format.channels; |
39 | for (channel = 0; channel < nchannels; channel++) { | 40 | for (channel = 0; channel < nchannels; channel++) { |
40 | snd_assert(src_channels->area.first % 8 == 0 && | 41 | if (snd_BUG_ON(src_channels->area.first % 8 || |
41 | src_channels->area.step % 8 == 0, | 42 | src_channels->area.step % 8)) |
42 | return -ENXIO); | 43 | return -ENXIO; |
43 | snd_assert(dst_channels->area.first % 8 == 0 && | 44 | if (snd_BUG_ON(dst_channels->area.first % 8 || |
44 | dst_channels->area.step % 8 == 0, | 45 | dst_channels->area.step % 8)) |
45 | return -ENXIO); | 46 | return -ENXIO; |
46 | if (!src_channels->enabled) { | 47 | if (!src_channels->enabled) { |
47 | if (dst_channels->wanted) | 48 | if (dst_channels->wanted) |
48 | snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format); | 49 | snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format); |
@@ -66,15 +67,20 @@ int snd_pcm_plugin_build_copy(struct snd_pcm_substream *plug, | |||
66 | struct snd_pcm_plugin *plugin; | 67 | struct snd_pcm_plugin *plugin; |
67 | int width; | 68 | int width; |
68 | 69 | ||
69 | snd_assert(r_plugin != NULL, return -ENXIO); | 70 | if (snd_BUG_ON(!r_plugin)) |
71 | return -ENXIO; | ||
70 | *r_plugin = NULL; | 72 | *r_plugin = NULL; |
71 | 73 | ||
72 | snd_assert(src_format->format == dst_format->format, return -ENXIO); | 74 | if (snd_BUG_ON(src_format->format != dst_format->format)) |
73 | snd_assert(src_format->rate == dst_format->rate, return -ENXIO); | 75 | return -ENXIO; |
74 | snd_assert(src_format->channels == dst_format->channels, return -ENXIO); | 76 | if (snd_BUG_ON(src_format->rate != dst_format->rate)) |
77 | return -ENXIO; | ||
78 | if (snd_BUG_ON(src_format->channels != dst_format->channels)) | ||
79 | return -ENXIO; | ||
75 | 80 | ||
76 | width = snd_pcm_format_physical_width(src_format->format); | 81 | width = snd_pcm_format_physical_width(src_format->format); |
77 | snd_assert(width > 0, return -ENXIO); | 82 | if (snd_BUG_ON(width <= 0)) |
83 | return -ENXIO; | ||
78 | 84 | ||
79 | err = snd_pcm_plugin_build(plug, "copy", src_format, dst_format, | 85 | err = snd_pcm_plugin_build(plug, "copy", src_format, dst_format, |
80 | 0, &plugin); | 86 | 0, &plugin); |
diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c index f874f6ca3657..6faa1d719206 100644 --- a/sound/core/oss/io.c +++ b/sound/core/oss/io.c | |||
@@ -39,14 +39,17 @@ static snd_pcm_sframes_t io_playback_transfer(struct snd_pcm_plugin *plugin, | |||
39 | struct snd_pcm_plugin_channel *dst_channels, | 39 | struct snd_pcm_plugin_channel *dst_channels, |
40 | snd_pcm_uframes_t frames) | 40 | snd_pcm_uframes_t frames) |
41 | { | 41 | { |
42 | snd_assert(plugin != NULL, return -ENXIO); | 42 | if (snd_BUG_ON(!plugin)) |
43 | snd_assert(src_channels != NULL, return -ENXIO); | 43 | return -ENXIO; |
44 | if (snd_BUG_ON(!src_channels)) | ||
45 | return -ENXIO; | ||
44 | if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { | 46 | if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { |
45 | return pcm_write(plugin->plug, src_channels->area.addr, frames); | 47 | return pcm_write(plugin->plug, src_channels->area.addr, frames); |
46 | } else { | 48 | } else { |
47 | int channel, channels = plugin->dst_format.channels; | 49 | int channel, channels = plugin->dst_format.channels; |
48 | void **bufs = (void**)plugin->extra_data; | 50 | void **bufs = (void**)plugin->extra_data; |
49 | snd_assert(bufs != NULL, return -ENXIO); | 51 | if (snd_BUG_ON(!bufs)) |
52 | return -ENXIO; | ||
50 | for (channel = 0; channel < channels; channel++) { | 53 | for (channel = 0; channel < channels; channel++) { |
51 | if (src_channels[channel].enabled) | 54 | if (src_channels[channel].enabled) |
52 | bufs[channel] = src_channels[channel].area.addr; | 55 | bufs[channel] = src_channels[channel].area.addr; |
@@ -62,14 +65,17 @@ static snd_pcm_sframes_t io_capture_transfer(struct snd_pcm_plugin *plugin, | |||
62 | struct snd_pcm_plugin_channel *dst_channels, | 65 | struct snd_pcm_plugin_channel *dst_channels, |
63 | snd_pcm_uframes_t frames) | 66 | snd_pcm_uframes_t frames) |
64 | { | 67 | { |
65 | snd_assert(plugin != NULL, return -ENXIO); | 68 | if (snd_BUG_ON(!plugin)) |
66 | snd_assert(dst_channels != NULL, return -ENXIO); | 69 | return -ENXIO; |
70 | if (snd_BUG_ON(!dst_channels)) | ||
71 | return -ENXIO; | ||
67 | if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { | 72 | if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { |
68 | return pcm_read(plugin->plug, dst_channels->area.addr, frames); | 73 | return pcm_read(plugin->plug, dst_channels->area.addr, frames); |
69 | } else { | 74 | } else { |
70 | int channel, channels = plugin->dst_format.channels; | 75 | int channel, channels = plugin->dst_format.channels; |
71 | void **bufs = (void**)plugin->extra_data; | 76 | void **bufs = (void**)plugin->extra_data; |
72 | snd_assert(bufs != NULL, return -ENXIO); | 77 | if (snd_BUG_ON(!bufs)) |
78 | return -ENXIO; | ||
73 | for (channel = 0; channel < channels; channel++) { | 79 | for (channel = 0; channel < channels; channel++) { |
74 | if (dst_channels[channel].enabled) | 80 | if (dst_channels[channel].enabled) |
75 | bufs[channel] = dst_channels[channel].area.addr; | 81 | bufs[channel] = dst_channels[channel].area.addr; |
@@ -107,9 +113,11 @@ int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug, | |||
107 | struct snd_pcm_plugin_format format; | 113 | struct snd_pcm_plugin_format format; |
108 | struct snd_pcm_plugin *plugin; | 114 | struct snd_pcm_plugin *plugin; |
109 | 115 | ||
110 | snd_assert(r_plugin != NULL, return -ENXIO); | 116 | if (snd_BUG_ON(!r_plugin)) |
117 | return -ENXIO; | ||
111 | *r_plugin = NULL; | 118 | *r_plugin = NULL; |
112 | snd_assert(plug != NULL && params != NULL, return -ENXIO); | 119 | if (snd_BUG_ON(!plug || !params)) |
120 | return -ENXIO; | ||
113 | format.format = params_format(params); | 121 | format.format = params_format(params); |
114 | format.rate = params_rate(params); | 122 | format.rate = params_rate(params); |
115 | format.channels = params_channels(params); | 123 | format.channels = params_channels(params); |
diff --git a/sound/core/oss/linear.c b/sound/core/oss/linear.c index da3dbd41669e..4c1d16827199 100644 --- a/sound/core/oss/linear.c +++ b/sound/core/oss/linear.c | |||
@@ -92,7 +92,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin, | |||
92 | { | 92 | { |
93 | struct linear_priv *data; | 93 | struct linear_priv *data; |
94 | 94 | ||
95 | snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); | 95 | if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) |
96 | return -ENXIO; | ||
96 | data = (struct linear_priv *)plugin->extra_data; | 97 | data = (struct linear_priv *)plugin->extra_data; |
97 | if (frames == 0) | 98 | if (frames == 0) |
98 | return 0; | 99 | return 0; |
@@ -100,12 +101,12 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin, | |||
100 | { | 101 | { |
101 | unsigned int channel; | 102 | unsigned int channel; |
102 | for (channel = 0; channel < plugin->src_format.channels; channel++) { | 103 | for (channel = 0; channel < plugin->src_format.channels; channel++) { |
103 | snd_assert(src_channels[channel].area.first % 8 == 0 && | 104 | if (snd_BUG_ON(src_channels[channel].area.first % 8 || |
104 | src_channels[channel].area.step % 8 == 0, | 105 | src_channels[channel].area.step % 8)) |
105 | return -ENXIO); | 106 | return -ENXIO; |
106 | snd_assert(dst_channels[channel].area.first % 8 == 0 && | 107 | if (snd_BUG_ON(dst_channels[channel].area.first % 8 || |
107 | dst_channels[channel].area.step % 8 == 0, | 108 | dst_channels[channel].area.step % 8)) |
108 | return -ENXIO); | 109 | return -ENXIO; |
109 | } | 110 | } |
110 | } | 111 | } |
111 | #endif | 112 | #endif |
@@ -154,13 +155,17 @@ int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug, | |||
154 | struct linear_priv *data; | 155 | struct linear_priv *data; |
155 | struct snd_pcm_plugin *plugin; | 156 | struct snd_pcm_plugin *plugin; |
156 | 157 | ||
157 | snd_assert(r_plugin != NULL, return -ENXIO); | 158 | if (snd_BUG_ON(!r_plugin)) |
159 | return -ENXIO; | ||
158 | *r_plugin = NULL; | 160 | *r_plugin = NULL; |
159 | 161 | ||
160 | snd_assert(src_format->rate == dst_format->rate, return -ENXIO); | 162 | if (snd_BUG_ON(src_format->rate != dst_format->rate)) |
161 | snd_assert(src_format->channels == dst_format->channels, return -ENXIO); | 163 | return -ENXIO; |
162 | snd_assert(snd_pcm_format_linear(src_format->format) && | 164 | if (snd_BUG_ON(src_format->channels != dst_format->channels)) |
163 | snd_pcm_format_linear(dst_format->format), return -ENXIO); | 165 | return -ENXIO; |
166 | if (snd_BUG_ON(!snd_pcm_format_linear(src_format->format) || | ||
167 | !snd_pcm_format_linear(dst_format->format))) | ||
168 | return -ENXIO; | ||
164 | 169 | ||
165 | err = snd_pcm_plugin_build(plug, "linear format conversion", | 170 | err = snd_pcm_plugin_build(plug, "linear format conversion", |
166 | src_format, dst_format, | 171 | src_format, dst_format, |
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 581aa2c60e65..4690b8b5681f 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c | |||
@@ -257,8 +257,10 @@ static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot) | |||
257 | result = pslot->get_volume(fmixer, pslot, &left, &right); | 257 | result = pslot->get_volume(fmixer, pslot, &left, &right); |
258 | if (!pslot->stereo) | 258 | if (!pslot->stereo) |
259 | right = left; | 259 | right = left; |
260 | snd_assert(left >= 0 && left <= 100, return -EIO); | 260 | if (snd_BUG_ON(left < 0 || left > 100)) |
261 | snd_assert(right >= 0 && right <= 100, return -EIO); | 261 | return -EIO; |
262 | if (snd_BUG_ON(right < 0 || right > 100)) | ||
263 | return -EIO; | ||
262 | if (result >= 0) { | 264 | if (result >= 0) { |
263 | pslot->volume[0] = left; | 265 | pslot->volume[0] = left; |
264 | pslot->volume[1] = right; | 266 | pslot->volume[1] = right; |
@@ -298,7 +300,8 @@ static int snd_mixer_oss_ioctl1(struct snd_mixer_oss_file *fmixer, unsigned int | |||
298 | int __user *p = argp; | 300 | int __user *p = argp; |
299 | int tmp; | 301 | int tmp; |
300 | 302 | ||
301 | snd_assert(fmixer != NULL, return -ENXIO); | 303 | if (snd_BUG_ON(!fmixer)) |
304 | return -ENXIO; | ||
302 | if (((cmd >> 8) & 0xff) == 'M') { | 305 | if (((cmd >> 8) & 0xff) == 'M') { |
303 | switch (cmd) { | 306 | switch (cmd) { |
304 | case SOUND_MIXER_INFO: | 307 | case SOUND_MIXER_INFO: |
@@ -368,7 +371,8 @@ int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned l | |||
368 | { | 371 | { |
369 | struct snd_mixer_oss_file fmixer; | 372 | struct snd_mixer_oss_file fmixer; |
370 | 373 | ||
371 | snd_assert(card != NULL, return -ENXIO); | 374 | if (snd_BUG_ON(!card)) |
375 | return -ENXIO; | ||
372 | if (card->mixer_oss == NULL) | 376 | if (card->mixer_oss == NULL) |
373 | return -ENXIO; | 377 | return -ENXIO; |
374 | memset(&fmixer, 0, sizeof(fmixer)); | 378 | memset(&fmixer, 0, sizeof(fmixer)); |
@@ -1284,9 +1288,11 @@ static int snd_mixer_oss_free1(void *private) | |||
1284 | struct snd_card *card; | 1288 | struct snd_card *card; |
1285 | int idx; | 1289 | int idx; |
1286 | 1290 | ||
1287 | snd_assert(mixer != NULL, return -ENXIO); | 1291 | if (!mixer) |
1292 | return 0; | ||
1288 | card = mixer->card; | 1293 | card = mixer->card; |
1289 | snd_assert(mixer == card->mixer_oss, return -ENXIO); | 1294 | if (snd_BUG_ON(mixer != card->mixer_oss)) |
1295 | return -ENXIO; | ||
1290 | card->mixer_oss = NULL; | 1296 | card->mixer_oss = NULL; |
1291 | for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) { | 1297 | for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) { |
1292 | struct snd_mixer_oss_slot *chn = &mixer->slots[idx]; | 1298 | struct snd_mixer_oss_slot *chn = &mixer->slots[idx]; |
diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c index 77f96194a0ed..f7649d4d950b 100644 --- a/sound/core/oss/mulaw.c +++ b/sound/core/oss/mulaw.c | |||
@@ -252,19 +252,20 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin, | |||
252 | { | 252 | { |
253 | struct mulaw_priv *data; | 253 | struct mulaw_priv *data; |
254 | 254 | ||
255 | snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); | 255 | if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) |
256 | return -ENXIO; | ||
256 | if (frames == 0) | 257 | if (frames == 0) |
257 | return 0; | 258 | return 0; |
258 | #ifdef CONFIG_SND_DEBUG | 259 | #ifdef CONFIG_SND_DEBUG |
259 | { | 260 | { |
260 | unsigned int channel; | 261 | unsigned int channel; |
261 | for (channel = 0; channel < plugin->src_format.channels; channel++) { | 262 | for (channel = 0; channel < plugin->src_format.channels; channel++) { |
262 | snd_assert(src_channels[channel].area.first % 8 == 0 && | 263 | if (snd_BUG_ON(src_channels[channel].area.first % 8 || |
263 | src_channels[channel].area.step % 8 == 0, | 264 | src_channels[channel].area.step % 8)) |
264 | return -ENXIO); | 265 | return -ENXIO; |
265 | snd_assert(dst_channels[channel].area.first % 8 == 0 && | 266 | if (snd_BUG_ON(dst_channels[channel].area.first % 8 || |
266 | dst_channels[channel].area.step % 8 == 0, | 267 | dst_channels[channel].area.step % 8)) |
267 | return -ENXIO); | 268 | return -ENXIO; |
268 | } | 269 | } |
269 | } | 270 | } |
270 | #endif | 271 | #endif |
@@ -305,11 +306,14 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug, | |||
305 | struct snd_pcm_plugin_format *format; | 306 | struct snd_pcm_plugin_format *format; |
306 | mulaw_f func; | 307 | mulaw_f func; |
307 | 308 | ||
308 | snd_assert(r_plugin != NULL, return -ENXIO); | 309 | if (snd_BUG_ON(!r_plugin)) |
310 | return -ENXIO; | ||
309 | *r_plugin = NULL; | 311 | *r_plugin = NULL; |
310 | 312 | ||
311 | snd_assert(src_format->rate == dst_format->rate, return -ENXIO); | 313 | if (snd_BUG_ON(src_format->rate != dst_format->rate)) |
312 | snd_assert(src_format->channels == dst_format->channels, return -ENXIO); | 314 | return -ENXIO; |
315 | if (snd_BUG_ON(src_format->channels != dst_format->channels)) | ||
316 | return -ENXIO; | ||
313 | 317 | ||
314 | if (dst_format->format == SNDRV_PCM_FORMAT_MU_LAW) { | 318 | if (dst_format->format == SNDRV_PCM_FORMAT_MU_LAW) { |
315 | format = src_format; | 319 | format = src_format; |
@@ -323,7 +327,8 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug, | |||
323 | snd_BUG(); | 327 | snd_BUG(); |
324 | return -EINVAL; | 328 | return -EINVAL; |
325 | } | 329 | } |
326 | snd_assert(snd_pcm_format_linear(format->format) != 0, return -ENXIO); | 330 | if (snd_BUG_ON(!snd_pcm_format_linear(format->format))) |
331 | return -ENXIO; | ||
327 | 332 | ||
328 | err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", | 333 | err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", |
329 | src_format, dst_format, | 334 | src_format, dst_format, |
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 4c601b192ddf..1af62b8b86c6 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c | |||
@@ -452,7 +452,8 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm, | |||
452 | } else { | 452 | } else { |
453 | *params = *save; | 453 | *params = *save; |
454 | max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); | 454 | max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); |
455 | snd_assert(max >= 0, return -EINVAL); | 455 | if (max < 0) |
456 | return max; | ||
456 | last = 1; | 457 | last = 1; |
457 | } | 458 | } |
458 | _end: | 459 | _end: |
@@ -461,7 +462,7 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm, | |||
461 | v = snd_pcm_hw_param_last(pcm, params, var, dir); | 462 | v = snd_pcm_hw_param_last(pcm, params, var, dir); |
462 | else | 463 | else |
463 | v = snd_pcm_hw_param_first(pcm, params, var, dir); | 464 | v = snd_pcm_hw_param_first(pcm, params, var, dir); |
464 | snd_assert(v >= 0, return -EINVAL); | 465 | snd_BUG_ON(v < 0); |
465 | return v; | 466 | return v; |
466 | } | 467 | } |
467 | 468 | ||
@@ -778,7 +779,8 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, | |||
778 | while (oss_period_size * oss_periods > oss_buffer_size) | 779 | while (oss_period_size * oss_periods > oss_buffer_size) |
779 | oss_period_size /= 2; | 780 | oss_period_size /= 2; |
780 | 781 | ||
781 | snd_assert(oss_period_size >= 16, return -EINVAL); | 782 | if (oss_period_size < 16) |
783 | return -EINVAL; | ||
782 | runtime->oss.period_bytes = oss_period_size; | 784 | runtime->oss.period_bytes = oss_period_size; |
783 | runtime->oss.period_frames = 1; | 785 | runtime->oss.period_frames = 1; |
784 | runtime->oss.periods = oss_periods; | 786 | runtime->oss.periods = oss_periods; |
@@ -895,7 +897,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
895 | } | 897 | } |
896 | } | 898 | } |
897 | err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); | 899 | err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); |
898 | snd_assert(err >= 0, goto failure); | 900 | if (err < 0) |
901 | goto failure; | ||
899 | 902 | ||
900 | if (direct) { | 903 | if (direct) { |
901 | memcpy(params, sparams, sizeof(*params)); | 904 | memcpy(params, sparams, sizeof(*params)); |
@@ -958,11 +961,13 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
958 | 961 | ||
959 | n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); | 962 | n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); |
960 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); | 963 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); |
961 | snd_assert(err >= 0, goto failure); | 964 | if (err < 0) |
965 | goto failure; | ||
962 | 966 | ||
963 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, | 967 | err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, |
964 | runtime->oss.periods, NULL); | 968 | runtime->oss.periods, NULL); |
965 | snd_assert(err >= 0, goto failure); | 969 | if (err < 0) |
970 | goto failure; | ||
966 | 971 | ||
967 | snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); | 972 | snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); |
968 | 973 | ||
@@ -1006,7 +1011,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
1006 | 1011 | ||
1007 | runtime->oss.periods = params_periods(sparams); | 1012 | runtime->oss.periods = params_periods(sparams); |
1008 | oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); | 1013 | oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); |
1009 | snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure); | 1014 | if (oss_period_size < 0) { |
1015 | err = -EINVAL; | ||
1016 | goto failure; | ||
1017 | } | ||
1010 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS | 1018 | #ifdef CONFIG_SND_PCM_OSS_PLUGINS |
1011 | if (runtime->oss.plugin_first) { | 1019 | if (runtime->oss.plugin_first) { |
1012 | err = snd_pcm_plug_alloc(substream, oss_period_size); | 1020 | err = snd_pcm_plug_alloc(substream, oss_period_size); |
@@ -1017,7 +1025,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) | |||
1017 | oss_period_size *= oss_frame_size; | 1025 | oss_period_size *= oss_frame_size; |
1018 | 1026 | ||
1019 | oss_buffer_size = oss_period_size * runtime->oss.periods; | 1027 | oss_buffer_size = oss_period_size * runtime->oss.periods; |
1020 | snd_assert(oss_buffer_size >= 0, err = -EINVAL; goto failure); | 1028 | if (oss_buffer_size < 0) { |
1029 | err = -EINVAL; | ||
1030 | goto failure; | ||
1031 | } | ||
1021 | 1032 | ||
1022 | runtime->oss.period_bytes = oss_period_size; | 1033 | runtime->oss.period_bytes = oss_period_size; |
1023 | runtime->oss.buffer_bytes = oss_buffer_size; | 1034 | runtime->oss.buffer_bytes = oss_buffer_size; |
@@ -1069,7 +1080,8 @@ static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_fil | |||
1069 | return err; | 1080 | return err; |
1070 | } | 1081 | } |
1071 | } | 1082 | } |
1072 | snd_assert(asubstream != NULL, return -EIO); | 1083 | if (!asubstream) |
1084 | return -EIO; | ||
1073 | if (r_substream) | 1085 | if (r_substream) |
1074 | *r_substream = asubstream; | 1086 | *r_substream = asubstream; |
1075 | return 0; | 1087 | return 0; |
@@ -1764,7 +1776,8 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file) | |||
1764 | err = snd_pcm_hw_refine(substream, params); | 1776 | err = snd_pcm_hw_refine(substream, params); |
1765 | format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); | 1777 | format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
1766 | kfree(params); | 1778 | kfree(params); |
1767 | snd_assert(err >= 0, return err); | 1779 | if (err < 0) |
1780 | return err; | ||
1768 | for (fmt = 0; fmt < 32; ++fmt) { | 1781 | for (fmt = 0; fmt < 32; ++fmt) { |
1769 | if (snd_mask_test(&format_mask, fmt)) { | 1782 | if (snd_mask_test(&format_mask, fmt)) { |
1770 | int f = snd_pcm_oss_format_to(fmt); | 1783 | int f = snd_pcm_oss_format_to(fmt); |
@@ -2250,7 +2263,8 @@ static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream, | |||
2250 | static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file) | 2263 | static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file) |
2251 | { | 2264 | { |
2252 | int cidx; | 2265 | int cidx; |
2253 | snd_assert(pcm_oss_file != NULL, return -ENXIO); | 2266 | if (!pcm_oss_file) |
2267 | return 0; | ||
2254 | for (cidx = 0; cidx < 2; ++cidx) { | 2268 | for (cidx = 0; cidx < 2; ++cidx) { |
2255 | struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx]; | 2269 | struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx]; |
2256 | if (substream) | 2270 | if (substream) |
@@ -2271,8 +2285,8 @@ static int snd_pcm_oss_open_file(struct file *file, | |||
2271 | struct snd_pcm_substream *substream; | 2285 | struct snd_pcm_substream *substream; |
2272 | unsigned int f_mode = file->f_mode; | 2286 | unsigned int f_mode = file->f_mode; |
2273 | 2287 | ||
2274 | snd_assert(rpcm_oss_file != NULL, return -EINVAL); | 2288 | if (rpcm_oss_file) |
2275 | *rpcm_oss_file = NULL; | 2289 | *rpcm_oss_file = NULL; |
2276 | 2290 | ||
2277 | pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL); | 2291 | pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL); |
2278 | if (pcm_oss_file == NULL) | 2292 | if (pcm_oss_file == NULL) |
@@ -2312,7 +2326,8 @@ static int snd_pcm_oss_open_file(struct file *file, | |||
2312 | } | 2326 | } |
2313 | 2327 | ||
2314 | file->private_data = pcm_oss_file; | 2328 | file->private_data = pcm_oss_file; |
2315 | *rpcm_oss_file = pcm_oss_file; | 2329 | if (rpcm_oss_file) |
2330 | *rpcm_oss_file = pcm_oss_file; | ||
2316 | return 0; | 2331 | return 0; |
2317 | } | 2332 | } |
2318 | 2333 | ||
@@ -2321,7 +2336,8 @@ static int snd_task_name(struct task_struct *task, char *name, size_t size) | |||
2321 | { | 2336 | { |
2322 | unsigned int idx; | 2337 | unsigned int idx; |
2323 | 2338 | ||
2324 | snd_assert(task != NULL && name != NULL && size >= 2, return -EINVAL); | 2339 | if (snd_BUG_ON(!task || !name || size < 2)) |
2340 | return -EINVAL; | ||
2325 | for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++) | 2341 | for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++) |
2326 | name[idx] = task->comm[idx]; | 2342 | name[idx] = task->comm[idx]; |
2327 | name[idx] = '\0'; | 2343 | name[idx] = '\0'; |
@@ -2415,7 +2431,8 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) | |||
2415 | substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; | 2431 | substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; |
2416 | if (substream == NULL) | 2432 | if (substream == NULL) |
2417 | substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; | 2433 | substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; |
2418 | snd_assert(substream != NULL, return -ENXIO); | 2434 | if (snd_BUG_ON(!substream)) |
2435 | return -ENXIO; | ||
2419 | pcm = substream->pcm; | 2436 | pcm = substream->pcm; |
2420 | if (!pcm->card->shutdown) | 2437 | if (!pcm->card->shutdown) |
2421 | snd_pcm_oss_sync(pcm_oss_file); | 2438 | snd_pcm_oss_sync(pcm_oss_file); |
@@ -2448,7 +2465,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long | |||
2448 | if (substream != NULL) | 2465 | if (substream != NULL) |
2449 | break; | 2466 | break; |
2450 | } | 2467 | } |
2451 | snd_assert(substream != NULL, return -ENXIO); | 2468 | if (snd_BUG_ON(idx >= 2)) |
2469 | return -ENXIO; | ||
2452 | return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg); | 2470 | return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg); |
2453 | } | 2471 | } |
2454 | #endif | 2472 | #endif |
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index bec94138205e..6751daa3bb50 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c | |||
@@ -62,7 +62,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t | |||
62 | if ((width = snd_pcm_format_physical_width(format->format)) < 0) | 62 | if ((width = snd_pcm_format_physical_width(format->format)) < 0) |
63 | return width; | 63 | return width; |
64 | size = frames * format->channels * width; | 64 | size = frames * format->channels * width; |
65 | snd_assert((size % 8) == 0, return -ENXIO); | 65 | if (snd_BUG_ON(size % 8)) |
66 | return -ENXIO; | ||
66 | size /= 8; | 67 | size /= 8; |
67 | if (plugin->buf_frames < frames) { | 68 | if (plugin->buf_frames < frames) { |
68 | vfree(plugin->buf); | 69 | vfree(plugin->buf); |
@@ -84,7 +85,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t | |||
84 | c->area.step = format->channels * width; | 85 | c->area.step = format->channels * width; |
85 | } | 86 | } |
86 | } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { | 87 | } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { |
87 | snd_assert((size % format->channels) == 0,); | 88 | if (snd_BUG_ON(size % format->channels)) |
89 | return -EINVAL; | ||
88 | size /= format->channels; | 90 | size /= format->channels; |
89 | for (channel = 0; channel < format->channels; channel++, c++) { | 91 | for (channel = 0; channel < format->channels; channel++, c++) { |
90 | c->frames = frames; | 92 | c->frames = frames; |
@@ -102,13 +104,15 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t | |||
102 | int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) | 104 | int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) |
103 | { | 105 | { |
104 | int err; | 106 | int err; |
105 | snd_assert(snd_pcm_plug_first(plug) != NULL, return -ENXIO); | 107 | if (snd_BUG_ON(!snd_pcm_plug_first(plug))) |
108 | return -ENXIO; | ||
106 | if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) { | 109 | if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) { |
107 | struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); | 110 | struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); |
108 | while (plugin->next) { | 111 | while (plugin->next) { |
109 | if (plugin->dst_frames) | 112 | if (plugin->dst_frames) |
110 | frames = plugin->dst_frames(plugin, frames); | 113 | frames = plugin->dst_frames(plugin, frames); |
111 | snd_assert(frames > 0, return -ENXIO); | 114 | if (snd_BUG_ON(frames <= 0)) |
115 | return -ENXIO; | ||
112 | plugin = plugin->next; | 116 | plugin = plugin->next; |
113 | err = snd_pcm_plugin_alloc(plugin, frames); | 117 | err = snd_pcm_plugin_alloc(plugin, frames); |
114 | if (err < 0) | 118 | if (err < 0) |
@@ -119,7 +123,8 @@ int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) | |||
119 | while (plugin->prev) { | 123 | while (plugin->prev) { |
120 | if (plugin->src_frames) | 124 | if (plugin->src_frames) |
121 | frames = plugin->src_frames(plugin, frames); | 125 | frames = plugin->src_frames(plugin, frames); |
122 | snd_assert(frames > 0, return -ENXIO); | 126 | if (snd_BUG_ON(frames <= 0)) |
127 | return -ENXIO; | ||
123 | plugin = plugin->prev; | 128 | plugin = plugin->prev; |
124 | err = snd_pcm_plugin_alloc(plugin, frames); | 129 | err = snd_pcm_plugin_alloc(plugin, frames); |
125 | if (err < 0) | 130 | if (err < 0) |
@@ -148,8 +153,10 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug, | |||
148 | struct snd_pcm_plugin *plugin; | 153 | struct snd_pcm_plugin *plugin; |
149 | unsigned int channels; | 154 | unsigned int channels; |
150 | 155 | ||
151 | snd_assert(plug != NULL, return -ENXIO); | 156 | if (snd_BUG_ON(!plug)) |
152 | snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO); | 157 | return -ENXIO; |
158 | if (snd_BUG_ON(!src_format || !dst_format)) | ||
159 | return -ENXIO; | ||
153 | plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL); | 160 | plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL); |
154 | if (plugin == NULL) | 161 | if (plugin == NULL) |
155 | return -ENOMEM; | 162 | return -ENOMEM; |
@@ -159,10 +166,10 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug, | |||
159 | plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED; | 166 | plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED; |
160 | plugin->src_format = *src_format; | 167 | plugin->src_format = *src_format; |
161 | plugin->src_width = snd_pcm_format_physical_width(src_format->format); | 168 | plugin->src_width = snd_pcm_format_physical_width(src_format->format); |
162 | snd_assert(plugin->src_width > 0, ); | 169 | snd_BUG_ON(plugin->src_width <= 0); |
163 | plugin->dst_format = *dst_format; | 170 | plugin->dst_format = *dst_format; |
164 | plugin->dst_width = snd_pcm_format_physical_width(dst_format->format); | 171 | plugin->dst_width = snd_pcm_format_physical_width(dst_format->format); |
165 | snd_assert(plugin->dst_width > 0, ); | 172 | snd_BUG_ON(plugin->dst_width <= 0); |
166 | if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) | 173 | if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) |
167 | channels = src_format->channels; | 174 | channels = src_format->channels; |
168 | else | 175 | else |
@@ -194,7 +201,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p | |||
194 | struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; | 201 | struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; |
195 | int stream = snd_pcm_plug_stream(plug); | 202 | int stream = snd_pcm_plug_stream(plug); |
196 | 203 | ||
197 | snd_assert(plug != NULL, return -ENXIO); | 204 | if (snd_BUG_ON(!plug)) |
205 | return -ENXIO; | ||
198 | if (drv_frames == 0) | 206 | if (drv_frames == 0) |
199 | return 0; | 207 | return 0; |
200 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 208 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
@@ -224,7 +232,8 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc | |||
224 | snd_pcm_sframes_t frames; | 232 | snd_pcm_sframes_t frames; |
225 | int stream = snd_pcm_plug_stream(plug); | 233 | int stream = snd_pcm_plug_stream(plug); |
226 | 234 | ||
227 | snd_assert(plug != NULL, return -ENXIO); | 235 | if (snd_BUG_ON(!plug)) |
236 | return -ENXIO; | ||
228 | if (clt_frames == 0) | 237 | if (clt_frames == 0) |
229 | return 0; | 238 | return 0; |
230 | frames = clt_frames; | 239 | frames = clt_frames; |
@@ -540,7 +549,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu | |||
540 | int width, nchannels, channel; | 549 | int width, nchannels, channel; |
541 | int stream = snd_pcm_plug_stream(plug); | 550 | int stream = snd_pcm_plug_stream(plug); |
542 | 551 | ||
543 | snd_assert(buf != NULL, return -ENXIO); | 552 | if (snd_BUG_ON(!buf)) |
553 | return -ENXIO; | ||
544 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 554 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
545 | plugin = snd_pcm_plug_first(plug); | 555 | plugin = snd_pcm_plug_first(plug); |
546 | format = &plugin->src_format; | 556 | format = &plugin->src_format; |
@@ -553,7 +563,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu | |||
553 | if ((width = snd_pcm_format_physical_width(format->format)) < 0) | 563 | if ((width = snd_pcm_format_physical_width(format->format)) < 0) |
554 | return width; | 564 | return width; |
555 | nchannels = format->channels; | 565 | nchannels = format->channels; |
556 | snd_assert(plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || format->channels <= 1, return -ENXIO); | 566 | if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && |
567 | format->channels > 1)) | ||
568 | return -ENXIO; | ||
557 | for (channel = 0; channel < nchannels; channel++, v++) { | 569 | for (channel = 0; channel < nchannels; channel++, v++) { |
558 | v->frames = count; | 570 | v->frames = count; |
559 | v->enabled = 1; | 571 | v->enabled = 1; |
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c index 14dfb3175d84..a466443c4a26 100644 --- a/sound/core/oss/rate.c +++ b/sound/core/oss/rate.c | |||
@@ -185,7 +185,8 @@ static snd_pcm_sframes_t rate_src_frames(struct snd_pcm_plugin *plugin, snd_pcm_ | |||
185 | struct rate_priv *data; | 185 | struct rate_priv *data; |
186 | snd_pcm_sframes_t res; | 186 | snd_pcm_sframes_t res; |
187 | 187 | ||
188 | snd_assert(plugin != NULL, return -ENXIO); | 188 | if (snd_BUG_ON(!plugin)) |
189 | return -ENXIO; | ||
189 | if (frames == 0) | 190 | if (frames == 0) |
190 | return 0; | 191 | return 0; |
191 | data = (struct rate_priv *)plugin->extra_data; | 192 | data = (struct rate_priv *)plugin->extra_data; |
@@ -217,7 +218,8 @@ static snd_pcm_sframes_t rate_dst_frames(struct snd_pcm_plugin *plugin, snd_pcm_ | |||
217 | struct rate_priv *data; | 218 | struct rate_priv *data; |
218 | snd_pcm_sframes_t res; | 219 | snd_pcm_sframes_t res; |
219 | 220 | ||
220 | snd_assert(plugin != NULL, return -ENXIO); | 221 | if (snd_BUG_ON(!plugin)) |
222 | return -ENXIO; | ||
221 | if (frames == 0) | 223 | if (frames == 0) |
222 | return 0; | 224 | return 0; |
223 | data = (struct rate_priv *)plugin->extra_data; | 225 | data = (struct rate_priv *)plugin->extra_data; |
@@ -252,19 +254,20 @@ static snd_pcm_sframes_t rate_transfer(struct snd_pcm_plugin *plugin, | |||
252 | snd_pcm_uframes_t dst_frames; | 254 | snd_pcm_uframes_t dst_frames; |
253 | struct rate_priv *data; | 255 | struct rate_priv *data; |
254 | 256 | ||
255 | snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); | 257 | if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) |
258 | return -ENXIO; | ||
256 | if (frames == 0) | 259 | if (frames == 0) |
257 | return 0; | 260 | return 0; |
258 | #ifdef CONFIG_SND_DEBUG | 261 | #ifdef CONFIG_SND_DEBUG |
259 | { | 262 | { |
260 | unsigned int channel; | 263 | unsigned int channel; |
261 | for (channel = 0; channel < plugin->src_format.channels; channel++) { | 264 | for (channel = 0; channel < plugin->src_format.channels; channel++) { |
262 | snd_assert(src_channels[channel].area.first % 8 == 0 && | 265 | if (snd_BUG_ON(src_channels[channel].area.first % 8 || |
263 | src_channels[channel].area.step % 8 == 0, | 266 | src_channels[channel].area.step % 8)) |
264 | return -ENXIO); | 267 | return -ENXIO; |
265 | snd_assert(dst_channels[channel].area.first % 8 == 0 && | 268 | if (snd_BUG_ON(dst_channels[channel].area.first % 8 || |
266 | dst_channels[channel].area.step % 8 == 0, | 269 | dst_channels[channel].area.step % 8)) |
267 | return -ENXIO); | 270 | return -ENXIO; |
268 | } | 271 | } |
269 | } | 272 | } |
270 | #endif | 273 | #endif |
@@ -281,7 +284,8 @@ static int rate_action(struct snd_pcm_plugin *plugin, | |||
281 | enum snd_pcm_plugin_action action, | 284 | enum snd_pcm_plugin_action action, |
282 | unsigned long udata) | 285 | unsigned long udata) |
283 | { | 286 | { |
284 | snd_assert(plugin != NULL, return -ENXIO); | 287 | if (snd_BUG_ON(!plugin)) |
288 | return -ENXIO; | ||
285 | switch (action) { | 289 | switch (action) { |
286 | case INIT: | 290 | case INIT: |
287 | case PREPARE: | 291 | case PREPARE: |
@@ -302,14 +306,20 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug, | |||
302 | struct rate_priv *data; | 306 | struct rate_priv *data; |
303 | struct snd_pcm_plugin *plugin; | 307 | struct snd_pcm_plugin *plugin; |
304 | 308 | ||
305 | snd_assert(r_plugin != NULL, return -ENXIO); | 309 | if (snd_BUG_ON(!r_plugin)) |
310 | return -ENXIO; | ||
306 | *r_plugin = NULL; | 311 | *r_plugin = NULL; |
307 | 312 | ||
308 | snd_assert(src_format->channels == dst_format->channels, return -ENXIO); | 313 | if (snd_BUG_ON(src_format->channels != dst_format->channels)) |
309 | snd_assert(src_format->channels > 0, return -ENXIO); | 314 | return -ENXIO; |
310 | snd_assert(src_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); | 315 | if (snd_BUG_ON(src_format->channels <= 0)) |
311 | snd_assert(dst_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); | 316 | return -ENXIO; |
312 | snd_assert(src_format->rate != dst_format->rate, return -ENXIO); | 317 | if (snd_BUG_ON(src_format->format != SNDRV_PCM_FORMAT_S16)) |
318 | return -ENXIO; | ||
319 | if (snd_BUG_ON(dst_format->format != SNDRV_PCM_FORMAT_S16)) | ||
320 | return -ENXIO; | ||
321 | if (snd_BUG_ON(src_format->rate == dst_format->rate)) | ||
322 | return -ENXIO; | ||
313 | 323 | ||
314 | err = snd_pcm_plugin_build(plug, "rate conversion", | 324 | err = snd_pcm_plugin_build(plug, "rate conversion", |
315 | src_format, dst_format, | 325 | src_format, dst_format, |
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c index da7ab7a3e82c..0dcc2870d537 100644 --- a/sound/core/oss/route.c +++ b/sound/core/oss/route.c | |||
@@ -54,7 +54,8 @@ static snd_pcm_sframes_t route_transfer(struct snd_pcm_plugin *plugin, | |||
54 | struct snd_pcm_plugin_channel *dvp; | 54 | struct snd_pcm_plugin_channel *dvp; |
55 | int format; | 55 | int format; |
56 | 56 | ||
57 | snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); | 57 | if (snd_BUG_ON(!plugin || !src_channels || !dst_channels)) |
58 | return -ENXIO; | ||
58 | if (frames == 0) | 59 | if (frames == 0) |
59 | return 0; | 60 | return 0; |
60 | 61 | ||
@@ -90,10 +91,13 @@ int snd_pcm_plugin_build_route(struct snd_pcm_substream *plug, | |||
90 | struct snd_pcm_plugin *plugin; | 91 | struct snd_pcm_plugin *plugin; |
91 | int err; | 92 | int err; |
92 | 93 | ||
93 | snd_assert(r_plugin != NULL, return -ENXIO); | 94 | if (snd_BUG_ON(!r_plugin)) |
95 | return -ENXIO; | ||
94 | *r_plugin = NULL; | 96 | *r_plugin = NULL; |
95 | snd_assert(src_format->rate == dst_format->rate, return -ENXIO); | 97 | if (snd_BUG_ON(src_format->rate != dst_format->rate)) |
96 | snd_assert(src_format->format == dst_format->format, return -ENXIO); | 98 | return -ENXIO; |
99 | if (snd_BUG_ON(src_format->format != dst_format->format)) | ||
100 | return -ENXIO; | ||
97 | 101 | ||
98 | err = snd_pcm_plugin_build(plug, "route conversion", | 102 | err = snd_pcm_plugin_build(plug, "route conversion", |
99 | src_format, dst_format, 0, &plugin); | 103 | src_format, dst_format, 0, &plugin); |
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9dd9bc73fe1d..192a433a2403 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -42,7 +42,7 @@ static int snd_pcm_dev_free(struct snd_device *device); | |||
42 | static int snd_pcm_dev_register(struct snd_device *device); | 42 | static int snd_pcm_dev_register(struct snd_device *device); |
43 | static int snd_pcm_dev_disconnect(struct snd_device *device); | 43 | static int snd_pcm_dev_disconnect(struct snd_device *device); |
44 | 44 | ||
45 | static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device) | 45 | static struct snd_pcm *snd_pcm_get(struct snd_card *card, int device) |
46 | { | 46 | { |
47 | struct snd_pcm *pcm; | 47 | struct snd_pcm *pcm; |
48 | 48 | ||
@@ -53,6 +53,37 @@ static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device) | |||
53 | return NULL; | 53 | return NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | static int snd_pcm_next(struct snd_card *card, int device) | ||
57 | { | ||
58 | struct snd_pcm *pcm; | ||
59 | |||
60 | list_for_each_entry(pcm, &snd_pcm_devices, list) { | ||
61 | if (pcm->card == card && pcm->device > device) | ||
62 | return pcm->device; | ||
63 | else if (pcm->card->number > card->number) | ||
64 | return -1; | ||
65 | } | ||
66 | return -1; | ||
67 | } | ||
68 | |||
69 | static int snd_pcm_add(struct snd_pcm *newpcm) | ||
70 | { | ||
71 | struct snd_pcm *pcm; | ||
72 | |||
73 | list_for_each_entry(pcm, &snd_pcm_devices, list) { | ||
74 | if (pcm->card == newpcm->card && pcm->device == newpcm->device) | ||
75 | return -EBUSY; | ||
76 | if (pcm->card->number > newpcm->card->number || | ||
77 | (pcm->card == newpcm->card && | ||
78 | pcm->device > newpcm->device)) { | ||
79 | list_add(&newpcm->list, pcm->list.prev); | ||
80 | return 0; | ||
81 | } | ||
82 | } | ||
83 | list_add_tail(&newpcm->list, &snd_pcm_devices); | ||
84 | return 0; | ||
85 | } | ||
86 | |||
56 | static int snd_pcm_control_ioctl(struct snd_card *card, | 87 | static int snd_pcm_control_ioctl(struct snd_card *card, |
57 | struct snd_ctl_file *control, | 88 | struct snd_ctl_file *control, |
58 | unsigned int cmd, unsigned long arg) | 89 | unsigned int cmd, unsigned long arg) |
@@ -65,14 +96,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, | |||
65 | if (get_user(device, (int __user *)arg)) | 96 | if (get_user(device, (int __user *)arg)) |
66 | return -EFAULT; | 97 | return -EFAULT; |
67 | mutex_lock(®ister_mutex); | 98 | mutex_lock(®ister_mutex); |
68 | device = device < 0 ? 0 : device + 1; | 99 | device = snd_pcm_next(card, device); |
69 | while (device < SNDRV_PCM_DEVICES) { | ||
70 | if (snd_pcm_search(card, device)) | ||
71 | break; | ||
72 | device++; | ||
73 | } | ||
74 | if (device == SNDRV_PCM_DEVICES) | ||
75 | device = -1; | ||
76 | mutex_unlock(®ister_mutex); | 100 | mutex_unlock(®ister_mutex); |
77 | if (put_user(device, (int __user *)arg)) | 101 | if (put_user(device, (int __user *)arg)) |
78 | return -EFAULT; | 102 | return -EFAULT; |
@@ -98,7 +122,7 @@ static int snd_pcm_control_ioctl(struct snd_card *card, | |||
98 | if (get_user(subdevice, &info->subdevice)) | 122 | if (get_user(subdevice, &info->subdevice)) |
99 | return -EFAULT; | 123 | return -EFAULT; |
100 | mutex_lock(®ister_mutex); | 124 | mutex_lock(®ister_mutex); |
101 | pcm = snd_pcm_search(card, device); | 125 | pcm = snd_pcm_get(card, device); |
102 | if (pcm == NULL) { | 126 | if (pcm == NULL) { |
103 | err = -ENXIO; | 127 | err = -ENXIO; |
104 | goto _error; | 128 | goto _error; |
@@ -232,7 +256,6 @@ static char *snd_pcm_tstamp_mode_names[] = { | |||
232 | 256 | ||
233 | static const char *snd_pcm_stream_name(int stream) | 257 | static const char *snd_pcm_stream_name(int stream) |
234 | { | 258 | { |
235 | snd_assert(stream <= SNDRV_PCM_STREAM_LAST, return NULL); | ||
236 | return snd_pcm_stream_names[stream]; | 259 | return snd_pcm_stream_names[stream]; |
237 | } | 260 | } |
238 | 261 | ||
@@ -248,7 +271,6 @@ static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) | |||
248 | 271 | ||
249 | static const char *snd_pcm_tstamp_mode_name(int mode) | 272 | static const char *snd_pcm_tstamp_mode_name(int mode) |
250 | { | 273 | { |
251 | snd_assert(mode <= SNDRV_PCM_TSTAMP_LAST, return NULL); | ||
252 | return snd_pcm_tstamp_mode_names[mode]; | 274 | return snd_pcm_tstamp_mode_names[mode]; |
253 | } | 275 | } |
254 | 276 | ||
@@ -682,9 +704,10 @@ int snd_pcm_new(struct snd_card *card, char *id, int device, | |||
682 | .dev_disconnect = snd_pcm_dev_disconnect, | 704 | .dev_disconnect = snd_pcm_dev_disconnect, |
683 | }; | 705 | }; |
684 | 706 | ||
685 | snd_assert(rpcm != NULL, return -EINVAL); | 707 | if (snd_BUG_ON(!card)) |
686 | *rpcm = NULL; | 708 | return -ENXIO; |
687 | snd_assert(card != NULL, return -ENXIO); | 709 | if (rpcm) |
710 | *rpcm = NULL; | ||
688 | pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); | 711 | pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); |
689 | if (pcm == NULL) { | 712 | if (pcm == NULL) { |
690 | snd_printk(KERN_ERR "Cannot allocate PCM\n"); | 713 | snd_printk(KERN_ERR "Cannot allocate PCM\n"); |
@@ -708,7 +731,8 @@ int snd_pcm_new(struct snd_card *card, char *id, int device, | |||
708 | snd_pcm_free(pcm); | 731 | snd_pcm_free(pcm); |
709 | return err; | 732 | return err; |
710 | } | 733 | } |
711 | *rpcm = pcm; | 734 | if (rpcm) |
735 | *rpcm = pcm; | ||
712 | return 0; | 736 | return 0; |
713 | } | 737 | } |
714 | 738 | ||
@@ -742,7 +766,8 @@ static int snd_pcm_free(struct snd_pcm *pcm) | |||
742 | { | 766 | { |
743 | struct snd_pcm_notify *notify; | 767 | struct snd_pcm_notify *notify; |
744 | 768 | ||
745 | snd_assert(pcm != NULL, return -ENXIO); | 769 | if (!pcm) |
770 | return 0; | ||
746 | list_for_each_entry(notify, &snd_pcm_notify_list, list) { | 771 | list_for_each_entry(notify, &snd_pcm_notify_list, list) { |
747 | notify->n_unregister(pcm); | 772 | notify->n_unregister(pcm); |
748 | } | 773 | } |
@@ -773,15 +798,15 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, | |||
773 | int prefer_subdevice = -1; | 798 | int prefer_subdevice = -1; |
774 | size_t size; | 799 | size_t size; |
775 | 800 | ||
776 | snd_assert(rsubstream != NULL, return -EINVAL); | 801 | if (snd_BUG_ON(!pcm || !rsubstream)) |
802 | return -ENXIO; | ||
777 | *rsubstream = NULL; | 803 | *rsubstream = NULL; |
778 | snd_assert(pcm != NULL, return -ENXIO); | ||
779 | pstr = &pcm->streams[stream]; | 804 | pstr = &pcm->streams[stream]; |
780 | if (pstr->substream == NULL || pstr->substream_count == 0) | 805 | if (pstr->substream == NULL || pstr->substream_count == 0) |
781 | return -ENODEV; | 806 | return -ENODEV; |
782 | 807 | ||
783 | card = pcm->card; | 808 | card = pcm->card; |
784 | down_read(&card->controls_rwsem); | 809 | read_lock(&card->ctl_files_rwlock); |
785 | list_for_each_entry(kctl, &card->ctl_files, list) { | 810 | list_for_each_entry(kctl, &card->ctl_files, list) { |
786 | if (kctl->pid == current->pid) { | 811 | if (kctl->pid == current->pid) { |
787 | prefer_subdevice = kctl->prefer_pcm_subdevice; | 812 | prefer_subdevice = kctl->prefer_pcm_subdevice; |
@@ -789,7 +814,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream, | |||
789 | break; | 814 | break; |
790 | } | 815 | } |
791 | } | 816 | } |
792 | up_read(&card->controls_rwsem); | 817 | read_unlock(&card->ctl_files_rwlock); |
793 | 818 | ||
794 | switch (stream) { | 819 | switch (stream) { |
795 | case SNDRV_PCM_STREAM_PLAYBACK: | 820 | case SNDRV_PCM_STREAM_PLAYBACK: |
@@ -883,8 +908,9 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream) | |||
883 | { | 908 | { |
884 | struct snd_pcm_runtime *runtime; | 909 | struct snd_pcm_runtime *runtime; |
885 | 910 | ||
911 | if (PCM_RUNTIME_CHECK(substream)) | ||
912 | return; | ||
886 | runtime = substream->runtime; | 913 | runtime = substream->runtime; |
887 | snd_assert(runtime != NULL, return); | ||
888 | if (runtime->private_free != NULL) | 914 | if (runtime->private_free != NULL) |
889 | runtime->private_free(runtime); | 915 | runtime->private_free(runtime); |
890 | snd_free_pages((void*)runtime->status, | 916 | snd_free_pages((void*)runtime->status, |
@@ -929,13 +955,14 @@ static int snd_pcm_dev_register(struct snd_device *device) | |||
929 | struct snd_pcm *pcm = device->device_data; | 955 | struct snd_pcm *pcm = device->device_data; |
930 | struct device *dev; | 956 | struct device *dev; |
931 | 957 | ||
932 | snd_assert(pcm != NULL && device != NULL, return -ENXIO); | 958 | if (snd_BUG_ON(!pcm || !device)) |
959 | return -ENXIO; | ||
933 | mutex_lock(®ister_mutex); | 960 | mutex_lock(®ister_mutex); |
934 | if (snd_pcm_search(pcm->card, pcm->device)) { | 961 | err = snd_pcm_add(pcm); |
962 | if (err) { | ||
935 | mutex_unlock(®ister_mutex); | 963 | mutex_unlock(®ister_mutex); |
936 | return -EBUSY; | 964 | return err; |
937 | } | 965 | } |
938 | list_add_tail(&pcm->list, &snd_pcm_devices); | ||
939 | for (cidx = 0; cidx < 2; cidx++) { | 966 | for (cidx = 0; cidx < 2; cidx++) { |
940 | int devtype = -1; | 967 | int devtype = -1; |
941 | if (pcm->streams[cidx].substream == NULL) | 968 | if (pcm->streams[cidx].substream == NULL) |
@@ -1019,10 +1046,11 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) | |||
1019 | { | 1046 | { |
1020 | struct snd_pcm *pcm; | 1047 | struct snd_pcm *pcm; |
1021 | 1048 | ||
1022 | snd_assert(notify != NULL && | 1049 | if (snd_BUG_ON(!notify || |
1023 | notify->n_register != NULL && | 1050 | !notify->n_register || |
1024 | notify->n_unregister != NULL && | 1051 | !notify->n_unregister || |
1025 | notify->n_disconnect, return -EINVAL); | 1052 | !notify->n_disconnect)) |
1053 | return -EINVAL; | ||
1026 | mutex_lock(®ister_mutex); | 1054 | mutex_lock(®ister_mutex); |
1027 | if (nfree) { | 1055 | if (nfree) { |
1028 | list_del(¬ify->list); | 1056 | list_del(¬ify->list); |
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 49aa693fba8a..36d7a5998234 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c | |||
@@ -397,7 +397,8 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, | |||
397 | snd_pcm_uframes_t boundary; | 397 | snd_pcm_uframes_t boundary; |
398 | int err; | 398 | int err; |
399 | 399 | ||
400 | snd_assert(runtime, return -EINVAL); | 400 | if (snd_BUG_ON(!runtime)) |
401 | return -EINVAL; | ||
401 | 402 | ||
402 | if (get_user(sflags, &src->flags) || | 403 | if (get_user(sflags, &src->flags) || |
403 | get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || | 404 | get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) || |
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 1533f0379e9d..6ea5cfb83998 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -85,7 +85,8 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram | |||
85 | } | 85 | } |
86 | frames = runtime->buffer_size - runtime->silence_filled; | 86 | frames = runtime->buffer_size - runtime->silence_filled; |
87 | } | 87 | } |
88 | snd_assert(frames <= runtime->buffer_size, return); | 88 | if (snd_BUG_ON(frames > runtime->buffer_size)) |
89 | return; | ||
89 | if (frames == 0) | 90 | if (frames == 0) |
90 | return; | 91 | return; |
91 | ofs = runtime->silence_start % runtime->buffer_size; | 92 | ofs = runtime->silence_start % runtime->buffer_size; |
@@ -96,7 +97,7 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram | |||
96 | if (substream->ops->silence) { | 97 | if (substream->ops->silence) { |
97 | int err; | 98 | int err; |
98 | err = substream->ops->silence(substream, -1, ofs, transfer); | 99 | err = substream->ops->silence(substream, -1, ofs, transfer); |
99 | snd_assert(err >= 0, ); | 100 | snd_BUG_ON(err < 0); |
100 | } else { | 101 | } else { |
101 | char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, ofs); | 102 | char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, ofs); |
102 | snd_pcm_format_set_silence(runtime->format, hwbuf, transfer * runtime->channels); | 103 | snd_pcm_format_set_silence(runtime->format, hwbuf, transfer * runtime->channels); |
@@ -108,7 +109,7 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram | |||
108 | for (c = 0; c < channels; ++c) { | 109 | for (c = 0; c < channels; ++c) { |
109 | int err; | 110 | int err; |
110 | err = substream->ops->silence(substream, c, ofs, transfer); | 111 | err = substream->ops->silence(substream, c, ofs, transfer); |
111 | snd_assert(err >= 0, ); | 112 | snd_BUG_ON(err < 0); |
112 | } | 113 | } |
113 | } else { | 114 | } else { |
114 | size_t dma_csize = runtime->dma_bytes / channels; | 115 | size_t dma_csize = runtime->dma_bytes / channels; |
@@ -354,7 +355,7 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b, | |||
354 | { | 355 | { |
355 | u_int64_t n = (u_int64_t) a * b; | 356 | u_int64_t n = (u_int64_t) a * b; |
356 | if (c == 0) { | 357 | if (c == 0) { |
357 | snd_assert(n > 0, ); | 358 | snd_BUG_ON(!n); |
358 | *r = 0; | 359 | *r = 0; |
359 | return UINT_MAX; | 360 | return UINT_MAX; |
360 | } | 361 | } |
@@ -380,7 +381,8 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b, | |||
380 | int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) | 381 | int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) |
381 | { | 382 | { |
382 | int changed = 0; | 383 | int changed = 0; |
383 | snd_assert(!snd_interval_empty(i), return -EINVAL); | 384 | if (snd_BUG_ON(snd_interval_empty(i))) |
385 | return -EINVAL; | ||
384 | if (i->min < v->min) { | 386 | if (i->min < v->min) { |
385 | i->min = v->min; | 387 | i->min = v->min; |
386 | i->openmin = v->openmin; | 388 | i->openmin = v->openmin; |
@@ -423,7 +425,8 @@ EXPORT_SYMBOL(snd_interval_refine); | |||
423 | 425 | ||
424 | static int snd_interval_refine_first(struct snd_interval *i) | 426 | static int snd_interval_refine_first(struct snd_interval *i) |
425 | { | 427 | { |
426 | snd_assert(!snd_interval_empty(i), return -EINVAL); | 428 | if (snd_BUG_ON(snd_interval_empty(i))) |
429 | return -EINVAL; | ||
427 | if (snd_interval_single(i)) | 430 | if (snd_interval_single(i)) |
428 | return 0; | 431 | return 0; |
429 | i->max = i->min; | 432 | i->max = i->min; |
@@ -435,7 +438,8 @@ static int snd_interval_refine_first(struct snd_interval *i) | |||
435 | 438 | ||
436 | static int snd_interval_refine_last(struct snd_interval *i) | 439 | static int snd_interval_refine_last(struct snd_interval *i) |
437 | { | 440 | { |
438 | snd_assert(!snd_interval_empty(i), return -EINVAL); | 441 | if (snd_BUG_ON(snd_interval_empty(i))) |
442 | return -EINVAL; | ||
439 | if (snd_interval_single(i)) | 443 | if (snd_interval_single(i)) |
440 | return 0; | 444 | return 0; |
441 | i->min = i->max; | 445 | i->min = i->max; |
@@ -889,7 +893,8 @@ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, | |||
889 | c->private = private; | 893 | c->private = private; |
890 | k = 0; | 894 | k = 0; |
891 | while (1) { | 895 | while (1) { |
892 | snd_assert(k < ARRAY_SIZE(c->deps), return -EINVAL); | 896 | if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) |
897 | return -EINVAL; | ||
893 | c->deps[k++] = dep; | 898 | c->deps[k++] = dep; |
894 | if (dep < 0) | 899 | if (dep < 0) |
895 | break; | 900 | break; |
@@ -1285,7 +1290,8 @@ int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, | |||
1285 | return changed; | 1290 | return changed; |
1286 | if (params->rmask) { | 1291 | if (params->rmask) { |
1287 | int err = snd_pcm_hw_refine(pcm, params); | 1292 | int err = snd_pcm_hw_refine(pcm, params); |
1288 | snd_assert(err >= 0, return err); | 1293 | if (snd_BUG_ON(err < 0)) |
1294 | return err; | ||
1289 | } | 1295 | } |
1290 | return snd_pcm_hw_param_value(params, var, dir); | 1296 | return snd_pcm_hw_param_value(params, var, dir); |
1291 | } | 1297 | } |
@@ -1330,7 +1336,8 @@ int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, | |||
1330 | return changed; | 1336 | return changed; |
1331 | if (params->rmask) { | 1337 | if (params->rmask) { |
1332 | int err = snd_pcm_hw_refine(pcm, params); | 1338 | int err = snd_pcm_hw_refine(pcm, params); |
1333 | snd_assert(err >= 0, return err); | 1339 | if (snd_BUG_ON(err < 0)) |
1340 | return err; | ||
1334 | } | 1341 | } |
1335 | return snd_pcm_hw_param_value(params, var, dir); | 1342 | return snd_pcm_hw_param_value(params, var, dir); |
1336 | } | 1343 | } |
@@ -1368,7 +1375,8 @@ int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, | |||
1368 | err = snd_pcm_hw_param_first(pcm, params, *v, NULL); | 1375 | err = snd_pcm_hw_param_first(pcm, params, *v, NULL); |
1369 | else | 1376 | else |
1370 | err = snd_pcm_hw_param_last(pcm, params, *v, NULL); | 1377 | err = snd_pcm_hw_param_last(pcm, params, *v, NULL); |
1371 | snd_assert(err >= 0, return err); | 1378 | if (snd_BUG_ON(err < 0)) |
1379 | return err; | ||
1372 | } | 1380 | } |
1373 | return 0; | 1381 | return 0; |
1374 | } | 1382 | } |
@@ -1466,9 +1474,9 @@ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) | |||
1466 | struct snd_pcm_runtime *runtime; | 1474 | struct snd_pcm_runtime *runtime; |
1467 | unsigned long flags; | 1475 | unsigned long flags; |
1468 | 1476 | ||
1469 | snd_assert(substream != NULL, return); | 1477 | if (PCM_RUNTIME_CHECK(substream)) |
1478 | return; | ||
1470 | runtime = substream->runtime; | 1479 | runtime = substream->runtime; |
1471 | snd_assert(runtime != NULL, return); | ||
1472 | 1480 | ||
1473 | if (runtime->transfer_ack_begin) | 1481 | if (runtime->transfer_ack_begin) |
1474 | runtime->transfer_ack_begin(substream); | 1482 | runtime->transfer_ack_begin(substream); |
@@ -1567,7 +1575,6 @@ static int snd_pcm_lib_write_transfer(struct snd_pcm_substream *substream, | |||
1567 | return err; | 1575 | return err; |
1568 | } else { | 1576 | } else { |
1569 | char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); | 1577 | char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); |
1570 | snd_assert(runtime->dma_area, return -EFAULT); | ||
1571 | if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames))) | 1578 | if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames))) |
1572 | return -EFAULT; | 1579 | return -EFAULT; |
1573 | } | 1580 | } |
@@ -1629,7 +1636,10 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, | |||
1629 | cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; | 1636 | cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; |
1630 | if (frames > cont) | 1637 | if (frames > cont) |
1631 | frames = cont; | 1638 | frames = cont; |
1632 | snd_assert(frames != 0, snd_pcm_stream_unlock_irq(substream); return -EINVAL); | 1639 | if (snd_BUG_ON(!frames)) { |
1640 | snd_pcm_stream_unlock_irq(substream); | ||
1641 | return -EINVAL; | ||
1642 | } | ||
1633 | appl_ptr = runtime->control->appl_ptr; | 1643 | appl_ptr = runtime->control->appl_ptr; |
1634 | appl_ofs = appl_ptr % runtime->buffer_size; | 1644 | appl_ofs = appl_ptr % runtime->buffer_size; |
1635 | snd_pcm_stream_unlock_irq(substream); | 1645 | snd_pcm_stream_unlock_irq(substream); |
@@ -1669,18 +1679,30 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, | |||
1669 | return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; | 1679 | return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; |
1670 | } | 1680 | } |
1671 | 1681 | ||
1672 | snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size) | 1682 | /* sanity-check for read/write methods */ |
1683 | static int pcm_sanity_check(struct snd_pcm_substream *substream) | ||
1673 | { | 1684 | { |
1674 | struct snd_pcm_runtime *runtime; | 1685 | struct snd_pcm_runtime *runtime; |
1675 | int nonblock; | 1686 | if (PCM_RUNTIME_CHECK(substream)) |
1676 | 1687 | return -ENXIO; | |
1677 | snd_assert(substream != NULL, return -ENXIO); | ||
1678 | runtime = substream->runtime; | 1688 | runtime = substream->runtime; |
1679 | snd_assert(runtime != NULL, return -ENXIO); | 1689 | if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) |
1680 | snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); | 1690 | return -EINVAL; |
1681 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | 1691 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
1682 | return -EBADFD; | 1692 | return -EBADFD; |
1693 | return 0; | ||
1694 | } | ||
1695 | |||
1696 | snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size) | ||
1697 | { | ||
1698 | struct snd_pcm_runtime *runtime; | ||
1699 | int nonblock; | ||
1700 | int err; | ||
1683 | 1701 | ||
1702 | err = pcm_sanity_check(substream); | ||
1703 | if (err < 0) | ||
1704 | return err; | ||
1705 | runtime = substream->runtime; | ||
1684 | nonblock = !!(substream->f_flags & O_NONBLOCK); | 1706 | nonblock = !!(substream->f_flags & O_NONBLOCK); |
1685 | 1707 | ||
1686 | if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && | 1708 | if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && |
@@ -1703,7 +1725,8 @@ static int snd_pcm_lib_writev_transfer(struct snd_pcm_substream *substream, | |||
1703 | int channels = runtime->channels; | 1725 | int channels = runtime->channels; |
1704 | int c; | 1726 | int c; |
1705 | if (substream->ops->copy) { | 1727 | if (substream->ops->copy) { |
1706 | snd_assert(substream->ops->silence != NULL, return -EINVAL); | 1728 | if (snd_BUG_ON(!substream->ops->silence)) |
1729 | return -EINVAL; | ||
1707 | for (c = 0; c < channels; ++c, ++bufs) { | 1730 | for (c = 0; c < channels; ++c, ++bufs) { |
1708 | if (*bufs == NULL) { | 1731 | if (*bufs == NULL) { |
1709 | if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) | 1732 | if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) |
@@ -1717,7 +1740,6 @@ static int snd_pcm_lib_writev_transfer(struct snd_pcm_substream *substream, | |||
1717 | } else { | 1740 | } else { |
1718 | /* default transfer behaviour */ | 1741 | /* default transfer behaviour */ |
1719 | size_t dma_csize = runtime->dma_bytes / channels; | 1742 | size_t dma_csize = runtime->dma_bytes / channels; |
1720 | snd_assert(runtime->dma_area, return -EFAULT); | ||
1721 | for (c = 0; c < channels; ++c, ++bufs) { | 1743 | for (c = 0; c < channels; ++c, ++bufs) { |
1722 | char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, hwoff); | 1744 | char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, hwoff); |
1723 | if (*bufs == NULL) { | 1745 | if (*bufs == NULL) { |
@@ -1738,14 +1760,12 @@ snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream, | |||
1738 | { | 1760 | { |
1739 | struct snd_pcm_runtime *runtime; | 1761 | struct snd_pcm_runtime *runtime; |
1740 | int nonblock; | 1762 | int nonblock; |
1763 | int err; | ||
1741 | 1764 | ||
1742 | snd_assert(substream != NULL, return -ENXIO); | 1765 | err = pcm_sanity_check(substream); |
1766 | if (err < 0) | ||
1767 | return err; | ||
1743 | runtime = substream->runtime; | 1768 | runtime = substream->runtime; |
1744 | snd_assert(runtime != NULL, return -ENXIO); | ||
1745 | snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); | ||
1746 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | ||
1747 | return -EBADFD; | ||
1748 | |||
1749 | nonblock = !!(substream->f_flags & O_NONBLOCK); | 1769 | nonblock = !!(substream->f_flags & O_NONBLOCK); |
1750 | 1770 | ||
1751 | if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) | 1771 | if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) |
@@ -1769,7 +1789,6 @@ static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream, | |||
1769 | return err; | 1789 | return err; |
1770 | } else { | 1790 | } else { |
1771 | char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); | 1791 | char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); |
1772 | snd_assert(runtime->dma_area, return -EFAULT); | ||
1773 | if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, frames))) | 1792 | if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, frames))) |
1774 | return -EFAULT; | 1793 | return -EFAULT; |
1775 | } | 1794 | } |
@@ -1841,7 +1860,10 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, | |||
1841 | cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; | 1860 | cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; |
1842 | if (frames > cont) | 1861 | if (frames > cont) |
1843 | frames = cont; | 1862 | frames = cont; |
1844 | snd_assert(frames != 0, snd_pcm_stream_unlock_irq(substream); return -EINVAL); | 1863 | if (snd_BUG_ON(!frames)) { |
1864 | snd_pcm_stream_unlock_irq(substream); | ||
1865 | return -EINVAL; | ||
1866 | } | ||
1845 | appl_ptr = runtime->control->appl_ptr; | 1867 | appl_ptr = runtime->control->appl_ptr; |
1846 | appl_ofs = appl_ptr % runtime->buffer_size; | 1868 | appl_ofs = appl_ptr % runtime->buffer_size; |
1847 | snd_pcm_stream_unlock_irq(substream); | 1869 | snd_pcm_stream_unlock_irq(substream); |
@@ -1879,14 +1901,12 @@ snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __u | |||
1879 | { | 1901 | { |
1880 | struct snd_pcm_runtime *runtime; | 1902 | struct snd_pcm_runtime *runtime; |
1881 | int nonblock; | 1903 | int nonblock; |
1904 | int err; | ||
1882 | 1905 | ||
1883 | snd_assert(substream != NULL, return -ENXIO); | 1906 | err = pcm_sanity_check(substream); |
1907 | if (err < 0) | ||
1908 | return err; | ||
1884 | runtime = substream->runtime; | 1909 | runtime = substream->runtime; |
1885 | snd_assert(runtime != NULL, return -ENXIO); | ||
1886 | snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); | ||
1887 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | ||
1888 | return -EBADFD; | ||
1889 | |||
1890 | nonblock = !!(substream->f_flags & O_NONBLOCK); | 1910 | nonblock = !!(substream->f_flags & O_NONBLOCK); |
1891 | if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED) | 1911 | if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED) |
1892 | return -EINVAL; | 1912 | return -EINVAL; |
@@ -1916,7 +1936,6 @@ static int snd_pcm_lib_readv_transfer(struct snd_pcm_substream *substream, | |||
1916 | } | 1936 | } |
1917 | } else { | 1937 | } else { |
1918 | snd_pcm_uframes_t dma_csize = runtime->dma_bytes / channels; | 1938 | snd_pcm_uframes_t dma_csize = runtime->dma_bytes / channels; |
1919 | snd_assert(runtime->dma_area, return -EFAULT); | ||
1920 | for (c = 0; c < channels; ++c, ++bufs) { | 1939 | for (c = 0; c < channels; ++c, ++bufs) { |
1921 | char *hwbuf; | 1940 | char *hwbuf; |
1922 | char __user *buf; | 1941 | char __user *buf; |
@@ -1938,11 +1957,12 @@ snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, | |||
1938 | { | 1957 | { |
1939 | struct snd_pcm_runtime *runtime; | 1958 | struct snd_pcm_runtime *runtime; |
1940 | int nonblock; | 1959 | int nonblock; |
1960 | int err; | ||
1941 | 1961 | ||
1942 | snd_assert(substream != NULL, return -ENXIO); | 1962 | err = pcm_sanity_check(substream); |
1963 | if (err < 0) | ||
1964 | return err; | ||
1943 | runtime = substream->runtime; | 1965 | runtime = substream->runtime; |
1944 | snd_assert(runtime != NULL, return -ENXIO); | ||
1945 | snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); | ||
1946 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | 1966 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
1947 | return -EBADFD; | 1967 | return -EBADFD; |
1948 | 1968 | ||
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index ff07b4a9992e..a6d42808828c 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -50,8 +50,6 @@ static int preallocate_pcm_pages(struct snd_pcm_substream *substream, size_t siz | |||
50 | struct snd_dma_buffer *dmab = &substream->dma_buffer; | 50 | struct snd_dma_buffer *dmab = &substream->dma_buffer; |
51 | int err; | 51 | int err; |
52 | 52 | ||
53 | snd_assert(size > 0, return -EINVAL); | ||
54 | |||
55 | /* already reserved? */ | 53 | /* already reserved? */ |
56 | if (snd_dma_get_reserved_buf(dmab, substream->dma_buf_id) > 0) { | 54 | if (snd_dma_get_reserved_buf(dmab, substream->dma_buf_id) > 0) { |
57 | if (dmab->bytes >= size) | 55 | if (dmab->bytes >= size) |
@@ -326,6 +324,32 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne | |||
326 | 324 | ||
327 | EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); | 325 | EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); |
328 | 326 | ||
327 | /* | ||
328 | * compute the max chunk size with continuous pages on sg-buffer | ||
329 | */ | ||
330 | unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | ||
331 | unsigned int ofs, unsigned int size) | ||
332 | { | ||
333 | struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); | ||
334 | unsigned int start, end, pg; | ||
335 | |||
336 | start = ofs >> PAGE_SHIFT; | ||
337 | end = (ofs + size - 1) >> PAGE_SHIFT; | ||
338 | /* check page continuity */ | ||
339 | pg = sg->table[start].addr >> PAGE_SHIFT; | ||
340 | for (;;) { | ||
341 | start++; | ||
342 | if (start > end) | ||
343 | break; | ||
344 | pg++; | ||
345 | if ((sg->table[start].addr >> PAGE_SHIFT) != pg) | ||
346 | return (start << PAGE_SHIFT) - ofs; | ||
347 | } | ||
348 | /* ok, all on continuous pages */ | ||
349 | return size; | ||
350 | } | ||
351 | EXPORT_SYMBOL(snd_pcm_sgbuf_get_chunk_size); | ||
352 | |||
329 | /** | 353 | /** |
330 | * snd_pcm_lib_malloc_pages - allocate the DMA buffer | 354 | * snd_pcm_lib_malloc_pages - allocate the DMA buffer |
331 | * @substream: the substream to allocate the DMA buffer to | 355 | * @substream: the substream to allocate the DMA buffer to |
@@ -342,10 +366,12 @@ int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) | |||
342 | struct snd_pcm_runtime *runtime; | 366 | struct snd_pcm_runtime *runtime; |
343 | struct snd_dma_buffer *dmab = NULL; | 367 | struct snd_dma_buffer *dmab = NULL; |
344 | 368 | ||
345 | snd_assert(substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_UNKNOWN, return -EINVAL); | 369 | if (PCM_RUNTIME_CHECK(substream)) |
346 | snd_assert(substream != NULL, return -EINVAL); | 370 | return -EINVAL; |
371 | if (snd_BUG_ON(substream->dma_buffer.dev.type == | ||
372 | SNDRV_DMA_TYPE_UNKNOWN)) | ||
373 | return -EINVAL; | ||
347 | runtime = substream->runtime; | 374 | runtime = substream->runtime; |
348 | snd_assert(runtime != NULL, return -EINVAL); | ||
349 | 375 | ||
350 | if (runtime->dma_buffer_p) { | 376 | if (runtime->dma_buffer_p) { |
351 | /* perphaps, we might free the large DMA memory region | 377 | /* perphaps, we might free the large DMA memory region |
@@ -391,9 +417,9 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) | |||
391 | { | 417 | { |
392 | struct snd_pcm_runtime *runtime; | 418 | struct snd_pcm_runtime *runtime; |
393 | 419 | ||
394 | snd_assert(substream != NULL, return -EINVAL); | 420 | if (PCM_RUNTIME_CHECK(substream)) |
421 | return -EINVAL; | ||
395 | runtime = substream->runtime; | 422 | runtime = substream->runtime; |
396 | snd_assert(runtime != NULL, return -EINVAL); | ||
397 | if (runtime->dma_area == NULL) | 423 | if (runtime->dma_area == NULL) |
398 | return 0; | 424 | return 0; |
399 | if (runtime->dma_buffer_p != &substream->dma_buffer) { | 425 | if (runtime->dma_buffer_p != &substream->dma_buffer) { |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index c49b9d9e303c..e61e12506ded 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -95,7 +95,6 @@ int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) | |||
95 | struct snd_pcm *pcm = substream->pcm; | 95 | struct snd_pcm *pcm = substream->pcm; |
96 | struct snd_pcm_str *pstr = substream->pstr; | 96 | struct snd_pcm_str *pstr = substream->pstr; |
97 | 97 | ||
98 | snd_assert(substream != NULL, return -ENXIO); | ||
99 | memset(info, 0, sizeof(*info)); | 98 | memset(info, 0, sizeof(*info)); |
100 | info->card = pcm->card->number; | 99 | info->card = pcm->card->number; |
101 | info->device = pcm->device; | 100 | info->device = pcm->device; |
@@ -370,9 +369,9 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream, | |||
370 | unsigned int bits; | 369 | unsigned int bits; |
371 | snd_pcm_uframes_t frames; | 370 | snd_pcm_uframes_t frames; |
372 | 371 | ||
373 | snd_assert(substream != NULL, return -ENXIO); | 372 | if (PCM_RUNTIME_CHECK(substream)) |
373 | return -ENXIO; | ||
374 | runtime = substream->runtime; | 374 | runtime = substream->runtime; |
375 | snd_assert(runtime != NULL, return -ENXIO); | ||
376 | snd_pcm_stream_lock_irq(substream); | 375 | snd_pcm_stream_lock_irq(substream); |
377 | switch (runtime->status->state) { | 376 | switch (runtime->status->state) { |
378 | case SNDRV_PCM_STATE_OPEN: | 377 | case SNDRV_PCM_STATE_OPEN: |
@@ -490,9 +489,9 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream) | |||
490 | struct snd_pcm_runtime *runtime; | 489 | struct snd_pcm_runtime *runtime; |
491 | int result = 0; | 490 | int result = 0; |
492 | 491 | ||
493 | snd_assert(substream != NULL, return -ENXIO); | 492 | if (PCM_RUNTIME_CHECK(substream)) |
493 | return -ENXIO; | ||
494 | runtime = substream->runtime; | 494 | runtime = substream->runtime; |
495 | snd_assert(runtime != NULL, return -ENXIO); | ||
496 | snd_pcm_stream_lock_irq(substream); | 495 | snd_pcm_stream_lock_irq(substream); |
497 | switch (runtime->status->state) { | 496 | switch (runtime->status->state) { |
498 | case SNDRV_PCM_STATE_SETUP: | 497 | case SNDRV_PCM_STATE_SETUP: |
@@ -518,9 +517,9 @@ static int snd_pcm_sw_params(struct snd_pcm_substream *substream, | |||
518 | { | 517 | { |
519 | struct snd_pcm_runtime *runtime; | 518 | struct snd_pcm_runtime *runtime; |
520 | 519 | ||
521 | snd_assert(substream != NULL, return -ENXIO); | 520 | if (PCM_RUNTIME_CHECK(substream)) |
521 | return -ENXIO; | ||
522 | runtime = substream->runtime; | 522 | runtime = substream->runtime; |
523 | snd_assert(runtime != NULL, return -ENXIO); | ||
524 | snd_pcm_stream_lock_irq(substream); | 523 | snd_pcm_stream_lock_irq(substream); |
525 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { | 524 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { |
526 | snd_pcm_stream_unlock_irq(substream); | 525 | snd_pcm_stream_unlock_irq(substream); |
@@ -622,11 +621,8 @@ static int snd_pcm_status_user(struct snd_pcm_substream *substream, | |||
622 | struct snd_pcm_status __user * _status) | 621 | struct snd_pcm_status __user * _status) |
623 | { | 622 | { |
624 | struct snd_pcm_status status; | 623 | struct snd_pcm_status status; |
625 | struct snd_pcm_runtime *runtime; | ||
626 | int res; | 624 | int res; |
627 | 625 | ||
628 | snd_assert(substream != NULL, return -ENXIO); | ||
629 | runtime = substream->runtime; | ||
630 | memset(&status, 0, sizeof(status)); | 626 | memset(&status, 0, sizeof(status)); |
631 | res = snd_pcm_status(substream, &status); | 627 | res = snd_pcm_status(substream, &status); |
632 | if (res < 0) | 628 | if (res < 0) |
@@ -642,7 +638,6 @@ static int snd_pcm_channel_info(struct snd_pcm_substream *substream, | |||
642 | struct snd_pcm_runtime *runtime; | 638 | struct snd_pcm_runtime *runtime; |
643 | unsigned int channel; | 639 | unsigned int channel; |
644 | 640 | ||
645 | snd_assert(substream != NULL, return -ENXIO); | ||
646 | channel = info->channel; | 641 | channel = info->channel; |
647 | runtime = substream->runtime; | 642 | runtime = substream->runtime; |
648 | snd_pcm_stream_lock_irq(substream); | 643 | snd_pcm_stream_lock_irq(substream); |
@@ -1250,7 +1245,6 @@ static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) | |||
1250 | int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); | 1245 | int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); |
1251 | if (err < 0) | 1246 | if (err < 0) |
1252 | return err; | 1247 | return err; |
1253 | // snd_assert(runtime->status->hw_ptr < runtime->buffer_size, ); | ||
1254 | runtime->hw_ptr_base = 0; | 1248 | runtime->hw_ptr_base = 0; |
1255 | runtime->hw_ptr_interrupt = runtime->status->hw_ptr - | 1249 | runtime->hw_ptr_interrupt = runtime->status->hw_ptr - |
1256 | runtime->status->hw_ptr % runtime->period_size; | 1250 | runtime->status->hw_ptr % runtime->period_size; |
@@ -1421,7 +1415,6 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream) | |||
1421 | int i, num_drecs; | 1415 | int i, num_drecs; |
1422 | struct drain_rec *drec, drec_tmp, *d; | 1416 | struct drain_rec *drec, drec_tmp, *d; |
1423 | 1417 | ||
1424 | snd_assert(substream != NULL, return -ENXIO); | ||
1425 | card = substream->pcm->card; | 1418 | card = substream->pcm->card; |
1426 | runtime = substream->runtime; | 1419 | runtime = substream->runtime; |
1427 | 1420 | ||
@@ -1541,21 +1534,16 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) | |||
1541 | struct snd_card *card; | 1534 | struct snd_card *card; |
1542 | int result = 0; | 1535 | int result = 0; |
1543 | 1536 | ||
1544 | snd_assert(substream != NULL, return -ENXIO); | 1537 | if (PCM_RUNTIME_CHECK(substream)) |
1538 | return -ENXIO; | ||
1545 | runtime = substream->runtime; | 1539 | runtime = substream->runtime; |
1546 | card = substream->pcm->card; | 1540 | card = substream->pcm->card; |
1547 | 1541 | ||
1548 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN || | 1542 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN || |
1549 | runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED) | 1543 | runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED || |
1544 | runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) | ||
1550 | return -EBADFD; | 1545 | return -EBADFD; |
1551 | 1546 | ||
1552 | snd_power_lock(card); | ||
1553 | if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { | ||
1554 | result = snd_power_wait(card, SNDRV_CTL_POWER_D0); | ||
1555 | if (result < 0) | ||
1556 | goto _unlock; | ||
1557 | } | ||
1558 | |||
1559 | snd_pcm_stream_lock_irq(substream); | 1547 | snd_pcm_stream_lock_irq(substream); |
1560 | /* resume pause */ | 1548 | /* resume pause */ |
1561 | if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) | 1549 | if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) |
@@ -1564,8 +1552,7 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream) | |||
1564 | snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); | 1552 | snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); |
1565 | /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ | 1553 | /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ |
1566 | snd_pcm_stream_unlock_irq(substream); | 1554 | snd_pcm_stream_unlock_irq(substream); |
1567 | _unlock: | 1555 | |
1568 | snd_power_unlock(card); | ||
1569 | return result; | 1556 | return result; |
1570 | } | 1557 | } |
1571 | 1558 | ||
@@ -1941,33 +1928,41 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) | |||
1941 | mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX; | 1928 | mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX; |
1942 | } | 1929 | } |
1943 | err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); | 1930 | err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); |
1944 | snd_assert(err >= 0, return -EINVAL); | 1931 | if (err < 0) |
1932 | return err; | ||
1945 | 1933 | ||
1946 | err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); | 1934 | err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); |
1947 | snd_assert(err >= 0, return -EINVAL); | 1935 | if (err < 0) |
1936 | return err; | ||
1948 | 1937 | ||
1949 | err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD); | 1938 | err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD); |
1950 | snd_assert(err >= 0, return -EINVAL); | 1939 | if (err < 0) |
1940 | return err; | ||
1951 | 1941 | ||
1952 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, | 1942 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, |
1953 | hw->channels_min, hw->channels_max); | 1943 | hw->channels_min, hw->channels_max); |
1954 | snd_assert(err >= 0, return -EINVAL); | 1944 | if (err < 0) |
1945 | return err; | ||
1955 | 1946 | ||
1956 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, | 1947 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, |
1957 | hw->rate_min, hw->rate_max); | 1948 | hw->rate_min, hw->rate_max); |
1958 | snd_assert(err >= 0, return -EINVAL); | 1949 | if (err < 0) |
1950 | return err; | ||
1959 | 1951 | ||
1960 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, | 1952 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, |
1961 | hw->period_bytes_min, hw->period_bytes_max); | 1953 | hw->period_bytes_min, hw->period_bytes_max); |
1962 | snd_assert(err >= 0, return -EINVAL); | 1954 | if (err < 0) |
1955 | return err; | ||
1963 | 1956 | ||
1964 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, | 1957 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, |
1965 | hw->periods_min, hw->periods_max); | 1958 | hw->periods_min, hw->periods_max); |
1966 | snd_assert(err >= 0, return -EINVAL); | 1959 | if (err < 0) |
1960 | return err; | ||
1967 | 1961 | ||
1968 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, | 1962 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, |
1969 | hw->period_bytes_min, hw->buffer_bytes_max); | 1963 | hw->period_bytes_min, hw->buffer_bytes_max); |
1970 | snd_assert(err >= 0, return -EINVAL); | 1964 | if (err < 0) |
1965 | return err; | ||
1971 | 1966 | ||
1972 | err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, | 1967 | err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, |
1973 | snd_pcm_hw_rule_buffer_bytes_max, substream, | 1968 | snd_pcm_hw_rule_buffer_bytes_max, substream, |
@@ -1978,7 +1973,8 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) | |||
1978 | /* FIXME: remove */ | 1973 | /* FIXME: remove */ |
1979 | if (runtime->dma_bytes) { | 1974 | if (runtime->dma_bytes) { |
1980 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes); | 1975 | err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes); |
1981 | snd_assert(err >= 0, return -EINVAL); | 1976 | if (err < 0) |
1977 | return -EINVAL; | ||
1982 | } | 1978 | } |
1983 | 1979 | ||
1984 | if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) { | 1980 | if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) { |
@@ -2074,8 +2070,8 @@ static int snd_pcm_open_file(struct file *file, | |||
2074 | struct snd_pcm_str *str; | 2070 | struct snd_pcm_str *str; |
2075 | int err; | 2071 | int err; |
2076 | 2072 | ||
2077 | snd_assert(rpcm_file != NULL, return -EINVAL); | 2073 | if (rpcm_file) |
2078 | *rpcm_file = NULL; | 2074 | *rpcm_file = NULL; |
2079 | 2075 | ||
2080 | err = snd_pcm_open_substream(pcm, stream, file, &substream); | 2076 | err = snd_pcm_open_substream(pcm, stream, file, &substream); |
2081 | if (err < 0) | 2077 | if (err < 0) |
@@ -2093,7 +2089,8 @@ static int snd_pcm_open_file(struct file *file, | |||
2093 | substream->pcm_release = pcm_release_private; | 2089 | substream->pcm_release = pcm_release_private; |
2094 | } | 2090 | } |
2095 | file->private_data = pcm_file; | 2091 | file->private_data = pcm_file; |
2096 | *rpcm_file = pcm_file; | 2092 | if (rpcm_file) |
2093 | *rpcm_file = pcm_file; | ||
2097 | return 0; | 2094 | return 0; |
2098 | } | 2095 | } |
2099 | 2096 | ||
@@ -2177,7 +2174,8 @@ static int snd_pcm_release(struct inode *inode, struct file *file) | |||
2177 | 2174 | ||
2178 | pcm_file = file->private_data; | 2175 | pcm_file = file->private_data; |
2179 | substream = pcm_file->substream; | 2176 | substream = pcm_file->substream; |
2180 | snd_assert(substream != NULL, return -ENXIO); | 2177 | if (snd_BUG_ON(!substream)) |
2178 | return -ENXIO; | ||
2181 | pcm = substream->pcm; | 2179 | pcm = substream->pcm; |
2182 | fasync_helper(-1, file, 0, &substream->runtime->fasync); | 2180 | fasync_helper(-1, file, 0, &substream->runtime->fasync); |
2183 | mutex_lock(&pcm->open_mutex); | 2181 | mutex_lock(&pcm->open_mutex); |
@@ -2500,8 +2498,6 @@ static int snd_pcm_common_ioctl1(struct file *file, | |||
2500 | struct snd_pcm_substream *substream, | 2498 | struct snd_pcm_substream *substream, |
2501 | unsigned int cmd, void __user *arg) | 2499 | unsigned int cmd, void __user *arg) |
2502 | { | 2500 | { |
2503 | snd_assert(substream != NULL, return -ENXIO); | ||
2504 | |||
2505 | switch (cmd) { | 2501 | switch (cmd) { |
2506 | case SNDRV_PCM_IOCTL_PVERSION: | 2502 | case SNDRV_PCM_IOCTL_PVERSION: |
2507 | return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; | 2503 | return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; |
@@ -2570,8 +2566,10 @@ static int snd_pcm_playback_ioctl1(struct file *file, | |||
2570 | struct snd_pcm_substream *substream, | 2566 | struct snd_pcm_substream *substream, |
2571 | unsigned int cmd, void __user *arg) | 2567 | unsigned int cmd, void __user *arg) |
2572 | { | 2568 | { |
2573 | snd_assert(substream != NULL, return -ENXIO); | 2569 | if (snd_BUG_ON(!substream)) |
2574 | snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL); | 2570 | return -ENXIO; |
2571 | if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) | ||
2572 | return -EINVAL; | ||
2575 | switch (cmd) { | 2573 | switch (cmd) { |
2576 | case SNDRV_PCM_IOCTL_WRITEI_FRAMES: | 2574 | case SNDRV_PCM_IOCTL_WRITEI_FRAMES: |
2577 | { | 2575 | { |
@@ -2650,8 +2648,10 @@ static int snd_pcm_capture_ioctl1(struct file *file, | |||
2650 | struct snd_pcm_substream *substream, | 2648 | struct snd_pcm_substream *substream, |
2651 | unsigned int cmd, void __user *arg) | 2649 | unsigned int cmd, void __user *arg) |
2652 | { | 2650 | { |
2653 | snd_assert(substream != NULL, return -ENXIO); | 2651 | if (snd_BUG_ON(!substream)) |
2654 | snd_assert(substream->stream == SNDRV_PCM_STREAM_CAPTURE, return -EINVAL); | 2652 | return -ENXIO; |
2653 | if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) | ||
2654 | return -EINVAL; | ||
2655 | switch (cmd) { | 2655 | switch (cmd) { |
2656 | case SNDRV_PCM_IOCTL_READI_FRAMES: | 2656 | case SNDRV_PCM_IOCTL_READI_FRAMES: |
2657 | { | 2657 | { |
@@ -2790,7 +2790,8 @@ static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, | |||
2790 | 2790 | ||
2791 | pcm_file = file->private_data; | 2791 | pcm_file = file->private_data; |
2792 | substream = pcm_file->substream; | 2792 | substream = pcm_file->substream; |
2793 | snd_assert(substream != NULL, return -ENXIO); | 2793 | if (PCM_RUNTIME_CHECK(substream)) |
2794 | return -ENXIO; | ||
2794 | runtime = substream->runtime; | 2795 | runtime = substream->runtime; |
2795 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | 2796 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
2796 | return -EBADFD; | 2797 | return -EBADFD; |
@@ -2813,21 +2814,17 @@ static ssize_t snd_pcm_write(struct file *file, const char __user *buf, | |||
2813 | 2814 | ||
2814 | pcm_file = file->private_data; | 2815 | pcm_file = file->private_data; |
2815 | substream = pcm_file->substream; | 2816 | substream = pcm_file->substream; |
2816 | snd_assert(substream != NULL, result = -ENXIO; goto end); | 2817 | if (PCM_RUNTIME_CHECK(substream)) |
2818 | return -ENXIO; | ||
2817 | runtime = substream->runtime; | 2819 | runtime = substream->runtime; |
2818 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { | 2820 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
2819 | result = -EBADFD; | 2821 | return -EBADFD; |
2820 | goto end; | 2822 | if (!frame_aligned(runtime, count)) |
2821 | } | 2823 | return -EINVAL; |
2822 | if (!frame_aligned(runtime, count)) { | ||
2823 | result = -EINVAL; | ||
2824 | goto end; | ||
2825 | } | ||
2826 | count = bytes_to_frames(runtime, count); | 2824 | count = bytes_to_frames(runtime, count); |
2827 | result = snd_pcm_lib_write(substream, buf, count); | 2825 | result = snd_pcm_lib_write(substream, buf, count); |
2828 | if (result > 0) | 2826 | if (result > 0) |
2829 | result = frames_to_bytes(runtime, result); | 2827 | result = frames_to_bytes(runtime, result); |
2830 | end: | ||
2831 | return result; | 2828 | return result; |
2832 | } | 2829 | } |
2833 | 2830 | ||
@@ -2845,7 +2842,8 @@ static ssize_t snd_pcm_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
2845 | 2842 | ||
2846 | pcm_file = iocb->ki_filp->private_data; | 2843 | pcm_file = iocb->ki_filp->private_data; |
2847 | substream = pcm_file->substream; | 2844 | substream = pcm_file->substream; |
2848 | snd_assert(substream != NULL, return -ENXIO); | 2845 | if (PCM_RUNTIME_CHECK(substream)) |
2846 | return -ENXIO; | ||
2849 | runtime = substream->runtime; | 2847 | runtime = substream->runtime; |
2850 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | 2848 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
2851 | return -EBADFD; | 2849 | return -EBADFD; |
@@ -2879,17 +2877,14 @@ static ssize_t snd_pcm_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2879 | 2877 | ||
2880 | pcm_file = iocb->ki_filp->private_data; | 2878 | pcm_file = iocb->ki_filp->private_data; |
2881 | substream = pcm_file->substream; | 2879 | substream = pcm_file->substream; |
2882 | snd_assert(substream != NULL, result = -ENXIO; goto end); | 2880 | if (PCM_RUNTIME_CHECK(substream)) |
2881 | return -ENXIO; | ||
2883 | runtime = substream->runtime; | 2882 | runtime = substream->runtime; |
2884 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { | 2883 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
2885 | result = -EBADFD; | 2884 | return -EBADFD; |
2886 | goto end; | ||
2887 | } | ||
2888 | if (nr_segs > 128 || nr_segs != runtime->channels || | 2885 | if (nr_segs > 128 || nr_segs != runtime->channels || |
2889 | !frame_aligned(runtime, iov->iov_len)) { | 2886 | !frame_aligned(runtime, iov->iov_len)) |
2890 | result = -EINVAL; | 2887 | return -EINVAL; |
2891 | goto end; | ||
2892 | } | ||
2893 | frames = bytes_to_samples(runtime, iov->iov_len); | 2888 | frames = bytes_to_samples(runtime, iov->iov_len); |
2894 | bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); | 2889 | bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); |
2895 | if (bufs == NULL) | 2890 | if (bufs == NULL) |
@@ -2900,7 +2895,6 @@ static ssize_t snd_pcm_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2900 | if (result > 0) | 2895 | if (result > 0) |
2901 | result = frames_to_bytes(runtime, result); | 2896 | result = frames_to_bytes(runtime, result); |
2902 | kfree(bufs); | 2897 | kfree(bufs); |
2903 | end: | ||
2904 | return result; | 2898 | return result; |
2905 | } | 2899 | } |
2906 | 2900 | ||
@@ -2915,7 +2909,8 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) | |||
2915 | pcm_file = file->private_data; | 2909 | pcm_file = file->private_data; |
2916 | 2910 | ||
2917 | substream = pcm_file->substream; | 2911 | substream = pcm_file->substream; |
2918 | snd_assert(substream != NULL, return -ENXIO); | 2912 | if (PCM_RUNTIME_CHECK(substream)) |
2913 | return -ENXIO; | ||
2919 | runtime = substream->runtime; | 2914 | runtime = substream->runtime; |
2920 | 2915 | ||
2921 | poll_wait(file, &runtime->sleep, wait); | 2916 | poll_wait(file, &runtime->sleep, wait); |
@@ -2953,7 +2948,8 @@ static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait) | |||
2953 | pcm_file = file->private_data; | 2948 | pcm_file = file->private_data; |
2954 | 2949 | ||
2955 | substream = pcm_file->substream; | 2950 | substream = pcm_file->substream; |
2956 | snd_assert(substream != NULL, return -ENXIO); | 2951 | if (PCM_RUNTIME_CHECK(substream)) |
2952 | return -ENXIO; | ||
2957 | runtime = substream->runtime; | 2953 | runtime = substream->runtime; |
2958 | 2954 | ||
2959 | poll_wait(file, &runtime->sleep, wait); | 2955 | poll_wait(file, &runtime->sleep, wait); |
@@ -3023,7 +3019,6 @@ static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file | |||
3023 | if (!(area->vm_flags & VM_READ)) | 3019 | if (!(area->vm_flags & VM_READ)) |
3024 | return -EINVAL; | 3020 | return -EINVAL; |
3025 | runtime = substream->runtime; | 3021 | runtime = substream->runtime; |
3026 | snd_assert(runtime != NULL, return -EAGAIN); | ||
3027 | size = area->vm_end - area->vm_start; | 3022 | size = area->vm_end - area->vm_start; |
3028 | if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) | 3023 | if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) |
3029 | return -EINVAL; | 3024 | return -EINVAL; |
@@ -3063,7 +3058,6 @@ static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file | |||
3063 | if (!(area->vm_flags & VM_READ)) | 3058 | if (!(area->vm_flags & VM_READ)) |
3064 | return -EINVAL; | 3059 | return -EINVAL; |
3065 | runtime = substream->runtime; | 3060 | runtime = substream->runtime; |
3066 | snd_assert(runtime != NULL, return -EAGAIN); | ||
3067 | size = area->vm_end - area->vm_start; | 3061 | size = area->vm_end - area->vm_start; |
3068 | if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) | 3062 | if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) |
3069 | return -EINVAL; | 3063 | return -EINVAL; |
@@ -3195,7 +3189,6 @@ int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, | |||
3195 | return -EINVAL; | 3189 | return -EINVAL; |
3196 | } | 3190 | } |
3197 | runtime = substream->runtime; | 3191 | runtime = substream->runtime; |
3198 | snd_assert(runtime != NULL, return -EAGAIN); | ||
3199 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) | 3192 | if (runtime->status->state == SNDRV_PCM_STATE_OPEN) |
3200 | return -EBADFD; | 3193 | return -EBADFD; |
3201 | if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) | 3194 | if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) |
@@ -3227,7 +3220,8 @@ static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area) | |||
3227 | 3220 | ||
3228 | pcm_file = file->private_data; | 3221 | pcm_file = file->private_data; |
3229 | substream = pcm_file->substream; | 3222 | substream = pcm_file->substream; |
3230 | snd_assert(substream != NULL, return -ENXIO); | 3223 | if (PCM_RUNTIME_CHECK(substream)) |
3224 | return -ENXIO; | ||
3231 | 3225 | ||
3232 | offset = area->vm_pgoff << PAGE_SHIFT; | 3226 | offset = area->vm_pgoff << PAGE_SHIFT; |
3233 | switch (offset) { | 3227 | switch (offset) { |
@@ -3255,9 +3249,9 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) | |||
3255 | lock_kernel(); | 3249 | lock_kernel(); |
3256 | pcm_file = file->private_data; | 3250 | pcm_file = file->private_data; |
3257 | substream = pcm_file->substream; | 3251 | substream = pcm_file->substream; |
3258 | snd_assert(substream != NULL, goto out); | 3252 | if (PCM_RUNTIME_CHECK(substream)) |
3253 | goto out; | ||
3259 | runtime = substream->runtime; | 3254 | runtime = substream->runtime; |
3260 | |||
3261 | err = fasync_helper(fd, file, on, &runtime->fasync); | 3255 | err = fasync_helper(fd, file, on, &runtime->fasync); |
3262 | out: | 3256 | out: |
3263 | unlock_kernel(); | 3257 | unlock_kernel(); |
@@ -3391,6 +3385,17 @@ out: | |||
3391 | } | 3385 | } |
3392 | #endif /* CONFIG_SND_SUPPORT_OLD_API */ | 3386 | #endif /* CONFIG_SND_SUPPORT_OLD_API */ |
3393 | 3387 | ||
3388 | #ifndef CONFIG_MMU | ||
3389 | unsigned long dummy_get_unmapped_area(struct file *file, unsigned long addr, | ||
3390 | unsigned long len, unsigned long pgoff, | ||
3391 | unsigned long flags) | ||
3392 | { | ||
3393 | return 0; | ||
3394 | } | ||
3395 | #else | ||
3396 | # define dummy_get_unmapped_area NULL | ||
3397 | #endif | ||
3398 | |||
3394 | /* | 3399 | /* |
3395 | * Register section | 3400 | * Register section |
3396 | */ | 3401 | */ |
@@ -3407,6 +3412,7 @@ const struct file_operations snd_pcm_f_ops[2] = { | |||
3407 | .compat_ioctl = snd_pcm_ioctl_compat, | 3412 | .compat_ioctl = snd_pcm_ioctl_compat, |
3408 | .mmap = snd_pcm_mmap, | 3413 | .mmap = snd_pcm_mmap, |
3409 | .fasync = snd_pcm_fasync, | 3414 | .fasync = snd_pcm_fasync, |
3415 | .get_unmapped_area = dummy_get_unmapped_area, | ||
3410 | }, | 3416 | }, |
3411 | { | 3417 | { |
3412 | .owner = THIS_MODULE, | 3418 | .owner = THIS_MODULE, |
@@ -3419,5 +3425,6 @@ const struct file_operations snd_pcm_f_ops[2] = { | |||
3419 | .compat_ioctl = snd_pcm_ioctl_compat, | 3425 | .compat_ioctl = snd_pcm_ioctl_compat, |
3420 | .mmap = snd_pcm_mmap, | 3426 | .mmap = snd_pcm_mmap, |
3421 | .fasync = snd_pcm_fasync, | 3427 | .fasync = snd_pcm_fasync, |
3428 | .get_unmapped_area = dummy_get_unmapped_area, | ||
3422 | } | 3429 | } |
3423 | }; | 3430 | }; |
diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c index 033a024d153a..2c89c04f2916 100644 --- a/sound/core/pcm_timer.c +++ b/sound/core/pcm_timer.c | |||
@@ -51,12 +51,14 @@ void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) | |||
51 | 51 | ||
52 | mult = 1000000000; | 52 | mult = 1000000000; |
53 | rate = runtime->rate; | 53 | rate = runtime->rate; |
54 | snd_assert(rate != 0, return); | 54 | if (snd_BUG_ON(!rate)) |
55 | return; | ||
55 | l = gcd(mult, rate); | 56 | l = gcd(mult, rate); |
56 | mult /= l; | 57 | mult /= l; |
57 | rate /= l; | 58 | rate /= l; |
58 | fsize = runtime->period_size; | 59 | fsize = runtime->period_size; |
59 | snd_assert(fsize != 0, return); | 60 | if (snd_BUG_ON(!fsize)) |
61 | return; | ||
60 | l = gcd(rate, fsize); | 62 | l = gcd(rate, fsize); |
61 | rate /= l; | 63 | rate /= l; |
62 | fsize /= l; | 64 | fsize /= l; |
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index f7ea7287c59c..c4995c9f5730 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c | |||
@@ -418,7 +418,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
418 | mutex_lock(&rmidi->open_mutex); | 418 | mutex_lock(&rmidi->open_mutex); |
419 | while (1) { | 419 | while (1) { |
420 | subdevice = -1; | 420 | subdevice = -1; |
421 | down_read(&card->controls_rwsem); | 421 | read_lock(&card->ctl_files_rwlock); |
422 | list_for_each_entry(kctl, &card->ctl_files, list) { | 422 | list_for_each_entry(kctl, &card->ctl_files, list) { |
423 | if (kctl->pid == current->pid) { | 423 | if (kctl->pid == current->pid) { |
424 | subdevice = kctl->prefer_rawmidi_subdevice; | 424 | subdevice = kctl->prefer_rawmidi_subdevice; |
@@ -426,7 +426,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) | |||
426 | break; | 426 | break; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | up_read(&card->controls_rwsem); | 429 | read_unlock(&card->ctl_files_rwlock); |
430 | err = snd_rawmidi_kernel_open(rmidi->card, rmidi->device, | 430 | err = snd_rawmidi_kernel_open(rmidi->card, rmidi->device, |
431 | subdevice, fflags, rawmidi_file); | 431 | subdevice, fflags, rawmidi_file); |
432 | if (err >= 0) | 432 | if (err >= 0) |
@@ -470,8 +470,8 @@ int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) | |||
470 | struct snd_rawmidi_substream *substream; | 470 | struct snd_rawmidi_substream *substream; |
471 | struct snd_rawmidi_runtime *runtime; | 471 | struct snd_rawmidi_runtime *runtime; |
472 | 472 | ||
473 | snd_assert(rfile != NULL, return -ENXIO); | 473 | if (snd_BUG_ON(!rfile)) |
474 | snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); | 474 | return -ENXIO; |
475 | rmidi = rfile->rmidi; | 475 | rmidi = rfile->rmidi; |
476 | mutex_lock(&rmidi->open_mutex); | 476 | mutex_lock(&rmidi->open_mutex); |
477 | if (rfile->input != NULL) { | 477 | if (rfile->input != NULL) { |
@@ -1100,7 +1100,7 @@ int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) | |||
1100 | return -EINVAL; | 1100 | return -EINVAL; |
1101 | } | 1101 | } |
1102 | spin_lock_irqsave(&runtime->lock, flags); | 1102 | spin_lock_irqsave(&runtime->lock, flags); |
1103 | snd_assert(runtime->avail + count <= runtime->buffer_size, ); | 1103 | snd_BUG_ON(runtime->avail + count > runtime->buffer_size); |
1104 | runtime->hw_ptr += count; | 1104 | runtime->hw_ptr += count; |
1105 | runtime->hw_ptr %= runtime->buffer_size; | 1105 | runtime->hw_ptr %= runtime->buffer_size; |
1106 | runtime->avail += count; | 1106 | runtime->avail += count; |
@@ -1141,8 +1141,10 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream, | |||
1141 | long count1, result; | 1141 | long count1, result; |
1142 | struct snd_rawmidi_runtime *runtime = substream->runtime; | 1142 | struct snd_rawmidi_runtime *runtime = substream->runtime; |
1143 | 1143 | ||
1144 | snd_assert(kernelbuf != NULL || userbuf != NULL, return -EINVAL); | 1144 | if (snd_BUG_ON(!kernelbuf && !userbuf)) |
1145 | snd_assert(runtime->buffer != NULL, return -EINVAL); | 1145 | return -EINVAL; |
1146 | if (snd_BUG_ON(!runtime->buffer)) | ||
1147 | return -EINVAL; | ||
1146 | 1148 | ||
1147 | result = 0; | 1149 | result = 0; |
1148 | spin_lock_irqsave(&runtime->lock, flags); | 1150 | spin_lock_irqsave(&runtime->lock, flags); |
@@ -1420,9 +1422,10 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, | |||
1420 | .dev_disconnect = snd_rawmidi_dev_disconnect, | 1422 | .dev_disconnect = snd_rawmidi_dev_disconnect, |
1421 | }; | 1423 | }; |
1422 | 1424 | ||
1423 | snd_assert(rrawmidi != NULL, return -EINVAL); | 1425 | if (snd_BUG_ON(!card)) |
1424 | *rrawmidi = NULL; | 1426 | return -ENXIO; |
1425 | snd_assert(card != NULL, return -ENXIO); | 1427 | if (rrawmidi) |
1428 | *rrawmidi = NULL; | ||
1426 | rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); | 1429 | rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); |
1427 | if (rmidi == NULL) { | 1430 | if (rmidi == NULL) { |
1428 | snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); | 1431 | snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); |
@@ -1455,7 +1458,8 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, | |||
1455 | snd_rawmidi_free(rmidi); | 1458 | snd_rawmidi_free(rmidi); |
1456 | return err; | 1459 | return err; |
1457 | } | 1460 | } |
1458 | *rrawmidi = rmidi; | 1461 | if (rrawmidi) |
1462 | *rrawmidi = rmidi; | ||
1459 | return 0; | 1463 | return 0; |
1460 | } | 1464 | } |
1461 | 1465 | ||
@@ -1472,7 +1476,8 @@ static void snd_rawmidi_free_substreams(struct snd_rawmidi_str *stream) | |||
1472 | 1476 | ||
1473 | static int snd_rawmidi_free(struct snd_rawmidi *rmidi) | 1477 | static int snd_rawmidi_free(struct snd_rawmidi *rmidi) |
1474 | { | 1478 | { |
1475 | snd_assert(rmidi != NULL, return -ENXIO); | 1479 | if (!rmidi) |
1480 | return 0; | ||
1476 | 1481 | ||
1477 | snd_info_free_entry(rmidi->proc_entry); | 1482 | snd_info_free_entry(rmidi->proc_entry); |
1478 | rmidi->proc_entry = NULL; | 1483 | rmidi->proc_entry = NULL; |
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c index 97b30fb4c361..51e64e30dd3b 100644 --- a/sound/core/rtctimer.c +++ b/sound/core/rtctimer.c | |||
@@ -91,7 +91,8 @@ static int | |||
91 | rtctimer_start(struct snd_timer *timer) | 91 | rtctimer_start(struct snd_timer *timer) |
92 | { | 92 | { |
93 | rtc_task_t *rtc = timer->private_data; | 93 | rtc_task_t *rtc = timer->private_data; |
94 | snd_assert(rtc != NULL, return -EINVAL); | 94 | if (snd_BUG_ON(!rtc)) |
95 | return -EINVAL; | ||
95 | rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq); | 96 | rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq); |
96 | rtc_control(rtc, RTC_PIE_ON, 0); | 97 | rtc_control(rtc, RTC_PIE_ON, 0); |
97 | return 0; | 98 | return 0; |
@@ -101,7 +102,8 @@ static int | |||
101 | rtctimer_stop(struct snd_timer *timer) | 102 | rtctimer_stop(struct snd_timer *timer) |
102 | { | 103 | { |
103 | rtc_task_t *rtc = timer->private_data; | 104 | rtc_task_t *rtc = timer->private_data; |
104 | snd_assert(rtc != NULL, return -EINVAL); | 105 | if (snd_BUG_ON(!rtc)) |
106 | return -EINVAL; | ||
105 | rtc_control(rtc, RTC_PIE_OFF, 0); | 107 | rtc_control(rtc, RTC_PIE_OFF, 0); |
106 | return 0; | 108 | return 0; |
107 | } | 109 | } |
diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 777796e94490..f25e3cc7ddfa 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c | |||
@@ -164,7 +164,8 @@ odev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) | |||
164 | { | 164 | { |
165 | struct seq_oss_devinfo *dp; | 165 | struct seq_oss_devinfo *dp; |
166 | dp = file->private_data; | 166 | dp = file->private_data; |
167 | snd_assert(dp != NULL, return -EIO); | 167 | if (snd_BUG_ON(!dp)) |
168 | return -ENXIO; | ||
168 | return snd_seq_oss_read(dp, buf, count); | 169 | return snd_seq_oss_read(dp, buf, count); |
169 | } | 170 | } |
170 | 171 | ||
@@ -174,7 +175,8 @@ odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offs | |||
174 | { | 175 | { |
175 | struct seq_oss_devinfo *dp; | 176 | struct seq_oss_devinfo *dp; |
176 | dp = file->private_data; | 177 | dp = file->private_data; |
177 | snd_assert(dp != NULL, return -EIO); | 178 | if (snd_BUG_ON(!dp)) |
179 | return -ENXIO; | ||
178 | return snd_seq_oss_write(dp, buf, count, file); | 180 | return snd_seq_oss_write(dp, buf, count, file); |
179 | } | 181 | } |
180 | 182 | ||
@@ -183,7 +185,8 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
183 | { | 185 | { |
184 | struct seq_oss_devinfo *dp; | 186 | struct seq_oss_devinfo *dp; |
185 | dp = file->private_data; | 187 | dp = file->private_data; |
186 | snd_assert(dp != NULL, return -EIO); | 188 | if (snd_BUG_ON(!dp)) |
189 | return -ENXIO; | ||
187 | return snd_seq_oss_ioctl(dp, cmd, arg); | 190 | return snd_seq_oss_ioctl(dp, cmd, arg); |
188 | } | 191 | } |
189 | 192 | ||
@@ -198,7 +201,8 @@ odev_poll(struct file *file, poll_table * wait) | |||
198 | { | 201 | { |
199 | struct seq_oss_devinfo *dp; | 202 | struct seq_oss_devinfo *dp; |
200 | dp = file->private_data; | 203 | dp = file->private_data; |
201 | snd_assert(dp != NULL, return 0); | 204 | if (snd_BUG_ON(!dp)) |
205 | return -ENXIO; | ||
202 | return snd_seq_oss_poll(dp, file, wait); | 206 | return snd_seq_oss_poll(dp, file, wait); |
203 | } | 207 | } |
204 | 208 | ||
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index e024e4588b82..945a27c34a9d 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c | |||
@@ -308,7 +308,8 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp) | |||
308 | struct seq_oss_synth *rec; | 308 | struct seq_oss_synth *rec; |
309 | struct seq_oss_synthinfo *info; | 309 | struct seq_oss_synthinfo *info; |
310 | 310 | ||
311 | snd_assert(dp->max_synthdev <= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS, return); | 311 | if (snd_BUG_ON(dp->max_synthdev >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS)) |
312 | return; | ||
312 | for (i = 0; i < dp->max_synthdev; i++) { | 313 | for (i = 0; i < dp->max_synthdev; i++) { |
313 | info = &dp->synths[i]; | 314 | info = &dp->synths[i]; |
314 | if (! info->opened) | 315 | if (! info->opened) |
@@ -402,7 +403,8 @@ snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev) | |||
402 | struct seq_oss_synth *rec; | 403 | struct seq_oss_synth *rec; |
403 | struct seq_oss_synthinfo *info; | 404 | struct seq_oss_synthinfo *info; |
404 | 405 | ||
405 | snd_assert(dev >= 0 && dev < dp->max_synthdev, return); | 406 | if (snd_BUG_ON(dev < 0 || dev >= dp->max_synthdev)) |
407 | return; | ||
406 | info = &dp->synths[dev]; | 408 | info = &dp->synths[dev]; |
407 | if (! info->opened) | 409 | if (! info->opened) |
408 | return; | 410 | return; |
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 7a1545d2d953..8ca2be339f3b 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c | |||
@@ -266,7 +266,8 @@ static int seq_free_client1(struct snd_seq_client *client) | |||
266 | { | 266 | { |
267 | unsigned long flags; | 267 | unsigned long flags; |
268 | 268 | ||
269 | snd_assert(client != NULL, return -EINVAL); | 269 | if (!client) |
270 | return 0; | ||
270 | snd_seq_delete_all_ports(client); | 271 | snd_seq_delete_all_ports(client); |
271 | snd_seq_queue_client_leave(client->number); | 272 | snd_seq_queue_client_leave(client->number); |
272 | spin_lock_irqsave(&clients_lock, flags); | 273 | spin_lock_irqsave(&clients_lock, flags); |
@@ -403,7 +404,8 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, | |||
403 | return -EFAULT; | 404 | return -EFAULT; |
404 | 405 | ||
405 | /* check client structures are in place */ | 406 | /* check client structures are in place */ |
406 | snd_assert(client != NULL, return -ENXIO); | 407 | if (snd_BUG_ON(!client)) |
408 | return -ENXIO; | ||
407 | 409 | ||
408 | if (!client->accept_input || (fifo = client->data.user.fifo) == NULL) | 410 | if (!client->accept_input || (fifo = client->data.user.fifo) == NULL) |
409 | return -ENXIO; | 411 | return -ENXIO; |
@@ -825,7 +827,8 @@ int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop) | |||
825 | struct snd_seq_client *client; | 827 | struct snd_seq_client *client; |
826 | int result; | 828 | int result; |
827 | 829 | ||
828 | snd_assert(cell != NULL, return -EINVAL); | 830 | if (snd_BUG_ON(!cell)) |
831 | return -EINVAL; | ||
829 | 832 | ||
830 | client = snd_seq_client_use_ptr(cell->event.source.client); | 833 | client = snd_seq_client_use_ptr(cell->event.source.client); |
831 | if (client == NULL) { | 834 | if (client == NULL) { |
@@ -994,7 +997,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, | |||
994 | return -ENXIO; | 997 | return -ENXIO; |
995 | 998 | ||
996 | /* check client structures are in place */ | 999 | /* check client structures are in place */ |
997 | snd_assert(client != NULL, return -ENXIO); | 1000 | if (snd_BUG_ON(!client)) |
1001 | return -ENXIO; | ||
998 | 1002 | ||
999 | if (!client->accept_output || client->pool == NULL) | 1003 | if (!client->accept_output || client->pool == NULL) |
1000 | return -ENXIO; | 1004 | return -ENXIO; |
@@ -1076,7 +1080,8 @@ static unsigned int snd_seq_poll(struct file *file, poll_table * wait) | |||
1076 | unsigned int mask = 0; | 1080 | unsigned int mask = 0; |
1077 | 1081 | ||
1078 | /* check client structures are in place */ | 1082 | /* check client structures are in place */ |
1079 | snd_assert(client != NULL, return -ENXIO); | 1083 | if (snd_BUG_ON(!client)) |
1084 | return -ENXIO; | ||
1080 | 1085 | ||
1081 | if ((snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_INPUT) && | 1086 | if ((snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_INPUT) && |
1082 | client->data.user.fifo) { | 1087 | client->data.user.fifo) { |
@@ -2195,7 +2200,8 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
2195 | { | 2200 | { |
2196 | struct snd_seq_client *client = file->private_data; | 2201 | struct snd_seq_client *client = file->private_data; |
2197 | 2202 | ||
2198 | snd_assert(client != NULL, return -ENXIO); | 2203 | if (snd_BUG_ON(!client)) |
2204 | return -ENXIO; | ||
2199 | 2205 | ||
2200 | return snd_seq_do_ioctl(client, cmd, (void __user *) arg); | 2206 | return snd_seq_do_ioctl(client, cmd, (void __user *) arg); |
2201 | } | 2207 | } |
@@ -2216,7 +2222,8 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, | |||
2216 | struct snd_seq_client *client; | 2222 | struct snd_seq_client *client; |
2217 | va_list args; | 2223 | va_list args; |
2218 | 2224 | ||
2219 | snd_assert(! in_interrupt(), return -EBUSY); | 2225 | if (snd_BUG_ON(in_interrupt())) |
2226 | return -EBUSY; | ||
2220 | 2227 | ||
2221 | if (card && client_index >= SNDRV_SEQ_CLIENTS_PER_CARD) | 2228 | if (card && client_index >= SNDRV_SEQ_CLIENTS_PER_CARD) |
2222 | return -EINVAL; | 2229 | return -EINVAL; |
@@ -2265,7 +2272,8 @@ int snd_seq_delete_kernel_client(int client) | |||
2265 | { | 2272 | { |
2266 | struct snd_seq_client *ptr; | 2273 | struct snd_seq_client *ptr; |
2267 | 2274 | ||
2268 | snd_assert(! in_interrupt(), return -EBUSY); | 2275 | if (snd_BUG_ON(in_interrupt())) |
2276 | return -EBUSY; | ||
2269 | 2277 | ||
2270 | ptr = clientptr(client); | 2278 | ptr = clientptr(client); |
2271 | if (ptr == NULL) | 2279 | if (ptr == NULL) |
@@ -2288,7 +2296,8 @@ static int kernel_client_enqueue(int client, struct snd_seq_event *ev, | |||
2288 | struct snd_seq_client *cptr; | 2296 | struct snd_seq_client *cptr; |
2289 | int result; | 2297 | int result; |
2290 | 2298 | ||
2291 | snd_assert(ev != NULL, return -EINVAL); | 2299 | if (snd_BUG_ON(!ev)) |
2300 | return -EINVAL; | ||
2292 | 2301 | ||
2293 | if (ev->type == SNDRV_SEQ_EVENT_NONE) | 2302 | if (ev->type == SNDRV_SEQ_EVENT_NONE) |
2294 | return 0; /* ignore this */ | 2303 | return 0; /* ignore this */ |
@@ -2354,7 +2363,8 @@ int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, | |||
2354 | struct snd_seq_client *cptr; | 2363 | struct snd_seq_client *cptr; |
2355 | int result; | 2364 | int result; |
2356 | 2365 | ||
2357 | snd_assert(ev != NULL, return -EINVAL); | 2366 | if (snd_BUG_ON(!ev)) |
2367 | return -EINVAL; | ||
2358 | 2368 | ||
2359 | /* fill in client number */ | 2369 | /* fill in client number */ |
2360 | ev->queue = SNDRV_SEQ_QUEUE_DIRECT; | 2370 | ev->queue = SNDRV_SEQ_QUEUE_DIRECT; |
diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c index 9628c06e4eab..38693f47c262 100644 --- a/sound/core/seq/seq_compat.c +++ b/sound/core/seq/seq_compat.c | |||
@@ -92,7 +92,8 @@ static long snd_seq_ioctl_compat(struct file *file, unsigned int cmd, unsigned l | |||
92 | struct snd_seq_client *client = file->private_data; | 92 | struct snd_seq_client *client = file->private_data; |
93 | void __user *argp = compat_ptr(arg); | 93 | void __user *argp = compat_ptr(arg); |
94 | 94 | ||
95 | snd_assert(client != NULL, return -ENXIO); | 95 | if (snd_BUG_ON(!client)) |
96 | return -ENXIO; | ||
96 | 97 | ||
97 | switch (cmd) { | 98 | switch (cmd) { |
98 | case SNDRV_SEQ_IOCTL_PVERSION: | 99 | case SNDRV_SEQ_IOCTL_PVERSION: |
diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index 05410e536a4f..1f997675c893 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c | |||
@@ -187,7 +187,8 @@ int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, | |||
187 | if (result) | 187 | if (result) |
188 | *result = NULL; | 188 | *result = NULL; |
189 | 189 | ||
190 | snd_assert(id != NULL, return -EINVAL); | 190 | if (snd_BUG_ON(!id)) |
191 | return -EINVAL; | ||
191 | 192 | ||
192 | ops = find_driver(id, 1); | 193 | ops = find_driver(id, 1); |
193 | if (ops == NULL) | 194 | if (ops == NULL) |
@@ -232,7 +233,8 @@ static int snd_seq_device_free(struct snd_seq_device *dev) | |||
232 | { | 233 | { |
233 | struct ops_list *ops; | 234 | struct ops_list *ops; |
234 | 235 | ||
235 | snd_assert(dev != NULL, return -EINVAL); | 236 | if (snd_BUG_ON(!dev)) |
237 | return -EINVAL; | ||
236 | 238 | ||
237 | ops = find_driver(dev->id, 0); | 239 | ops = find_driver(dev->id, 0); |
238 | if (ops == NULL) | 240 | if (ops == NULL) |
diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c index 3a94ed021bd9..0d75afa786bc 100644 --- a/sound/core/seq/seq_fifo.c +++ b/sound/core/seq/seq_fifo.c | |||
@@ -65,9 +65,11 @@ void snd_seq_fifo_delete(struct snd_seq_fifo **fifo) | |||
65 | { | 65 | { |
66 | struct snd_seq_fifo *f; | 66 | struct snd_seq_fifo *f; |
67 | 67 | ||
68 | snd_assert(fifo != NULL, return); | 68 | if (snd_BUG_ON(!fifo)) |
69 | return; | ||
69 | f = *fifo; | 70 | f = *fifo; |
70 | snd_assert(f != NULL, return); | 71 | if (snd_BUG_ON(!f)) |
72 | return; | ||
71 | *fifo = NULL; | 73 | *fifo = NULL; |
72 | 74 | ||
73 | snd_seq_fifo_clear(f); | 75 | snd_seq_fifo_clear(f); |
@@ -116,7 +118,8 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f, | |||
116 | unsigned long flags; | 118 | unsigned long flags; |
117 | int err; | 119 | int err; |
118 | 120 | ||
119 | snd_assert(f != NULL, return -EINVAL); | 121 | if (snd_BUG_ON(!f)) |
122 | return -EINVAL; | ||
120 | 123 | ||
121 | snd_use_lock_use(&f->use_lock); | 124 | snd_use_lock_use(&f->use_lock); |
122 | err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */ | 125 | err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */ |
@@ -174,7 +177,8 @@ int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, | |||
174 | unsigned long flags; | 177 | unsigned long flags; |
175 | wait_queue_t wait; | 178 | wait_queue_t wait; |
176 | 179 | ||
177 | snd_assert(f != NULL, return -EINVAL); | 180 | if (snd_BUG_ON(!f)) |
181 | return -EINVAL; | ||
178 | 182 | ||
179 | *cellp = NULL; | 183 | *cellp = NULL; |
180 | init_waitqueue_entry(&wait, current); | 184 | init_waitqueue_entry(&wait, current); |
@@ -233,7 +237,8 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) | |||
233 | struct snd_seq_pool *newpool, *oldpool; | 237 | struct snd_seq_pool *newpool, *oldpool; |
234 | struct snd_seq_event_cell *cell, *next, *oldhead; | 238 | struct snd_seq_event_cell *cell, *next, *oldhead; |
235 | 239 | ||
236 | snd_assert(f != NULL && f->pool != NULL, return -EINVAL); | 240 | if (snd_BUG_ON(!f || !f->pool)) |
241 | return -EINVAL; | ||
237 | 242 | ||
238 | /* allocate new pool */ | 243 | /* allocate new pool */ |
239 | newpool = snd_seq_pool_new(poolsize); | 244 | newpool = snd_seq_pool_new(poolsize); |
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index 0cf6ac477318..7fb55436287f 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c | |||
@@ -187,9 +187,11 @@ void snd_seq_cell_free(struct snd_seq_event_cell * cell) | |||
187 | unsigned long flags; | 187 | unsigned long flags; |
188 | struct snd_seq_pool *pool; | 188 | struct snd_seq_pool *pool; |
189 | 189 | ||
190 | snd_assert(cell != NULL, return); | 190 | if (snd_BUG_ON(!cell)) |
191 | return; | ||
191 | pool = cell->pool; | 192 | pool = cell->pool; |
192 | snd_assert(pool != NULL, return); | 193 | if (snd_BUG_ON(!pool)) |
194 | return; | ||
193 | 195 | ||
194 | spin_lock_irqsave(&pool->lock, flags); | 196 | spin_lock_irqsave(&pool->lock, flags); |
195 | free_cell(pool, cell); | 197 | free_cell(pool, cell); |
@@ -378,7 +380,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool) | |||
378 | struct snd_seq_event_cell *cellptr; | 380 | struct snd_seq_event_cell *cellptr; |
379 | unsigned long flags; | 381 | unsigned long flags; |
380 | 382 | ||
381 | snd_assert(pool != NULL, return -EINVAL); | 383 | if (snd_BUG_ON(!pool)) |
384 | return -EINVAL; | ||
382 | if (pool->ptr) /* should be atomic? */ | 385 | if (pool->ptr) /* should be atomic? */ |
383 | return 0; | 386 | return 0; |
384 | 387 | ||
@@ -414,7 +417,8 @@ int snd_seq_pool_done(struct snd_seq_pool *pool) | |||
414 | struct snd_seq_event_cell *ptr; | 417 | struct snd_seq_event_cell *ptr; |
415 | int max_count = 5 * HZ; | 418 | int max_count = 5 * HZ; |
416 | 419 | ||
417 | snd_assert(pool != NULL, return -EINVAL); | 420 | if (snd_BUG_ON(!pool)) |
421 | return -EINVAL; | ||
418 | 422 | ||
419 | /* wait for closing all threads */ | 423 | /* wait for closing all threads */ |
420 | spin_lock_irqsave(&pool->lock, flags); | 424 | spin_lock_irqsave(&pool->lock, flags); |
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 99b35360c506..4d26146a62cc 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c | |||
@@ -116,7 +116,8 @@ static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, i | |||
116 | struct snd_rawmidi_runtime *runtime; | 116 | struct snd_rawmidi_runtime *runtime; |
117 | int tmp; | 117 | int tmp; |
118 | 118 | ||
119 | snd_assert(substream != NULL || buf != NULL, return -EINVAL); | 119 | if (snd_BUG_ON(!substream || !buf)) |
120 | return -EINVAL; | ||
120 | runtime = substream->runtime; | 121 | runtime = substream->runtime; |
121 | if ((tmp = runtime->avail) < count) { | 122 | if ((tmp = runtime->avail) < count) { |
122 | snd_printd("warning, output event was lost (count = %i, available = %i)\n", count, tmp); | 123 | snd_printd("warning, output event was lost (count = %i, available = %i)\n", count, tmp); |
@@ -135,7 +136,8 @@ static int event_process_midi(struct snd_seq_event *ev, int direct, | |||
135 | struct snd_rawmidi_substream *substream; | 136 | struct snd_rawmidi_substream *substream; |
136 | int len; | 137 | int len; |
137 | 138 | ||
138 | snd_assert(msynth != NULL, return -EINVAL); | 139 | if (snd_BUG_ON(!msynth)) |
140 | return -EINVAL; | ||
139 | substream = msynth->output_rfile.output; | 141 | substream = msynth->output_rfile.output; |
140 | if (substream == NULL) | 142 | if (substream == NULL) |
141 | return -ENODEV; | 143 | return -ENODEV; |
@@ -210,7 +212,8 @@ static int midisynth_unsubscribe(void *private_data, struct snd_seq_port_subscri | |||
210 | int err; | 212 | int err; |
211 | struct seq_midisynth *msynth = private_data; | 213 | struct seq_midisynth *msynth = private_data; |
212 | 214 | ||
213 | snd_assert(msynth->input_rfile.input != NULL, return -EINVAL); | 215 | if (snd_BUG_ON(!msynth->input_rfile.input)) |
216 | return -EINVAL; | ||
214 | err = snd_rawmidi_kernel_release(&msynth->input_rfile); | 217 | err = snd_rawmidi_kernel_release(&msynth->input_rfile); |
215 | return err; | 218 | return err; |
216 | } | 219 | } |
@@ -247,7 +250,8 @@ static int midisynth_unuse(void *private_data, struct snd_seq_port_subscribe *in | |||
247 | struct seq_midisynth *msynth = private_data; | 250 | struct seq_midisynth *msynth = private_data; |
248 | unsigned char buf = 0xff; /* MIDI reset */ | 251 | unsigned char buf = 0xff; /* MIDI reset */ |
249 | 252 | ||
250 | snd_assert(msynth->output_rfile.output != NULL, return -EINVAL); | 253 | if (snd_BUG_ON(!msynth->output_rfile.output)) |
254 | return -EINVAL; | ||
251 | /* sending single MIDI reset message to shut the device up */ | 255 | /* sending single MIDI reset message to shut the device up */ |
252 | snd_rawmidi_kernel_write(msynth->output_rfile.output, &buf, 1); | 256 | snd_rawmidi_kernel_write(msynth->output_rfile.output, &buf, 1); |
253 | snd_rawmidi_drain_output(msynth->output_rfile.output); | 257 | snd_rawmidi_drain_output(msynth->output_rfile.output); |
@@ -285,7 +289,8 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) | |||
285 | int device = dev->device; | 289 | int device = dev->device; |
286 | unsigned int input_count = 0, output_count = 0; | 290 | unsigned int input_count = 0, output_count = 0; |
287 | 291 | ||
288 | snd_assert(card != NULL && device >= 0 && device < SNDRV_RAWMIDI_DEVICES, return -EINVAL); | 292 | if (snd_BUG_ON(!card || device < 0 || device >= SNDRV_RAWMIDI_DEVICES)) |
293 | return -EINVAL; | ||
289 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 294 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
290 | if (! info) | 295 | if (! info) |
291 | return -ENOMEM; | 296 | return -ENOMEM; |
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 1c32a53d6bd8..3bf7d73ac52e 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c | |||
@@ -130,7 +130,8 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, | |||
130 | int num = -1; | 130 | int num = -1; |
131 | 131 | ||
132 | /* sanity check */ | 132 | /* sanity check */ |
133 | snd_assert(client, return NULL); | 133 | if (snd_BUG_ON(!client)) |
134 | return NULL; | ||
134 | 135 | ||
135 | if (client->num_ports >= SNDRV_SEQ_MAX_PORTS - 1) { | 136 | if (client->num_ports >= SNDRV_SEQ_MAX_PORTS - 1) { |
136 | snd_printk(KERN_WARNING "too many ports for client %d\n", client->number); | 137 | snd_printk(KERN_WARNING "too many ports for client %d\n", client->number); |
@@ -268,8 +269,8 @@ static int port_delete(struct snd_seq_client *client, | |||
268 | if (port->private_free) | 269 | if (port->private_free) |
269 | port->private_free(port->private_data); | 270 | port->private_free(port->private_data); |
270 | 271 | ||
271 | snd_assert(port->c_src.count == 0,); | 272 | snd_BUG_ON(port->c_src.count != 0); |
272 | snd_assert(port->c_dest.count == 0,); | 273 | snd_BUG_ON(port->c_dest.count != 0); |
273 | 274 | ||
274 | kfree(port); | 275 | kfree(port); |
275 | return 0; | 276 | return 0; |
@@ -336,7 +337,8 @@ int snd_seq_delete_all_ports(struct snd_seq_client *client) | |||
336 | int snd_seq_set_port_info(struct snd_seq_client_port * port, | 337 | int snd_seq_set_port_info(struct snd_seq_client_port * port, |
337 | struct snd_seq_port_info * info) | 338 | struct snd_seq_port_info * info) |
338 | { | 339 | { |
339 | snd_assert(port && info, return -EINVAL); | 340 | if (snd_BUG_ON(!port || !info)) |
341 | return -EINVAL; | ||
340 | 342 | ||
341 | /* set port name */ | 343 | /* set port name */ |
342 | if (info->name[0]) | 344 | if (info->name[0]) |
@@ -365,7 +367,8 @@ int snd_seq_set_port_info(struct snd_seq_client_port * port, | |||
365 | int snd_seq_get_port_info(struct snd_seq_client_port * port, | 367 | int snd_seq_get_port_info(struct snd_seq_client_port * port, |
366 | struct snd_seq_port_info * info) | 368 | struct snd_seq_port_info * info) |
367 | { | 369 | { |
368 | snd_assert(port && info, return -EINVAL); | 370 | if (snd_BUG_ON(!port || !info)) |
371 | return -EINVAL; | ||
369 | 372 | ||
370 | /* get port name */ | 373 | /* get port name */ |
371 | strlcpy(info->name, port->name, sizeof(info->name)); | 374 | strlcpy(info->name, port->name, sizeof(info->name)); |
diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c index 85969db576c9..0101a8b99b73 100644 --- a/sound/core/seq/seq_prioq.c +++ b/sound/core/seq/seq_prioq.c | |||
@@ -153,8 +153,8 @@ int snd_seq_prioq_cell_in(struct snd_seq_prioq * f, | |||
153 | int count; | 153 | int count; |
154 | int prior; | 154 | int prior; |
155 | 155 | ||
156 | snd_assert(f, return -EINVAL); | 156 | if (snd_BUG_ON(!f || !cell)) |
157 | snd_assert(cell, return -EINVAL); | 157 | return -EINVAL; |
158 | 158 | ||
159 | /* check flags */ | 159 | /* check flags */ |
160 | prior = (cell->event.flags & SNDRV_SEQ_PRIORITY_MASK); | 160 | prior = (cell->event.flags & SNDRV_SEQ_PRIORITY_MASK); |
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 4a48c6ee8ee8..e7a8e9e4edb2 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c | |||
@@ -315,7 +315,8 @@ int snd_seq_enqueue_event(struct snd_seq_event_cell *cell, int atomic, int hop) | |||
315 | int dest, err; | 315 | int dest, err; |
316 | struct snd_seq_queue *q; | 316 | struct snd_seq_queue *q; |
317 | 317 | ||
318 | snd_assert(cell != NULL, return -EINVAL); | 318 | if (snd_BUG_ON(!cell)) |
319 | return -EINVAL; | ||
319 | dest = cell->event.queue; /* destination queue */ | 320 | dest = cell->event.queue; /* destination queue */ |
320 | q = queueptr(dest); | 321 | q = queueptr(dest); |
321 | if (q == NULL) | 322 | if (q == NULL) |
@@ -734,7 +735,8 @@ int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop) | |||
734 | { | 735 | { |
735 | struct snd_seq_queue *q; | 736 | struct snd_seq_queue *q; |
736 | 737 | ||
737 | snd_assert(ev != NULL, return -EINVAL); | 738 | if (snd_BUG_ON(!ev)) |
739 | return -EINVAL; | ||
738 | q = queueptr(ev->data.queue.queue); | 740 | q = queueptr(ev->data.queue.queue); |
739 | 741 | ||
740 | if (q == NULL) | 742 | if (q == NULL) |
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index d8fcd62e400f..f745c317d6af 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c | |||
@@ -173,7 +173,8 @@ int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo) | |||
173 | { | 173 | { |
174 | unsigned long flags; | 174 | unsigned long flags; |
175 | 175 | ||
176 | snd_assert(tmr, return -EINVAL); | 176 | if (snd_BUG_ON(!tmr)) |
177 | return -EINVAL; | ||
177 | if (tempo <= 0) | 178 | if (tempo <= 0) |
178 | return -EINVAL; | 179 | return -EINVAL; |
179 | spin_lock_irqsave(&tmr->lock, flags); | 180 | spin_lock_irqsave(&tmr->lock, flags); |
@@ -190,7 +191,8 @@ int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq) | |||
190 | { | 191 | { |
191 | unsigned long flags; | 192 | unsigned long flags; |
192 | 193 | ||
193 | snd_assert(tmr, return -EINVAL); | 194 | if (snd_BUG_ON(!tmr)) |
195 | return -EINVAL; | ||
194 | if (ppq <= 0) | 196 | if (ppq <= 0) |
195 | return -EINVAL; | 197 | return -EINVAL; |
196 | spin_lock_irqsave(&tmr->lock, flags); | 198 | spin_lock_irqsave(&tmr->lock, flags); |
@@ -214,7 +216,8 @@ int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr, | |||
214 | { | 216 | { |
215 | unsigned long flags; | 217 | unsigned long flags; |
216 | 218 | ||
217 | snd_assert(tmr, return -EINVAL); | 219 | if (snd_BUG_ON(!tmr)) |
220 | return -EINVAL; | ||
218 | 221 | ||
219 | spin_lock_irqsave(&tmr->lock, flags); | 222 | spin_lock_irqsave(&tmr->lock, flags); |
220 | tmr->tick.cur_tick = position; | 223 | tmr->tick.cur_tick = position; |
@@ -229,7 +232,8 @@ int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr, | |||
229 | { | 232 | { |
230 | unsigned long flags; | 233 | unsigned long flags; |
231 | 234 | ||
232 | snd_assert(tmr, return -EINVAL); | 235 | if (snd_BUG_ON(!tmr)) |
236 | return -EINVAL; | ||
233 | 237 | ||
234 | snd_seq_sanity_real_time(&position); | 238 | snd_seq_sanity_real_time(&position); |
235 | spin_lock_irqsave(&tmr->lock, flags); | 239 | spin_lock_irqsave(&tmr->lock, flags); |
@@ -244,7 +248,8 @@ int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew, | |||
244 | { | 248 | { |
245 | unsigned long flags; | 249 | unsigned long flags; |
246 | 250 | ||
247 | snd_assert(tmr, return -EINVAL); | 251 | if (snd_BUG_ON(!tmr)) |
252 | return -EINVAL; | ||
248 | 253 | ||
249 | /* FIXME */ | 254 | /* FIXME */ |
250 | if (base != SKEW_BASE) { | 255 | if (base != SKEW_BASE) { |
@@ -265,7 +270,8 @@ int snd_seq_timer_open(struct snd_seq_queue *q) | |||
265 | int err; | 270 | int err; |
266 | 271 | ||
267 | tmr = q->timer; | 272 | tmr = q->timer; |
268 | snd_assert(tmr != NULL, return -EINVAL); | 273 | if (snd_BUG_ON(!tmr)) |
274 | return -EINVAL; | ||
269 | if (tmr->timeri) | 275 | if (tmr->timeri) |
270 | return -EBUSY; | 276 | return -EBUSY; |
271 | sprintf(str, "sequencer queue %i", q->queue); | 277 | sprintf(str, "sequencer queue %i", q->queue); |
@@ -302,7 +308,8 @@ int snd_seq_timer_close(struct snd_seq_queue *q) | |||
302 | struct snd_seq_timer *tmr; | 308 | struct snd_seq_timer *tmr; |
303 | 309 | ||
304 | tmr = q->timer; | 310 | tmr = q->timer; |
305 | snd_assert(tmr != NULL, return -EINVAL); | 311 | if (snd_BUG_ON(!tmr)) |
312 | return -EINVAL; | ||
306 | if (tmr->timeri) { | 313 | if (tmr->timeri) { |
307 | snd_timer_stop(tmr->timeri); | 314 | snd_timer_stop(tmr->timeri); |
308 | snd_timer_close(tmr->timeri); | 315 | snd_timer_close(tmr->timeri); |
@@ -328,7 +335,8 @@ static int initialize_timer(struct snd_seq_timer *tmr) | |||
328 | unsigned long freq; | 335 | unsigned long freq; |
329 | 336 | ||
330 | t = tmr->timeri->timer; | 337 | t = tmr->timeri->timer; |
331 | snd_assert(t, return -EINVAL); | 338 | if (snd_BUG_ON(!t)) |
339 | return -EINVAL; | ||
332 | 340 | ||
333 | freq = tmr->preferred_resolution; | 341 | freq = tmr->preferred_resolution; |
334 | if (!freq) | 342 | if (!freq) |
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c index cefd228cd2aa..d4564edd61d7 100644 --- a/sound/core/sgbuf.c +++ b/sound/core/sgbuf.c | |||
@@ -41,9 +41,11 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab) | |||
41 | tmpb.dev.type = SNDRV_DMA_TYPE_DEV; | 41 | tmpb.dev.type = SNDRV_DMA_TYPE_DEV; |
42 | tmpb.dev.dev = sgbuf->dev; | 42 | tmpb.dev.dev = sgbuf->dev; |
43 | for (i = 0; i < sgbuf->pages; i++) { | 43 | for (i = 0; i < sgbuf->pages; i++) { |
44 | if (!(sgbuf->table[i].addr & ~PAGE_MASK)) | ||
45 | continue; /* continuous pages */ | ||
44 | tmpb.area = sgbuf->table[i].buf; | 46 | tmpb.area = sgbuf->table[i].buf; |
45 | tmpb.addr = sgbuf->table[i].addr; | 47 | tmpb.addr = sgbuf->table[i].addr & PAGE_MASK; |
46 | tmpb.bytes = PAGE_SIZE; | 48 | tmpb.bytes = (sgbuf->table[i].addr & ~PAGE_MASK) << PAGE_SHIFT; |
47 | snd_dma_free_pages(&tmpb); | 49 | snd_dma_free_pages(&tmpb); |
48 | } | 50 | } |
49 | if (dmab->area) | 51 | if (dmab->area) |
@@ -58,13 +60,17 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab) | |||
58 | return 0; | 60 | return 0; |
59 | } | 61 | } |
60 | 62 | ||
63 | #define MAX_ALLOC_PAGES 32 | ||
64 | |||
61 | void *snd_malloc_sgbuf_pages(struct device *device, | 65 | void *snd_malloc_sgbuf_pages(struct device *device, |
62 | size_t size, struct snd_dma_buffer *dmab, | 66 | size_t size, struct snd_dma_buffer *dmab, |
63 | size_t *res_size) | 67 | size_t *res_size) |
64 | { | 68 | { |
65 | struct snd_sg_buf *sgbuf; | 69 | struct snd_sg_buf *sgbuf; |
66 | unsigned int i, pages; | 70 | unsigned int i, pages, chunk, maxpages; |
67 | struct snd_dma_buffer tmpb; | 71 | struct snd_dma_buffer tmpb; |
72 | struct snd_sg_page *table; | ||
73 | struct page **pgtable; | ||
68 | 74 | ||
69 | dmab->area = NULL; | 75 | dmab->area = NULL; |
70 | dmab->addr = 0; | 76 | dmab->addr = 0; |
@@ -74,31 +80,55 @@ void *snd_malloc_sgbuf_pages(struct device *device, | |||
74 | sgbuf->dev = device; | 80 | sgbuf->dev = device; |
75 | pages = snd_sgbuf_aligned_pages(size); | 81 | pages = snd_sgbuf_aligned_pages(size); |
76 | sgbuf->tblsize = sgbuf_align_table(pages); | 82 | sgbuf->tblsize = sgbuf_align_table(pages); |
77 | sgbuf->table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->table), GFP_KERNEL); | 83 | table = kcalloc(sgbuf->tblsize, sizeof(*table), GFP_KERNEL); |
78 | if (! sgbuf->table) | 84 | if (!table) |
79 | goto _failed; | 85 | goto _failed; |
80 | sgbuf->page_table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->page_table), GFP_KERNEL); | 86 | sgbuf->table = table; |
81 | if (! sgbuf->page_table) | 87 | pgtable = kcalloc(sgbuf->tblsize, sizeof(*pgtable), GFP_KERNEL); |
88 | if (!pgtable) | ||
82 | goto _failed; | 89 | goto _failed; |
90 | sgbuf->page_table = pgtable; | ||
83 | 91 | ||
84 | /* allocate each page */ | 92 | /* allocate pages */ |
85 | for (i = 0; i < pages; i++) { | 93 | maxpages = MAX_ALLOC_PAGES; |
86 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, device, PAGE_SIZE, &tmpb) < 0) { | 94 | while (pages > 0) { |
87 | if (res_size == NULL) | 95 | chunk = pages; |
96 | /* don't be too eager to take a huge chunk */ | ||
97 | if (chunk > maxpages) | ||
98 | chunk = maxpages; | ||
99 | chunk <<= PAGE_SHIFT; | ||
100 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, device, | ||
101 | chunk, &tmpb) < 0) { | ||
102 | if (!sgbuf->pages) | ||
103 | return NULL; | ||
104 | if (!res_size) | ||
88 | goto _failed; | 105 | goto _failed; |
89 | *res_size = size = sgbuf->pages * PAGE_SIZE; | 106 | size = sgbuf->pages * PAGE_SIZE; |
90 | break; | 107 | break; |
91 | } | 108 | } |
92 | sgbuf->table[i].buf = tmpb.area; | 109 | chunk = tmpb.bytes >> PAGE_SHIFT; |
93 | sgbuf->table[i].addr = tmpb.addr; | 110 | for (i = 0; i < chunk; i++) { |
94 | sgbuf->page_table[i] = virt_to_page(tmpb.area); | 111 | table->buf = tmpb.area; |
95 | sgbuf->pages++; | 112 | table->addr = tmpb.addr; |
113 | if (!i) | ||
114 | table->addr |= chunk; /* mark head */ | ||
115 | table++; | ||
116 | *pgtable++ = virt_to_page(tmpb.area); | ||
117 | tmpb.area += PAGE_SIZE; | ||
118 | tmpb.addr += PAGE_SIZE; | ||
119 | } | ||
120 | sgbuf->pages += chunk; | ||
121 | pages -= chunk; | ||
122 | if (chunk < maxpages) | ||
123 | maxpages = chunk; | ||
96 | } | 124 | } |
97 | 125 | ||
98 | sgbuf->size = size; | 126 | sgbuf->size = size; |
99 | dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, PAGE_KERNEL); | 127 | dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, PAGE_KERNEL); |
100 | if (! dmab->area) | 128 | if (! dmab->area) |
101 | goto _failed; | 129 | goto _failed; |
130 | if (res_size) | ||
131 | *res_size = sgbuf->size; | ||
102 | return dmab->area; | 132 | return dmab->area; |
103 | 133 | ||
104 | _failed: | 134 | _failed: |
diff --git a/sound/core/sound.c b/sound/core/sound.c index 1003ae375d47..44a69bb8d4f0 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -34,8 +34,6 @@ | |||
34 | #include <linux/kmod.h> | 34 | #include <linux/kmod.h> |
35 | #include <linux/mutex.h> | 35 | #include <linux/mutex.h> |
36 | 36 | ||
37 | #define SNDRV_OS_MINORS 256 | ||
38 | |||
39 | static int major = CONFIG_SND_MAJOR; | 37 | static int major = CONFIG_SND_MAJOR; |
40 | int snd_major; | 38 | int snd_major; |
41 | EXPORT_SYMBOL(snd_major); | 39 | EXPORT_SYMBOL(snd_major); |
@@ -208,20 +206,23 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) | |||
208 | minor = type; | 206 | minor = type; |
209 | break; | 207 | break; |
210 | case SNDRV_DEVICE_TYPE_CONTROL: | 208 | case SNDRV_DEVICE_TYPE_CONTROL: |
211 | snd_assert(card != NULL, return -EINVAL); | 209 | if (snd_BUG_ON(!card)) |
210 | return -EINVAL; | ||
212 | minor = SNDRV_MINOR(card->number, type); | 211 | minor = SNDRV_MINOR(card->number, type); |
213 | break; | 212 | break; |
214 | case SNDRV_DEVICE_TYPE_HWDEP: | 213 | case SNDRV_DEVICE_TYPE_HWDEP: |
215 | case SNDRV_DEVICE_TYPE_RAWMIDI: | 214 | case SNDRV_DEVICE_TYPE_RAWMIDI: |
216 | case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: | 215 | case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: |
217 | case SNDRV_DEVICE_TYPE_PCM_CAPTURE: | 216 | case SNDRV_DEVICE_TYPE_PCM_CAPTURE: |
218 | snd_assert(card != NULL, return -EINVAL); | 217 | if (snd_BUG_ON(!card)) |
218 | return -EINVAL; | ||
219 | minor = SNDRV_MINOR(card->number, type + dev); | 219 | minor = SNDRV_MINOR(card->number, type + dev); |
220 | break; | 220 | break; |
221 | default: | 221 | default: |
222 | return -EINVAL; | 222 | return -EINVAL; |
223 | } | 223 | } |
224 | snd_assert(minor >= 0 && minor < SNDRV_OS_MINORS, return -EINVAL); | 224 | if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) |
225 | return -EINVAL; | ||
225 | return minor; | 226 | return minor; |
226 | } | 227 | } |
227 | #endif | 228 | #endif |
@@ -249,7 +250,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, | |||
249 | int minor; | 250 | int minor; |
250 | struct snd_minor *preg; | 251 | struct snd_minor *preg; |
251 | 252 | ||
252 | snd_assert(name, return -EINVAL); | 253 | if (snd_BUG_ON(!name)) |
254 | return -EINVAL; | ||
253 | preg = kmalloc(sizeof *preg, GFP_KERNEL); | 255 | preg = kmalloc(sizeof *preg, GFP_KERNEL); |
254 | if (preg == NULL) | 256 | if (preg == NULL) |
255 | return -ENOMEM; | 257 | return -ENOMEM; |
@@ -272,9 +274,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, | |||
272 | return minor; | 274 | return minor; |
273 | } | 275 | } |
274 | snd_minors[minor] = preg; | 276 | snd_minors[minor] = preg; |
275 | preg->dev = device_create_drvdata(sound_class, device, | 277 | preg->dev = device_create(sound_class, device, MKDEV(major, minor), |
276 | MKDEV(major, minor), | 278 | private_data, "%s", name); |
277 | private_data, "%s", name); | ||
278 | if (IS_ERR(preg->dev)) { | 279 | if (IS_ERR(preg->dev)) { |
279 | snd_minors[minor] = NULL; | 280 | snd_minors[minor] = NULL; |
280 | mutex_unlock(&sound_mutex); | 281 | mutex_unlock(&sound_mutex); |
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index 7be51546eb9e..7fe12264ff80 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c | |||
@@ -64,7 +64,8 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) | |||
64 | 64 | ||
65 | switch (type) { | 65 | switch (type) { |
66 | case SNDRV_OSS_DEVICE_TYPE_MIXER: | 66 | case SNDRV_OSS_DEVICE_TYPE_MIXER: |
67 | snd_assert(card != NULL && dev <= 1, return -EINVAL); | 67 | if (snd_BUG_ON(!card || dev < 0 || dev > 1)) |
68 | return -EINVAL; | ||
68 | minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIXER1 : SNDRV_MINOR_OSS_MIXER)); | 69 | minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIXER1 : SNDRV_MINOR_OSS_MIXER)); |
69 | break; | 70 | break; |
70 | case SNDRV_OSS_DEVICE_TYPE_SEQUENCER: | 71 | case SNDRV_OSS_DEVICE_TYPE_SEQUENCER: |
@@ -74,11 +75,13 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) | |||
74 | minor = SNDRV_MINOR_OSS_MUSIC; | 75 | minor = SNDRV_MINOR_OSS_MUSIC; |
75 | break; | 76 | break; |
76 | case SNDRV_OSS_DEVICE_TYPE_PCM: | 77 | case SNDRV_OSS_DEVICE_TYPE_PCM: |
77 | snd_assert(card != NULL && dev <= 1, return -EINVAL); | 78 | if (snd_BUG_ON(!card || dev < 0 || dev > 1)) |
79 | return -EINVAL; | ||
78 | minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_PCM1 : SNDRV_MINOR_OSS_PCM)); | 80 | minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_PCM1 : SNDRV_MINOR_OSS_PCM)); |
79 | break; | 81 | break; |
80 | case SNDRV_OSS_DEVICE_TYPE_MIDI: | 82 | case SNDRV_OSS_DEVICE_TYPE_MIDI: |
81 | snd_assert(card != NULL && dev <= 1, return -EINVAL); | 83 | if (snd_BUG_ON(!card || dev < 0 || dev > 1)) |
84 | return -EINVAL; | ||
82 | minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIDI1 : SNDRV_MINOR_OSS_MIDI)); | 85 | minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIDI1 : SNDRV_MINOR_OSS_MIDI)); |
83 | break; | 86 | break; |
84 | case SNDRV_OSS_DEVICE_TYPE_DMFM: | 87 | case SNDRV_OSS_DEVICE_TYPE_DMFM: |
@@ -90,7 +93,8 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) | |||
90 | default: | 93 | default: |
91 | return -EINVAL; | 94 | return -EINVAL; |
92 | } | 95 | } |
93 | snd_assert(minor >= 0 && minor < SNDRV_OSS_MINORS, return -EINVAL); | 96 | if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OSS_MINORS)) |
97 | return -EINVAL; | ||
94 | return minor; | 98 | return minor; |
95 | } | 99 | } |
96 | 100 | ||
diff --git a/sound/core/timer.c b/sound/core/timer.c index 0af337efc64e..e582face89d2 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c | |||
@@ -306,7 +306,8 @@ int snd_timer_close(struct snd_timer_instance *timeri) | |||
306 | struct snd_timer *timer = NULL; | 306 | struct snd_timer *timer = NULL; |
307 | struct snd_timer_instance *slave, *tmp; | 307 | struct snd_timer_instance *slave, *tmp; |
308 | 308 | ||
309 | snd_assert(timeri != NULL, return -ENXIO); | 309 | if (snd_BUG_ON(!timeri)) |
310 | return -ENXIO; | ||
310 | 311 | ||
311 | /* force to stop the timer */ | 312 | /* force to stop the timer */ |
312 | snd_timer_stop(timeri); | 313 | snd_timer_stop(timeri); |
@@ -385,8 +386,9 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event) | |||
385 | do_posix_clock_monotonic_gettime(&tstamp); | 386 | do_posix_clock_monotonic_gettime(&tstamp); |
386 | else | 387 | else |
387 | getnstimeofday(&tstamp); | 388 | getnstimeofday(&tstamp); |
388 | snd_assert(event >= SNDRV_TIMER_EVENT_START && | 389 | if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_START || |
389 | event <= SNDRV_TIMER_EVENT_PAUSE, return); | 390 | event > SNDRV_TIMER_EVENT_PAUSE)) |
391 | return; | ||
390 | if (event == SNDRV_TIMER_EVENT_START || | 392 | if (event == SNDRV_TIMER_EVENT_START || |
391 | event == SNDRV_TIMER_EVENT_CONTINUE) | 393 | event == SNDRV_TIMER_EVENT_CONTINUE) |
392 | resolution = snd_timer_resolution(ti); | 394 | resolution = snd_timer_resolution(ti); |
@@ -474,7 +476,8 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri, | |||
474 | struct snd_timer *timer; | 476 | struct snd_timer *timer; |
475 | unsigned long flags; | 477 | unsigned long flags; |
476 | 478 | ||
477 | snd_assert(timeri != NULL, return -ENXIO); | 479 | if (snd_BUG_ON(!timeri)) |
480 | return -ENXIO; | ||
478 | 481 | ||
479 | if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) { | 482 | if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) { |
480 | if (!keep_flag) { | 483 | if (!keep_flag) { |
@@ -758,9 +761,10 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, | |||
758 | .dev_disconnect = snd_timer_dev_disconnect, | 761 | .dev_disconnect = snd_timer_dev_disconnect, |
759 | }; | 762 | }; |
760 | 763 | ||
761 | snd_assert(tid != NULL, return -EINVAL); | 764 | if (snd_BUG_ON(!tid)) |
762 | snd_assert(rtimer != NULL, return -EINVAL); | 765 | return -EINVAL; |
763 | *rtimer = NULL; | 766 | if (rtimer) |
767 | *rtimer = NULL; | ||
764 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); | 768 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); |
765 | if (timer == NULL) { | 769 | if (timer == NULL) { |
766 | snd_printk(KERN_ERR "timer: cannot allocate\n"); | 770 | snd_printk(KERN_ERR "timer: cannot allocate\n"); |
@@ -788,13 +792,15 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, | |||
788 | return err; | 792 | return err; |
789 | } | 793 | } |
790 | } | 794 | } |
791 | *rtimer = timer; | 795 | if (rtimer) |
796 | *rtimer = timer; | ||
792 | return 0; | 797 | return 0; |
793 | } | 798 | } |
794 | 799 | ||
795 | static int snd_timer_free(struct snd_timer *timer) | 800 | static int snd_timer_free(struct snd_timer *timer) |
796 | { | 801 | { |
797 | snd_assert(timer != NULL, return -ENXIO); | 802 | if (!timer) |
803 | return 0; | ||
798 | 804 | ||
799 | mutex_lock(®ister_mutex); | 805 | mutex_lock(®ister_mutex); |
800 | if (! list_empty(&timer->open_list_head)) { | 806 | if (! list_empty(&timer->open_list_head)) { |
@@ -827,8 +833,8 @@ static int snd_timer_dev_register(struct snd_device *dev) | |||
827 | struct snd_timer *timer = dev->device_data; | 833 | struct snd_timer *timer = dev->device_data; |
828 | struct snd_timer *timer1; | 834 | struct snd_timer *timer1; |
829 | 835 | ||
830 | snd_assert(timer != NULL && timer->hw.start != NULL && | 836 | if (snd_BUG_ON(!timer || !timer->hw.start || !timer->hw.stop)) |
831 | timer->hw.stop != NULL, return -ENXIO); | 837 | return -ENXIO; |
832 | if (!(timer->hw.flags & SNDRV_TIMER_HW_SLAVE) && | 838 | if (!(timer->hw.flags & SNDRV_TIMER_HW_SLAVE) && |
833 | !timer->hw.resolution && timer->hw.c_resolution == NULL) | 839 | !timer->hw.resolution && timer->hw.c_resolution == NULL) |
834 | return -EINVAL; | 840 | return -EINVAL; |
@@ -879,8 +885,9 @@ void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstam | |||
879 | 885 | ||
880 | if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) | 886 | if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) |
881 | return; | 887 | return; |
882 | snd_assert(event >= SNDRV_TIMER_EVENT_MSTART && | 888 | if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_MSTART || |
883 | event <= SNDRV_TIMER_EVENT_MRESUME, return); | 889 | event > SNDRV_TIMER_EVENT_MRESUME)) |
890 | return; | ||
884 | spin_lock_irqsave(&timer->lock, flags); | 891 | spin_lock_irqsave(&timer->lock, flags); |
885 | if (event == SNDRV_TIMER_EVENT_MSTART || | 892 | if (event == SNDRV_TIMER_EVENT_MSTART || |
886 | event == SNDRV_TIMER_EVENT_MCONTINUE || | 893 | event == SNDRV_TIMER_EVENT_MCONTINUE || |
diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c index 5512f5373c52..e05802ae6e1b 100644 --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c | |||
@@ -40,9 +40,11 @@ static int snd_timer_user_info_compat(struct file *file, | |||
40 | struct snd_timer *t; | 40 | struct snd_timer *t; |
41 | 41 | ||
42 | tu = file->private_data; | 42 | tu = file->private_data; |
43 | snd_assert(tu->timeri != NULL, return -ENXIO); | 43 | if (snd_BUG_ON(!tu->timeri)) |
44 | return -ENXIO; | ||
44 | t = tu->timeri->timer; | 45 | t = tu->timeri->timer; |
45 | snd_assert(t != NULL, return -ENXIO); | 46 | if (snd_BUG_ON(!t)) |
47 | return -ENXIO; | ||
46 | memset(&info, 0, sizeof(info)); | 48 | memset(&info, 0, sizeof(info)); |
47 | info.card = t->card ? t->card->number : -1; | 49 | info.card = t->card ? t->card->number : -1; |
48 | if (t->hw.flags & SNDRV_TIMER_HW_SLAVE) | 50 | if (t->hw.flags & SNDRV_TIMER_HW_SLAVE) |
@@ -71,7 +73,8 @@ static int snd_timer_user_status_compat(struct file *file, | |||
71 | struct snd_timer_status status; | 73 | struct snd_timer_status status; |
72 | 74 | ||
73 | tu = file->private_data; | 75 | tu = file->private_data; |
74 | snd_assert(tu->timeri != NULL, return -ENXIO); | 76 | if (snd_BUG_ON(!tu->timeri)) |
77 | return -ENXIO; | ||
75 | memset(&status, 0, sizeof(status)); | 78 | memset(&status, 0, sizeof(status)); |
76 | status.tstamp = tu->tstamp; | 79 | status.tstamp = tu->tstamp; |
77 | status.resolution = snd_timer_resolution(tu->timeri); | 80 | status.resolution = snd_timer_resolution(tu->timeri); |