X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=sound%2Fcore%2Foss%2Fmixer_oss.c;h=caab3ee273111d0587da4c73a3569aeee339de1e;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=d8359d301806233fd1195a4836365b10d551c8dd;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index d8359d301..caab3ee27 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -51,7 +52,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 = (snd_mixer_oss_file_t *)snd_kcalloc(sizeof(*fmixer), GFP_KERNEL); + fmixer = kcalloc(1, sizeof(*fmixer), GFP_KERNEL); if (fmixer == NULL) { snd_card_file_remove(card, file); return -ENOMEM; @@ -358,10 +359,16 @@ static int snd_mixer_oss_ioctl1(snd_mixer_oss_file_t *fmixer, unsigned int cmd, return -ENXIO; } +/* FIXME: need to unlock BKL to allow preemption */ int snd_mixer_oss_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { - return snd_mixer_oss_ioctl1((snd_mixer_oss_file_t *) file->private_data, cmd, arg); + int err; + /* FIXME: need to unlock BKL to allow preemption */ + unlock_kernel(); + err = snd_mixer_oss_ioctl1((snd_mixer_oss_file_t *) file->private_data, cmd, arg); + lock_kernel(); + return err; } int snd_mixer_oss_ioctl_card(snd_card_t *card, unsigned int cmd, unsigned long arg) @@ -508,8 +515,8 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer, up_read(&card->controls_rwsem); return; } - uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL); - uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL); + uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); + uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -544,8 +551,8 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer, up_read(&card->controls_rwsem); return; } - uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL); - uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL); + uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); + uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -607,8 +614,8 @@ 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 = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL); - uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL); + uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); + uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -646,8 +653,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, up_read(&fmixer->card->controls_rwsem); return; } - uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL); - uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL); + uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); + uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); @@ -767,8 +774,8 @@ 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 = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL); - uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL); + uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); + uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) { err = -ENOMEM; goto __unlock; @@ -814,8 +821,8 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int int err; unsigned int idx; - uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL); - uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL); + uinfo = kcalloc(1, sizeof(*uinfo), GFP_KERNEL); + uctl = kcalloc(1, sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) { err = -ENOMEM; goto __unlock; @@ -968,8 +975,10 @@ static int snd_mixer_oss_build_input(snd_mixer_oss_t *mixer, struct snd_mixer_os snd_ctl_elem_info_t uinfo; memset(&uinfo, 0, sizeof(uinfo)); - if (kctl->info(kctl, &uinfo)) + if (kctl->info(kctl, &uinfo)) { + up_read(&mixer->card->controls_rwsem); return 0; + } strcpy(str, ptr->name); if (!strcmp(str, "Master")) strcpy(str, "Mix"); @@ -1060,7 +1069,7 @@ static char *oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = { static void snd_mixer_oss_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) { - snd_mixer_oss_t *mixer = snd_magic_cast(snd_mixer_oss_t, entry->private_data, return); + snd_mixer_oss_t *mixer = entry->private_data; int i; down(&mixer->reg_mutex); @@ -1084,7 +1093,7 @@ static void snd_mixer_oss_proc_read(snd_info_entry_t *entry, static void snd_mixer_oss_proc_write(snd_info_entry_t *entry, snd_info_buffer_t * buffer) { - snd_mixer_oss_t *mixer = snd_magic_cast(snd_mixer_oss_t, entry->private_data, return); + snd_mixer_oss_t *mixer = entry->private_data; char line[128], str[32], idxstr[16], *cptr; int ch, idx; struct snd_mixer_oss_assign_table *tbl; @@ -1210,7 +1219,7 @@ static void snd_mixer_oss_build(snd_mixer_oss_t *mixer) }; unsigned int idx; - for (idx = 0; idx < sizeof(table) / sizeof(struct snd_mixer_oss_assign_table); idx++) + for (idx = 0; idx < ARRAY_SIZE(table); idx++) snd_mixer_oss_build_input(mixer, &table[idx], 0, 0); if (mixer->mask_recsrc) { mixer->get_recsrc = snd_mixer_oss_get_recsrc2; @@ -1224,7 +1233,7 @@ static void snd_mixer_oss_build(snd_mixer_oss_t *mixer) static int snd_mixer_oss_free1(void *private) { - snd_mixer_oss_t *mixer = snd_magic_cast(snd_mixer_oss_t, private, return -ENXIO); + snd_mixer_oss_t *mixer = private; snd_card_t * card; int idx; @@ -1237,7 +1246,7 @@ static int snd_mixer_oss_free1(void *private) if (chn->private_free) chn->private_free(chn); } - snd_magic_kfree(mixer); + kfree(mixer); return 0; } @@ -1249,7 +1258,7 @@ static int snd_mixer_oss_notify_handler(snd_card_t * card, int cmd) char name[128]; int idx, err; - mixer = snd_magic_kcalloc(snd_mixer_oss_t, sizeof(snd_mixer_oss_t), GFP_KERNEL); + mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL); if (mixer == NULL) return -ENOMEM; init_MUTEX(&mixer->reg_mutex); @@ -1259,7 +1268,7 @@ static int snd_mixer_oss_notify_handler(snd_card_t * card, int cmd) &snd_mixer_oss_reg, name)) < 0) { snd_printk("unable to register OSS mixer device %i:%i\n", card->number, 0); - snd_magic_kfree(mixer); + kfree(mixer); return err; } mixer->oss_dev_alloc = 1;