Commit 6c5cb93b authored by Takashi Iwai's avatar Takashi Iwai

Merge branch 'topic/ctxfi' into for-linus

* topic/ctxfi:
  ALSA: ctxfi - Simple code clean up
  ALSA: ctxfi - Native timer support for emu20k2
parents f604529d 35ebf6e7
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
/* Timer Registers */ /* Timer Registers */
#define TIMER_TIMR 0x1B7004 #define WC 0x1b7000
#define INTERRUPT_GIP 0x1B7010 #define TIMR 0x1b7004
#define INTERRUPT_GIE 0x1B7014 # define TIMR_IE (1<<15)
# define TIMR_IP (1<<14)
#define GIP 0x1b7010
#define GIE 0x1b7014
/* I2C Registers */ /* I2C Registers */
#define I2C_IF_ADDRESS 0x1B9000 #define I2C_IF_ADDRESS 0x1B9000
......
...@@ -63,7 +63,7 @@ static int amixer_set_input(struct amixer *amixer, struct rsc *rsc) ...@@ -63,7 +63,7 @@ static int amixer_set_input(struct amixer *amixer, struct rsc *rsc)
hw = amixer->rsc.hw; hw = amixer->rsc.hw;
hw->amixer_set_mode(amixer->rsc.ctrl_blk, AMIXER_Y_IMMEDIATE); hw->amixer_set_mode(amixer->rsc.ctrl_blk, AMIXER_Y_IMMEDIATE);
amixer->input = rsc; amixer->input = rsc;
if (NULL == rsc) if (!rsc)
hw->amixer_set_x(amixer->rsc.ctrl_blk, BLANK_SLOT); hw->amixer_set_x(amixer->rsc.ctrl_blk, BLANK_SLOT);
else else
hw->amixer_set_x(amixer->rsc.ctrl_blk, hw->amixer_set_x(amixer->rsc.ctrl_blk,
...@@ -99,7 +99,7 @@ static int amixer_set_sum(struct amixer *amixer, struct sum *sum) ...@@ -99,7 +99,7 @@ static int amixer_set_sum(struct amixer *amixer, struct sum *sum)
hw = amixer->rsc.hw; hw = amixer->rsc.hw;
amixer->sum = sum; amixer->sum = sum;
if (NULL == sum) { if (!sum) {
hw->amixer_set_se(amixer->rsc.ctrl_blk, 0); hw->amixer_set_se(amixer->rsc.ctrl_blk, 0);
} else { } else {
hw->amixer_set_se(amixer->rsc.ctrl_blk, 1); hw->amixer_set_se(amixer->rsc.ctrl_blk, 1);
...@@ -124,20 +124,20 @@ static int amixer_commit_write(struct amixer *amixer) ...@@ -124,20 +124,20 @@ static int amixer_commit_write(struct amixer *amixer)
/* Program master and conjugate resources */ /* Program master and conjugate resources */
amixer->rsc.ops->master(&amixer->rsc); amixer->rsc.ops->master(&amixer->rsc);
if (NULL != input) if (input)
input->ops->master(input); input->ops->master(input);
if (NULL != sum) if (sum)
sum->rsc.ops->master(&sum->rsc); sum->rsc.ops->master(&sum->rsc);
for (i = 0; i < amixer->rsc.msr; i++) { for (i = 0; i < amixer->rsc.msr; i++) {
hw->amixer_set_dirty_all(amixer->rsc.ctrl_blk); hw->amixer_set_dirty_all(amixer->rsc.ctrl_blk);
if (NULL != input) { if (input) {
hw->amixer_set_x(amixer->rsc.ctrl_blk, hw->amixer_set_x(amixer->rsc.ctrl_blk,
input->ops->output_slot(input)); input->ops->output_slot(input));
input->ops->next_conj(input); input->ops->next_conj(input);
} }
if (NULL != sum) { if (sum) {
hw->amixer_set_sadr(amixer->rsc.ctrl_blk, hw->amixer_set_sadr(amixer->rsc.ctrl_blk,
sum->rsc.ops->index(&sum->rsc)); sum->rsc.ops->index(&sum->rsc));
sum->rsc.ops->next_conj(&sum->rsc); sum->rsc.ops->next_conj(&sum->rsc);
...@@ -147,10 +147,10 @@ static int amixer_commit_write(struct amixer *amixer) ...@@ -147,10 +147,10 @@ static int amixer_commit_write(struct amixer *amixer)
amixer->rsc.ops->next_conj(&amixer->rsc); amixer->rsc.ops->next_conj(&amixer->rsc);
} }
amixer->rsc.ops->master(&amixer->rsc); amixer->rsc.ops->master(&amixer->rsc);
if (NULL != input) if (input)
input->ops->master(input); input->ops->master(input);
if (NULL != sum) if (sum)
sum->rsc.ops->master(&sum->rsc); sum->rsc.ops->master(&sum->rsc);
return 0; return 0;
...@@ -303,7 +303,7 @@ int amixer_mgr_create(void *hw, struct amixer_mgr **ramixer_mgr) ...@@ -303,7 +303,7 @@ int amixer_mgr_create(void *hw, struct amixer_mgr **ramixer_mgr)
*ramixer_mgr = NULL; *ramixer_mgr = NULL;
amixer_mgr = kzalloc(sizeof(*amixer_mgr), GFP_KERNEL); amixer_mgr = kzalloc(sizeof(*amixer_mgr), GFP_KERNEL);
if (NULL == amixer_mgr) if (!amixer_mgr)
return -ENOMEM; return -ENOMEM;
err = rsc_mgr_init(&amixer_mgr->mgr, AMIXER, AMIXER_RESOURCE_NUM, hw); err = rsc_mgr_init(&amixer_mgr->mgr, AMIXER, AMIXER_RESOURCE_NUM, hw);
...@@ -456,7 +456,7 @@ int sum_mgr_create(void *hw, struct sum_mgr **rsum_mgr) ...@@ -456,7 +456,7 @@ int sum_mgr_create(void *hw, struct sum_mgr **rsum_mgr)
*rsum_mgr = NULL; *rsum_mgr = NULL;
sum_mgr = kzalloc(sizeof(*sum_mgr), GFP_KERNEL); sum_mgr = kzalloc(sizeof(*sum_mgr), GFP_KERNEL);
if (NULL == sum_mgr) if (!sum_mgr)
return -ENOMEM; return -ENOMEM;
err = rsc_mgr_init(&sum_mgr->mgr, SUM, SUM_RESOURCE_NUM, hw); err = rsc_mgr_init(&sum_mgr->mgr, SUM, SUM_RESOURCE_NUM, hw);
......
...@@ -136,7 +136,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -136,7 +136,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
struct ct_vm *vm; struct ct_vm *vm;
if (NULL == apcm->substream) if (!apcm->substream)
return 0; return 0;
runtime = apcm->substream->runtime; runtime = apcm->substream->runtime;
...@@ -144,7 +144,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -144,7 +144,7 @@ static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes); apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes);
if (NULL == apcm->vm_block) if (!apcm->vm_block)
return -ENOENT; return -ENOENT;
return 0; return 0;
...@@ -154,7 +154,7 @@ static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -154,7 +154,7 @@ static void ct_unmap_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
{ {
struct ct_vm *vm; struct ct_vm *vm;
if (NULL == apcm->vm_block) if (!apcm->vm_block)
return; return;
vm = atc->vm; vm = atc->vm;
...@@ -231,16 +231,16 @@ atc_get_pitch(unsigned int input_rate, unsigned int output_rate) ...@@ -231,16 +231,16 @@ atc_get_pitch(unsigned int input_rate, unsigned int output_rate)
static int select_rom(unsigned int pitch) static int select_rom(unsigned int pitch)
{ {
if ((pitch > 0x00428f5c) && (pitch < 0x01b851ec)) { if (pitch > 0x00428f5c && pitch < 0x01b851ec) {
/* 0.26 <= pitch <= 1.72 */ /* 0.26 <= pitch <= 1.72 */
return 1; return 1;
} else if ((0x01d66666 == pitch) || (0x01d66667 == pitch)) { } else if (pitch == 0x01d66666 || pitch == 0x01d66667) {
/* pitch == 1.8375 */ /* pitch == 1.8375 */
return 2; return 2;
} else if (0x02000000 == pitch) { } else if (pitch == 0x02000000) {
/* pitch == 2 */ /* pitch == 2 */
return 3; return 3;
} else if ((pitch >= 0x0) && (pitch <= 0x08000000)) { } else if (pitch >= 0x0 && pitch <= 0x08000000) {
/* 0 <= pitch <= 8 */ /* 0 <= pitch <= 8 */
return 0; return 0;
} else { } else {
...@@ -283,7 +283,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -283,7 +283,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
/* Get AMIXER resource */ /* Get AMIXER resource */
n_amixer = (n_amixer < 2) ? 2 : n_amixer; n_amixer = (n_amixer < 2) ? 2 : n_amixer;
apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
if (NULL == apcm->amixers) { if (!apcm->amixers) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
...@@ -311,7 +311,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -311,7 +311,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
INIT_VOL, atc->pcm[i+device*2]); INIT_VOL, atc->pcm[i+device*2]);
mutex_unlock(&atc->atc_mutex); mutex_unlock(&atc->atc_mutex);
src = src->ops->next_interleave(src); src = src->ops->next_interleave(src);
if (NULL == src) if (!src)
src = apcm->src; src = apcm->src;
} }
...@@ -334,7 +334,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -334,7 +334,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
struct srcimp *srcimp; struct srcimp *srcimp;
int i; int i;
if (NULL != apcm->srcimps) { if (apcm->srcimps) {
for (i = 0; i < apcm->n_srcimp; i++) { for (i = 0; i < apcm->n_srcimp; i++) {
srcimp = apcm->srcimps[i]; srcimp = apcm->srcimps[i];
srcimp->ops->unmap(srcimp); srcimp->ops->unmap(srcimp);
...@@ -345,7 +345,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -345,7 +345,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
apcm->srcimps = NULL; apcm->srcimps = NULL;
} }
if (NULL != apcm->srccs) { if (apcm->srccs) {
for (i = 0; i < apcm->n_srcc; i++) { for (i = 0; i < apcm->n_srcc; i++) {
src_mgr->put_src(src_mgr, apcm->srccs[i]); src_mgr->put_src(src_mgr, apcm->srccs[i]);
apcm->srccs[i] = NULL; apcm->srccs[i] = NULL;
...@@ -354,7 +354,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -354,7 +354,7 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
apcm->srccs = NULL; apcm->srccs = NULL;
} }
if (NULL != apcm->amixers) { if (apcm->amixers) {
for (i = 0; i < apcm->n_amixer; i++) { for (i = 0; i < apcm->n_amixer; i++) {
amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]); amixer_mgr->put_amixer(amixer_mgr, apcm->amixers[i]);
apcm->amixers[i] = NULL; apcm->amixers[i] = NULL;
...@@ -363,17 +363,17 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -363,17 +363,17 @@ atc_pcm_release_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
apcm->amixers = NULL; apcm->amixers = NULL;
} }
if (NULL != apcm->mono) { if (apcm->mono) {
sum_mgr->put_sum(sum_mgr, apcm->mono); sum_mgr->put_sum(sum_mgr, apcm->mono);
apcm->mono = NULL; apcm->mono = NULL;
} }
if (NULL != apcm->src) { if (apcm->src) {
src_mgr->put_src(src_mgr, apcm->src); src_mgr->put_src(src_mgr, apcm->src);
apcm->src = NULL; apcm->src = NULL;
} }
if (NULL != apcm->vm_block) { if (apcm->vm_block) {
/* Undo device virtual mem map */ /* Undo device virtual mem map */
ct_unmap_audio_buffer(atc, apcm); ct_unmap_audio_buffer(atc, apcm);
apcm->vm_block = NULL; apcm->vm_block = NULL;
...@@ -419,7 +419,7 @@ static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -419,7 +419,7 @@ static int atc_pcm_stop(struct ct_atc *atc, struct ct_atc_pcm *apcm)
src->ops->set_state(src, SRC_STATE_OFF); src->ops->set_state(src, SRC_STATE_OFF);
src->ops->commit_write(src); src->ops->commit_write(src);
if (NULL != apcm->srccs) { if (apcm->srccs) {
for (i = 0; i < apcm->n_srcc; i++) { for (i = 0; i < apcm->n_srcc; i++) {
src = apcm->srccs[i]; src = apcm->srccs[i];
src->ops->set_bm(src, 0); src->ops->set_bm(src, 0);
...@@ -544,18 +544,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -544,18 +544,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
if (n_srcc) { if (n_srcc) {
apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL); apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL);
if (NULL == apcm->srccs) if (!apcm->srccs)
return -ENOMEM; return -ENOMEM;
} }
if (n_amixer) { if (n_amixer) {
apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
if (NULL == apcm->amixers) { if (!apcm->amixers) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
} }
apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL); apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL);
if (NULL == apcm->srcimps) { if (!apcm->srcimps) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
...@@ -818,7 +818,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc, ...@@ -818,7 +818,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
/* Get AMIXER resource */ /* Get AMIXER resource */
n_amixer = (n_amixer < 2) ? 2 : n_amixer; n_amixer = (n_amixer < 2) ? 2 : n_amixer;
apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
if (NULL == apcm->amixers) { if (!apcm->amixers) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
...@@ -919,7 +919,7 @@ spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) ...@@ -919,7 +919,7 @@ spdif_passthru_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
amixer = apcm->amixers[i]; amixer = apcm->amixers[i];
amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL); amixer->ops->setup(amixer, &src->rsc, INIT_VOL, NULL);
src = src->ops->next_interleave(src); src = src->ops->next_interleave(src);
if (NULL == src) if (!src)
src = apcm->src; src = apcm->src;
} }
/* Connect to SPDIFOO */ /* Connect to SPDIFOO */
...@@ -1121,7 +1121,7 @@ static int atc_release_resources(struct ct_atc *atc) ...@@ -1121,7 +1121,7 @@ static int atc_release_resources(struct ct_atc *atc)
struct ct_mixer *mixer = NULL; struct ct_mixer *mixer = NULL;
/* disconnect internal mixer objects */ /* disconnect internal mixer objects */
if (NULL != atc->mixer) { if (atc->mixer) {
mixer = atc->mixer; mixer = atc->mixer;
mixer->set_input_left(mixer, MIX_LINE_IN, NULL); mixer->set_input_left(mixer, MIX_LINE_IN, NULL);
mixer->set_input_right(mixer, MIX_LINE_IN, NULL); mixer->set_input_right(mixer, MIX_LINE_IN, NULL);
...@@ -1131,7 +1131,7 @@ static int atc_release_resources(struct ct_atc *atc) ...@@ -1131,7 +1131,7 @@ static int atc_release_resources(struct ct_atc *atc)
mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL); mixer->set_input_right(mixer, MIX_SPDIF_IN, NULL);
} }
if (NULL != atc->daios) { if (atc->daios) {
daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO];
for (i = 0; i < atc->n_daio; i++) { for (i = 0; i < atc->n_daio; i++) {
daio = atc->daios[i]; daio = atc->daios[i];
...@@ -1149,7 +1149,7 @@ static int atc_release_resources(struct ct_atc *atc) ...@@ -1149,7 +1149,7 @@ static int atc_release_resources(struct ct_atc *atc)
atc->daios = NULL; atc->daios = NULL;
} }
if (NULL != atc->pcm) { if (atc->pcm) {
sum_mgr = atc->rsc_mgrs[SUM]; sum_mgr = atc->rsc_mgrs[SUM];
for (i = 0; i < atc->n_pcm; i++) for (i = 0; i < atc->n_pcm; i++)
sum_mgr->put_sum(sum_mgr, atc->pcm[i]); sum_mgr->put_sum(sum_mgr, atc->pcm[i]);
...@@ -1158,7 +1158,7 @@ static int atc_release_resources(struct ct_atc *atc) ...@@ -1158,7 +1158,7 @@ static int atc_release_resources(struct ct_atc *atc)
atc->pcm = NULL; atc->pcm = NULL;
} }
if (NULL != atc->srcs) { if (atc->srcs) {
src_mgr = atc->rsc_mgrs[SRC]; src_mgr = atc->rsc_mgrs[SRC];
for (i = 0; i < atc->n_src; i++) for (i = 0; i < atc->n_src; i++)
src_mgr->put_src(src_mgr, atc->srcs[i]); src_mgr->put_src(src_mgr, atc->srcs[i]);
...@@ -1167,7 +1167,7 @@ static int atc_release_resources(struct ct_atc *atc) ...@@ -1167,7 +1167,7 @@ static int atc_release_resources(struct ct_atc *atc)
atc->srcs = NULL; atc->srcs = NULL;
} }
if (NULL != atc->srcimps) { if (atc->srcimps) {
srcimp_mgr = atc->rsc_mgrs[SRCIMP]; srcimp_mgr = atc->rsc_mgrs[SRCIMP];
for (i = 0; i < atc->n_srcimp; i++) { for (i = 0; i < atc->n_srcimp; i++) {
srcimp = atc->srcimps[i]; srcimp = atc->srcimps[i];
...@@ -1185,7 +1185,7 @@ static int ct_atc_destroy(struct ct_atc *atc) ...@@ -1185,7 +1185,7 @@ static int ct_atc_destroy(struct ct_atc *atc)
{ {
int i = 0; int i = 0;
if (NULL == atc) if (!atc)
return 0; return 0;
if (atc->timer) { if (atc->timer) {
...@@ -1196,21 +1196,20 @@ static int ct_atc_destroy(struct ct_atc *atc) ...@@ -1196,21 +1196,20 @@ static int ct_atc_destroy(struct ct_atc *atc)
atc_release_resources(atc); atc_release_resources(atc);
/* Destroy internal mixer objects */ /* Destroy internal mixer objects */
if (NULL != atc->mixer) if (atc->mixer)
ct_mixer_destroy(atc->mixer); ct_mixer_destroy(atc->mixer);
for (i = 0; i < NUM_RSCTYP; i++) { for (i = 0; i < NUM_RSCTYP; i++) {
if ((NULL != rsc_mgr_funcs[i].destroy) && if (rsc_mgr_funcs[i].destroy && atc->rsc_mgrs[i])
(NULL != atc->rsc_mgrs[i]))
rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]); rsc_mgr_funcs[i].destroy(atc->rsc_mgrs[i]);
} }
if (NULL != atc->hw) if (atc->hw)
destroy_hw_obj((struct hw *)atc->hw); destroy_hw_obj((struct hw *)atc->hw);
/* Destroy device virtual memory manager object */ /* Destroy device virtual memory manager object */
if (NULL != atc->vm) { if (atc->vm) {
ct_vm_destroy(atc->vm); ct_vm_destroy(atc->vm);
atc->vm = NULL; atc->vm = NULL;
} }
...@@ -1275,7 +1274,7 @@ int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc) ...@@ -1275,7 +1274,7 @@ int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc)
alsa_dev_funcs[MIXER].public_name = atc->chip_name; alsa_dev_funcs[MIXER].public_name = atc->chip_name;
for (i = 0; i < NUM_CTALSADEVS; i++) { for (i = 0; i < NUM_CTALSADEVS; i++) {
if (NULL == alsa_dev_funcs[i].create) if (!alsa_dev_funcs[i].create)
continue; continue;
err = alsa_dev_funcs[i].create(atc, i, err = alsa_dev_funcs[i].create(atc, i,
...@@ -1312,7 +1311,7 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc) ...@@ -1312,7 +1311,7 @@ static int __devinit atc_create_hw_devs(struct ct_atc *atc)
return err; return err;
for (i = 0; i < NUM_RSCTYP; i++) { for (i = 0; i < NUM_RSCTYP; i++) {
if (NULL == rsc_mgr_funcs[i].create) if (!rsc_mgr_funcs[i].create)
continue; continue;
err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]); err = rsc_mgr_funcs[i].create(atc->hw, &atc->rsc_mgrs[i]);
...@@ -1339,19 +1338,19 @@ static int atc_get_resources(struct ct_atc *atc) ...@@ -1339,19 +1338,19 @@ static int atc_get_resources(struct ct_atc *atc)
int err, i; int err, i;
atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL); atc->daios = kzalloc(sizeof(void *)*(DAIONUM), GFP_KERNEL);
if (NULL == atc->daios) if (!atc->daios)
return -ENOMEM; return -ENOMEM;
atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); atc->srcs = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL);
if (NULL == atc->srcs) if (!atc->srcs)
return -ENOMEM; return -ENOMEM;
atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL); atc->srcimps = kzalloc(sizeof(void *)*(2*2), GFP_KERNEL);
if (NULL == atc->srcimps) if (!atc->srcimps)
return -ENOMEM; return -ENOMEM;
atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL); atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL);
if (NULL == atc->pcm) if (!atc->pcm)
return -ENOMEM; return -ENOMEM;
daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO]; daio_mgr = (struct daio_mgr *)atc->rsc_mgrs[DAIO];
...@@ -1648,7 +1647,7 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, ...@@ -1648,7 +1647,7 @@ int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
*ratc = NULL; *ratc = NULL;
atc = kzalloc(sizeof(*atc), GFP_KERNEL); atc = kzalloc(sizeof(*atc), GFP_KERNEL);
if (NULL == atc) if (!atc)
return -ENOMEM; return -ENOMEM;
/* Set operations */ /* Set operations */
......
...@@ -173,7 +173,7 @@ static int dao_set_left_input(struct dao *dao, struct rsc *input) ...@@ -173,7 +173,7 @@ static int dao_set_left_input(struct dao *dao, struct rsc *input)
int i; int i;
entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL); entry = kzalloc((sizeof(*entry) * daio->rscl.msr), GFP_KERNEL);
if (NULL == entry) if (!entry)
return -ENOMEM; return -ENOMEM;
/* Program master and conjugate resources */ /* Program master and conjugate resources */
...@@ -201,7 +201,7 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input) ...@@ -201,7 +201,7 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input)
int i; int i;
entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL); entry = kzalloc((sizeof(*entry) * daio->rscr.msr), GFP_KERNEL);
if (NULL == entry) if (!entry)
return -ENOMEM; return -ENOMEM;
/* Program master and conjugate resources */ /* Program master and conjugate resources */
...@@ -228,7 +228,7 @@ static int dao_clear_left_input(struct dao *dao) ...@@ -228,7 +228,7 @@ static int dao_clear_left_input(struct dao *dao)
struct daio *daio = &dao->daio; struct daio *daio = &dao->daio;
int i; int i;
if (NULL == dao->imappers[0]) if (!dao->imappers[0])
return 0; return 0;
entry = dao->imappers[0]; entry = dao->imappers[0];
...@@ -252,7 +252,7 @@ static int dao_clear_right_input(struct dao *dao) ...@@ -252,7 +252,7 @@ static int dao_clear_right_input(struct dao *dao)
struct daio *daio = &dao->daio; struct daio *daio = &dao->daio;
int i; int i;
if (NULL == dao->imappers[daio->rscl.msr]) if (!dao->imappers[daio->rscl.msr])
return 0; return 0;
entry = dao->imappers[daio->rscl.msr]; entry = dao->imappers[daio->rscl.msr];
...@@ -408,7 +408,7 @@ static int dao_rsc_init(struct dao *dao, ...@@ -408,7 +408,7 @@ static int dao_rsc_init(struct dao *dao,
return err; return err;
dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL);
if (NULL == dao->imappers) { if (!dao->imappers) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
...@@ -442,11 +442,11 @@ error1: ...@@ -442,11 +442,11 @@ error1:
static int dao_rsc_uninit(struct dao *dao) static int dao_rsc_uninit(struct dao *dao)
{ {
if (NULL != dao->imappers) { if (dao->imappers) {
if (NULL != dao->imappers[0]) if (dao->imappers[0])
dao_clear_left_input(dao); dao_clear_left_input(dao);
if (NULL != dao->imappers[dao->daio.rscl.msr]) if (dao->imappers[dao->daio.rscl.msr])
dao_clear_right_input(dao); dao_clear_right_input(dao);
kfree(dao->imappers); kfree(dao->imappers);
...@@ -555,7 +555,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, ...@@ -555,7 +555,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
/* Allocate mem for daio resource */ /* Allocate mem for daio resource */
if (desc->type <= DAIO_OUT_MAX) { if (desc->type <= DAIO_OUT_MAX) {
dao = kzalloc(sizeof(*dao), GFP_KERNEL); dao = kzalloc(sizeof(*dao), GFP_KERNEL);
if (NULL == dao) { if (!dao) {
err = -ENOMEM; err = -ENOMEM;
goto error; goto error;
} }
...@@ -566,7 +566,7 @@ static int get_daio_rsc(struct daio_mgr *mgr, ...@@ -566,7 +566,7 @@ static int get_daio_rsc(struct daio_mgr *mgr,
*rdaio = &dao->daio; *rdaio = &dao->daio;
} else { } else {
dai = kzalloc(sizeof(*dai), GFP_KERNEL); dai = kzalloc(sizeof(*dai), GFP_KERNEL);
if (NULL == dai) { if (!dai) {
err = -ENOMEM; err = -ENOMEM;
goto error; goto error;
} }
...@@ -583,9 +583,9 @@ static int get_daio_rsc(struct daio_mgr *mgr, ...@@ -583,9 +583,9 @@ static int get_daio_rsc(struct daio_mgr *mgr,
return 0; return 0;
error: error:
if (NULL != dao) if (dao)
kfree(dao); kfree(dao);
else if (NULL != dai) else if (dai)
kfree(dai); kfree(dai);
spin_lock_irqsave(&mgr->mgr_lock, flags); spin_lock_irqsave(&mgr->mgr_lock, flags);
...@@ -663,7 +663,7 @@ static int daio_imap_add(struct daio_mgr *mgr, struct imapper *entry) ...@@ -663,7 +663,7 @@ static int daio_imap_add(struct daio_mgr *mgr, struct imapper *entry)
int err; int err;
spin_lock_irqsave(&mgr->imap_lock, flags); spin_lock_irqsave(&mgr->imap_lock, flags);
if ((0 == entry->addr) && (mgr->init_imap_added)) { if (!entry->addr && mgr->init_imap_added) {
input_mapper_delete(&mgr->imappers, mgr->init_imap, input_mapper_delete(&mgr->imappers, mgr->init_imap,
daio_map_op, mgr); daio_map_op, mgr);
mgr->init_imap_added = 0; mgr->init_imap_added = 0;
...@@ -707,7 +707,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr) ...@@ -707,7 +707,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr)
*rdaio_mgr = NULL; *rdaio_mgr = NULL;
daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL); daio_mgr = kzalloc(sizeof(*daio_mgr), GFP_KERNEL);
if (NULL == daio_mgr) if (!daio_mgr)
return -ENOMEM; return -ENOMEM;
err = rsc_mgr_init(&daio_mgr->mgr, DAIO, DAIO_RESOURCE_NUM, hw); err = rsc_mgr_init(&daio_mgr->mgr, DAIO, DAIO_RESOURCE_NUM, hw);
...@@ -718,7 +718,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr) ...@@ -718,7 +718,7 @@ int daio_mgr_create(void *hw, struct daio_mgr **rdaio_mgr)
spin_lock_init(&daio_mgr->imap_lock); spin_lock_init(&daio_mgr->imap_lock);
INIT_LIST_HEAD(&daio_mgr->imappers); INIT_LIST_HEAD(&daio_mgr->imappers);
entry = kzalloc(sizeof(*entry), GFP_KERNEL); entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (NULL == entry) { if (!entry) {
err = -ENOMEM; err = -ENOMEM;
goto error2; goto error2;
} }
......
...@@ -168,7 +168,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) ...@@ -168,7 +168,7 @@ static int src_get_rsc_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -494,7 +494,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) ...@@ -494,7 +494,7 @@ static int src_mgr_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -515,7 +515,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) ...@@ -515,7 +515,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) ...@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -723,7 +723,7 @@ static int amixer_mgr_get_ctrl_blk(void **rblk) ...@@ -723,7 +723,7 @@ static int amixer_mgr_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
/*blk = kzalloc(sizeof(*blk), GFP_KERNEL); /*blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk;*/ *rblk = blk;*/
...@@ -909,7 +909,7 @@ static int dai_get_ctrl_blk(void **rblk) ...@@ -909,7 +909,7 @@ static int dai_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -958,7 +958,7 @@ static int dao_get_ctrl_blk(void **rblk) ...@@ -958,7 +958,7 @@ static int dao_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -1152,7 +1152,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) ...@@ -1152,7 +1152,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
blk->i2sctl = hw_read_20kx(hw, I2SCTL); blk->i2sctl = hw_read_20kx(hw, I2SCTL);
...@@ -1808,7 +1808,7 @@ static int uaa_to_xfi(struct pci_dev *pci) ...@@ -1808,7 +1808,7 @@ static int uaa_to_xfi(struct pci_dev *pci)
/* By default, Hendrix card UAA Bar0 should be using memory... */ /* By default, Hendrix card UAA Bar0 should be using memory... */
io_base = pci_resource_start(pci, 0); io_base = pci_resource_start(pci, 0);
mem_base = ioremap(io_base, pci_resource_len(pci, 0)); mem_base = ioremap(io_base, pci_resource_len(pci, 0));
if (NULL == mem_base) if (!mem_base)
return -ENOENT; return -ENOENT;
/* Read current mode from Mode Change Register */ /* Read current mode from Mode Change Register */
...@@ -1977,7 +1977,7 @@ static int hw_card_shutdown(struct hw *hw) ...@@ -1977,7 +1977,7 @@ static int hw_card_shutdown(struct hw *hw)
hw->irq = -1; hw->irq = -1;
if (NULL != ((void *)hw->mem_base)) if (hw->mem_base)
iounmap((void *)hw->mem_base); iounmap((void *)hw->mem_base);
hw->mem_base = (unsigned long)NULL; hw->mem_base = (unsigned long)NULL;
...@@ -2274,7 +2274,7 @@ int __devinit create_20k1_hw_obj(struct hw **rhw) ...@@ -2274,7 +2274,7 @@ int __devinit create_20k1_hw_obj(struct hw **rhw)
*rhw = NULL; *rhw = NULL;
hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL); hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL);
if (NULL == hw20k1) if (!hw20k1)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&hw20k1->reg_20k1_lock); spin_lock_init(&hw20k1->reg_20k1_lock);
......
...@@ -166,7 +166,7 @@ static int src_get_rsc_ctrl_blk(void **rblk) ...@@ -166,7 +166,7 @@ static int src_get_rsc_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -492,7 +492,7 @@ static int src_mgr_get_ctrl_blk(void **rblk) ...@@ -492,7 +492,7 @@ static int src_mgr_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -513,7 +513,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk) ...@@ -513,7 +513,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk) ...@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -891,7 +891,7 @@ static int dai_get_ctrl_blk(void **rblk) ...@@ -891,7 +891,7 @@ static int dai_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -941,7 +941,7 @@ static int dao_get_ctrl_blk(void **rblk) ...@@ -941,7 +941,7 @@ static int dao_get_ctrl_blk(void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
*rblk = blk; *rblk = blk;
...@@ -1092,7 +1092,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) ...@@ -1092,7 +1092,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk)
*rblk = NULL; *rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL); blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (NULL == blk) if (!blk)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -1112,6 +1112,26 @@ static int daio_mgr_put_ctrl_blk(void *blk) ...@@ -1112,6 +1112,26 @@ static int daio_mgr_put_ctrl_blk(void *blk)
return 0; return 0;
} }
/* Timer interrupt */
static int set_timer_irq(struct hw *hw, int enable)
{
hw_write_20kx(hw, GIE, enable ? IT_INT : 0);
return 0;
}
static int set_timer_tick(struct hw *hw, unsigned int ticks)
{
if (ticks)
ticks |= TIMR_IE | TIMR_IP;
hw_write_20kx(hw, TIMR, ticks);
return 0;
}
static unsigned int get_wc(struct hw *hw)
{
return hw_read_20kx(hw, WC);
}
/* Card hardware initialization block */ /* Card hardware initialization block */
struct dac_conf { struct dac_conf {
unsigned int msr; /* master sample rate in rsrs */ unsigned int msr; /* master sample rate in rsrs */
...@@ -1841,6 +1861,22 @@ static int hw_have_digit_io_switch(struct hw *hw) ...@@ -1841,6 +1861,22 @@ static int hw_have_digit_io_switch(struct hw *hw)
return 0; return 0;
} }
static irqreturn_t ct_20k2_interrupt(int irq, void *dev_id)
{
struct hw *hw = dev_id;
unsigned int status;
status = hw_read_20kx(hw, GIP);
if (!status)
return IRQ_NONE;
if (hw->irq_callback)
hw->irq_callback(hw->irq_callback_data, status);
hw_write_20kx(hw, GIP, status);
return IRQ_HANDLED;
}
static int hw_card_start(struct hw *hw) static int hw_card_start(struct hw *hw)
{ {
int err = 0; int err = 0;
...@@ -1868,7 +1904,7 @@ static int hw_card_start(struct hw *hw) ...@@ -1868,7 +1904,7 @@ static int hw_card_start(struct hw *hw)
hw->io_base = pci_resource_start(hw->pci, 2); hw->io_base = pci_resource_start(hw->pci, 2);
hw->mem_base = (unsigned long)ioremap(hw->io_base, hw->mem_base = (unsigned long)ioremap(hw->io_base,
pci_resource_len(hw->pci, 2)); pci_resource_len(hw->pci, 2));
if (NULL == (void *)hw->mem_base) { if (!hw->mem_base) {
err = -ENOENT; err = -ENOENT;
goto error2; goto error2;
} }
...@@ -1879,12 +1915,15 @@ static int hw_card_start(struct hw *hw) ...@@ -1879,12 +1915,15 @@ static int hw_card_start(struct hw *hw)
set_field(&gctl, GCTL_UAA, 0); set_field(&gctl, GCTL_UAA, 0);
hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl);
/*if ((err = request_irq(pci->irq, ct_atc_interrupt, IRQF_SHARED, if (hw->irq < 0) {
atc->chip_details->nm_card, hw))) { err = request_irq(pci->irq, ct_20k2_interrupt, IRQF_SHARED,
goto error3; "ctxfi", hw);
if (err < 0) {
printk(KERN_ERR "XFi: Cannot get irq %d\n", pci->irq);
goto error2;
}
hw->irq = pci->irq;
} }
hw->irq = pci->irq;
*/
pci_set_master(pci); pci_set_master(pci);
...@@ -1923,7 +1962,7 @@ static int hw_card_shutdown(struct hw *hw) ...@@ -1923,7 +1962,7 @@ static int hw_card_shutdown(struct hw *hw)
hw->irq = -1; hw->irq = -1;
if (NULL != ((void *)hw->mem_base)) if (hw->mem_base)
iounmap((void *)hw->mem_base); iounmap((void *)hw->mem_base);
hw->mem_base = (unsigned long)NULL; hw->mem_base = (unsigned long)NULL;
...@@ -1972,7 +2011,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info) ...@@ -1972,7 +2011,7 @@ static int hw_card_init(struct hw *hw, struct card_conf *info)
hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl); hw_write_20kx(hw, GLOBAL_CNTL_GCTL, gctl);
/* Reset all global pending interrupts */ /* Reset all global pending interrupts */
hw_write_20kx(hw, INTERRUPT_GIE, 0); hw_write_20kx(hw, GIE, 0);
/* Reset all SRC pending interrupts */ /* Reset all SRC pending interrupts */
hw_write_20kx(hw, SRC_IP, 0); hw_write_20kx(hw, SRC_IP, 0);
...@@ -2149,6 +2188,10 @@ static struct hw ct20k2_preset __devinitdata = { ...@@ -2149,6 +2188,10 @@ static struct hw ct20k2_preset __devinitdata = {
.daio_mgr_set_imapnxt = daio_mgr_set_imapnxt, .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt,
.daio_mgr_set_imapaddr = daio_mgr_set_imapaddr, .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr,
.daio_mgr_commit_write = daio_mgr_commit_write, .daio_mgr_commit_write = daio_mgr_commit_write,
.set_timer_irq = set_timer_irq,
.set_timer_tick = set_timer_tick,
.get_wc = get_wc,
}; };
int __devinit create_20k2_hw_obj(struct hw **rhw) int __devinit create_20k2_hw_obj(struct hw **rhw)
......
...@@ -654,7 +654,7 @@ ct_mixer_kcontrol_new(struct ct_mixer *mixer, struct snd_kcontrol_new *new) ...@@ -654,7 +654,7 @@ ct_mixer_kcontrol_new(struct ct_mixer *mixer, struct snd_kcontrol_new *new)
int err; int err;
kctl = snd_ctl_new1(new, mixer->atc); kctl = snd_ctl_new1(new, mixer->atc);
if (NULL == kctl) if (!kctl)
return -ENOMEM; return -ENOMEM;
if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface) if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface)
...@@ -837,17 +837,17 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer) ...@@ -837,17 +837,17 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer)
*rmixer = NULL; *rmixer = NULL;
/* Allocate mem for mixer obj */ /* Allocate mem for mixer obj */
mixer = kzalloc(sizeof(*mixer), GFP_KERNEL); mixer = kzalloc(sizeof(*mixer), GFP_KERNEL);
if (NULL == mixer) if (!mixer)
return -ENOMEM; return -ENOMEM;
mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM), mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM),
GFP_KERNEL); GFP_KERNEL);
if (NULL == mixer->amixers) { if (!mixer->amixers) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL); mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL);
if (NULL == mixer->sums) { if (!mixer->sums) {
err = -ENOMEM; err = -ENOMEM;
goto error2; goto error2;
} }
......
...@@ -97,7 +97,7 @@ static void ct_atc_pcm_interrupt(struct ct_atc_pcm *atc_pcm) ...@@ -97,7 +97,7 @@ static void ct_atc_pcm_interrupt(struct ct_atc_pcm *atc_pcm)
{ {
struct ct_atc_pcm *apcm = atc_pcm; struct ct_atc_pcm *apcm = atc_pcm;
if (NULL == apcm->substream) if (!apcm->substream)
return; return;
snd_pcm_period_elapsed(apcm->substream); snd_pcm_period_elapsed(apcm->substream);
...@@ -123,7 +123,7 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream) ...@@ -123,7 +123,7 @@ static int ct_pcm_playback_open(struct snd_pcm_substream *substream)
int err; int err;
apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
if (NULL == apcm) if (!apcm)
return -ENOMEM; return -ENOMEM;
apcm->substream = substream; apcm->substream = substream;
...@@ -271,7 +271,7 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream) ...@@ -271,7 +271,7 @@ static int ct_pcm_capture_open(struct snd_pcm_substream *substream)
int err; int err;
apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
if (NULL == apcm) if (!apcm)
return -ENOMEM; return -ENOMEM;
apcm->started = 0; apcm->started = 0;
......
...@@ -144,7 +144,7 @@ int rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, void *hw) ...@@ -144,7 +144,7 @@ int rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, void *hw)
rsc->msr = msr; rsc->msr = msr;
rsc->hw = hw; rsc->hw = hw;
rsc->ops = &rsc_generic_ops; rsc->ops = &rsc_generic_ops;
if (NULL == hw) { if (!hw) {
rsc->ctrl_blk = NULL; rsc->ctrl_blk = NULL;
return 0; return 0;
} }
...@@ -216,7 +216,7 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type, ...@@ -216,7 +216,7 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,
mgr->type = NUM_RSCTYP; mgr->type = NUM_RSCTYP;
mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL); mgr->rscs = kzalloc(((amount + 8 - 1) / 8), GFP_KERNEL);
if (NULL == mgr->rscs) if (!mgr->rscs)
return -ENOMEM; return -ENOMEM;
switch (type) { switch (type) {
......
...@@ -441,7 +441,7 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc) ...@@ -441,7 +441,7 @@ get_src_rsc(struct src_mgr *mgr, const struct src_desc *desc, struct src **rsrc)
else else
src = kzalloc(sizeof(*src), GFP_KERNEL); src = kzalloc(sizeof(*src), GFP_KERNEL);
if (NULL == src) { if (!src) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
...@@ -550,7 +550,7 @@ int src_mgr_create(void *hw, struct src_mgr **rsrc_mgr) ...@@ -550,7 +550,7 @@ int src_mgr_create(void *hw, struct src_mgr **rsrc_mgr)
*rsrc_mgr = NULL; *rsrc_mgr = NULL;
src_mgr = kzalloc(sizeof(*src_mgr), GFP_KERNEL); src_mgr = kzalloc(sizeof(*src_mgr), GFP_KERNEL);
if (NULL == src_mgr) if (!src_mgr)
return -ENOMEM; return -ENOMEM;
err = rsc_mgr_init(&src_mgr->mgr, SRC, SRC_RESOURCE_NUM, hw); err = rsc_mgr_init(&src_mgr->mgr, SRC, SRC_RESOURCE_NUM, hw);
...@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp, ...@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp,
/* Reserve memory for imapper nodes */ /* Reserve memory for imapper nodes */
srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr, srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr,
GFP_KERNEL); GFP_KERNEL);
if (NULL == srcimp->imappers) { if (!srcimp->imappers) {
err = -ENOMEM; err = -ENOMEM;
goto error1; goto error1;
} }
...@@ -833,7 +833,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr) ...@@ -833,7 +833,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr)
*rsrcimp_mgr = NULL; *rsrcimp_mgr = NULL;
srcimp_mgr = kzalloc(sizeof(*srcimp_mgr), GFP_KERNEL); srcimp_mgr = kzalloc(sizeof(*srcimp_mgr), GFP_KERNEL);
if (NULL == srcimp_mgr) if (!srcimp_mgr)
return -ENOMEM; return -ENOMEM;
err = rsc_mgr_init(&srcimp_mgr->mgr, SRCIMP, SRCIMP_RESOURCE_NUM, hw); err = rsc_mgr_init(&srcimp_mgr->mgr, SRCIMP, SRCIMP_RESOURCE_NUM, hw);
...@@ -844,7 +844,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr) ...@@ -844,7 +844,7 @@ int srcimp_mgr_create(void *hw, struct srcimp_mgr **rsrcimp_mgr)
spin_lock_init(&srcimp_mgr->imap_lock); spin_lock_init(&srcimp_mgr->imap_lock);
INIT_LIST_HEAD(&srcimp_mgr->imappers); INIT_LIST_HEAD(&srcimp_mgr->imappers);
entry = kzalloc(sizeof(*entry), GFP_KERNEL); entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (NULL == entry) { if (!entry) {
err = -ENOMEM; err = -ENOMEM;
goto error2; goto error2;
} }
......
...@@ -60,7 +60,7 @@ get_vm_block(struct ct_vm *vm, unsigned int size) ...@@ -60,7 +60,7 @@ get_vm_block(struct ct_vm *vm, unsigned int size)
} }
block = kzalloc(sizeof(*block), GFP_KERNEL); block = kzalloc(sizeof(*block), GFP_KERNEL);
if (NULL == block) if (!block)
goto out; goto out;
block->addr = entry->addr; block->addr = entry->addr;
...@@ -181,7 +181,7 @@ int ct_vm_create(struct ct_vm **rvm) ...@@ -181,7 +181,7 @@ int ct_vm_create(struct ct_vm **rvm)
*rvm = NULL; *rvm = NULL;
vm = kzalloc(sizeof(*vm), GFP_KERNEL); vm = kzalloc(sizeof(*vm), GFP_KERNEL);
if (NULL == vm) if (!vm)
return -ENOMEM; return -ENOMEM;
mutex_init(&vm->lock); mutex_init(&vm->lock);
...@@ -189,7 +189,7 @@ int ct_vm_create(struct ct_vm **rvm) ...@@ -189,7 +189,7 @@ int ct_vm_create(struct ct_vm **rvm)
/* Allocate page table pages */ /* Allocate page table pages */
for (i = 0; i < CT_PTP_NUM; i++) { for (i = 0; i < CT_PTP_NUM; i++) {
vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL); vm->ptp[i] = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (NULL == vm->ptp[i]) if (!vm->ptp[i])
break; break;
} }
if (!i) { if (!i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment