X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sound%2Fcore%2Foss%2Fmixer_oss.c;h=214933cf5d49a62084fc655a9ec05a5a438a7919;hb=d3d579f84ebf701dedd22ba696d1738ed6759ef7;hp=98fc0766f8853731757105c534556e27712e1e8f;hpb=8ed693d29b25bbd88471ec043cc01581419d0481;p=linux-2.6 diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 98fc0766f8..214933cf5d 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -53,7 +53,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file) err = snd_card_file_add(card, file); if (err < 0) return err; - fmixer = kcalloc(1, sizeof(*fmixer), GFP_KERNEL); + fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL); if (fmixer == NULL) { snd_card_file_remove(card, file); return -ENOMEM; @@ -517,13 +517,17 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer, up_read(&card->controls_rwsem); return; } - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); - snd_runtime_check(!kctl->get(kctl, uctl), goto __unalloc); - snd_runtime_check(uinfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN || uinfo->value.integer.min != 0 || uinfo->value.integer.max != 1, goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; + if (kctl->get(kctl, uctl)) + goto __unalloc; + if (uinfo->type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && + uinfo->value.integer.min == 0 && uinfo->value.integer.max == 1) + goto __unalloc; *left = snd_mixer_oss_conv1(uctl->value.integer.value[0], uinfo->value.integer.min, uinfo->value.integer.max, &pslot->volume[0]); if (uinfo->count > 1) *right = snd_mixer_oss_conv1(uctl->value.integer.value[1], uinfo->value.integer.min, uinfo->value.integer.max, &pslot->volume[1]); @@ -551,12 +555,14 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer, up_read(&card->controls_rwsem); return; } - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); - snd_runtime_check(!kctl->get(kctl, uctl), goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; + if (kctl->get(kctl, uctl)) + goto __unalloc; if (!uctl->value.integer.value[0]) { *left = 0; if (uinfo->count == 1) @@ -612,16 +618,20 @@ static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer, down_read(&card->controls_rwsem); if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) return; - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); - snd_runtime_check(uinfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN || uinfo->value.integer.min != 0 || uinfo->value.integer.max != 1, goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; + if (uinfo->type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && + uinfo->value.integer.min == 0 && uinfo->value.integer.max == 1) + goto __unalloc; uctl->value.integer.value[0] = snd_mixer_oss_conv2(left, uinfo->value.integer.min, uinfo->value.integer.max); if (uinfo->count > 1) uctl->value.integer.value[1] = snd_mixer_oss_conv2(right, uinfo->value.integer.min, uinfo->value.integer.max); - snd_runtime_check((res = kctl->put(kctl, uctl)) >= 0, goto __unalloc); + if ((res = kctl->put(kctl, uctl)) < 0) + goto __unalloc; if (res > 0) snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); __unalloc: @@ -649,11 +659,12 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, up_read(&fmixer->card->controls_rwsem); return; } - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; if (uinfo->count > 1) { uctl->value.integer.value[0] = left > 0 ? 1 : 0; uctl->value.integer.value[route ? 3 : 1] = right > 0 ? 1 : 0; @@ -664,7 +675,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, } else { uctl->value.integer.value[0] = (left > 0 || right > 0) ? 1 : 0; } - snd_runtime_check((res = kctl->put(kctl, uctl)) >= 0, goto __unalloc); + if ((res = kctl->put(kctl, uctl)) < 0) + goto __unalloc; if (res > 0) snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); __unalloc: @@ -768,17 +780,22 @@ static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int snd_ctl_elem_value_t *uctl; int err, idx; - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) { err = -ENOMEM; goto __unlock; } down_read(&card->controls_rwsem); kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); - snd_runtime_check(kctl != NULL, err = -ENOENT; goto __unlock); - snd_runtime_check(!(err = kctl->info(kctl, uinfo)), goto __unlock); - snd_runtime_check(!(err = kctl->get(kctl, uctl)), goto __unlock); + if (! kctl) { + err = -ENOENT; + goto __unlock; + } + if ((err = kctl->info(kctl, uinfo)) < 0) + goto __unlock; + if ((err = kctl->get(kctl, uctl)) < 0) + goto __unlock; for (idx = 0; idx < 32; idx++) { if (!(mixer->mask_recsrc & (1 << idx))) continue; @@ -813,16 +830,20 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int int err; unsigned int idx; - uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); - uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); + uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); + uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) { err = -ENOMEM; goto __unlock; } down_read(&card->controls_rwsem); kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); - snd_runtime_check(kctl != NULL, err = -ENOENT; goto __unlock); - snd_runtime_check(!(err = kctl->info(kctl, uinfo)), goto __unlock); + if (! kctl) { + err = -ENOENT; + goto __unlock; + } + if ((err = kctl->info(kctl, uinfo)) < 0) + goto __unlock; for (idx = 0; idx < 32; idx++) { if (!(mixer->mask_recsrc & (1 << idx))) continue; @@ -836,10 +857,11 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int break; slot = NULL; } - snd_runtime_check(slot != NULL, goto __unlock); + if (! slot) + goto __unlock; for (idx = 0; idx < uinfo->count; idx++) uctl->value.enumerated.item[idx] = slot->capture_item; - snd_runtime_check((err = kctl->put(kctl, uctl)) >= 0, ); + err = kctl->put(kctl, uctl); if (err > 0) snd_ctl_notify(fmixer->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); err = 0; @@ -1008,7 +1030,8 @@ static int snd_mixer_oss_build_input(snd_mixer_oss_t *mixer, struct snd_mixer_os up_read(&mixer->card->controls_rwsem); if (slot.present != 0) { pslot = (struct slot *)kmalloc(sizeof(slot), GFP_KERNEL); - snd_runtime_check(pslot != NULL, return -ENOMEM); + if (! pslot) + return -ENOMEM; *pslot = slot; pslot->signature = SNDRV_MIXER_OSS_SIGNATURE; pslot->assigned = ptr; @@ -1271,7 +1294,8 @@ static int snd_mixer_oss_notify_handler(snd_card_t * card, int cmd) card, 0, &snd_mixer_oss_reg, name)) < 0) { - snd_printk("unable to register OSS mixer device %i:%i\n", card->number, 0); + snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", + card->number, 0); kfree(mixer); return err; }