From 326f0480b7f8504c4f594c4f36ab7874e17780bc Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Tue, 28 Oct 2014 14:27:44 +0200 Subject: ALSA: pcxhr: convert timeval to ktime_t This patch is concerned with migrating the time variables in the pcxhr module found in the sound driver. The changes are concerend with the y2038 problem where timeval will overflow in the year 2038. ktime_t was used instead of timeval to get the wall time. The difference is displayed now in nanoseconds instead of microseconds. Signed-off-by: Aya Mahfouz Reviewed-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sound/pci/pcxhr/pcxhr.c') diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index b854fc5e01f5..7c33c973dbd5 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -711,8 +711,9 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr) int playback_mask = 0; #ifdef CONFIG_SND_DEBUG_VERBOSE - struct timeval my_tv1, my_tv2; - do_gettimeofday(&my_tv1); + ktime_t start_time, stop_time, diff_time; + + start_time = ktime_get(); #endif mutex_lock(&mgr->setup_mutex); @@ -823,9 +824,10 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr) mutex_unlock(&mgr->setup_mutex); #ifdef CONFIG_SND_DEBUG_VERBOSE - do_gettimeofday(&my_tv2); + stop_time = ktime_get(); + diff_time = ktime_sub(stop_time, start_time); dev_dbg(&mgr->pci->dev, "***TRIGGER START*** TIME = %ld (err = %x)\n", - (long)(my_tv2.tv_usec - my_tv1.tv_usec), err); + (long)(ktime_to_ns(diff_time)), err); #endif } -- cgit v1.2.3-59-g8ed1b From f48a6df28239f5bf35d80e43e580261d2298395a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 28 Oct 2014 17:22:45 +0100 Subject: ALSA: pcxhr: Kill the rest snd_print*() Use the standard dev_*() instead. Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'sound/pci/pcxhr/pcxhr.c') diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 7c33c973dbd5..a60293015267 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -501,10 +501,10 @@ int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, /* * start or stop playback/capture substream */ -static int pcxhr_set_stream_state(struct pcxhr_stream *stream) +static int pcxhr_set_stream_state(struct snd_pcxhr *chip, + struct pcxhr_stream *stream) { int err; - struct snd_pcxhr *chip; struct pcxhr_rmh rmh; int stream_mask, start; @@ -512,8 +512,8 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream) start = 1; else { if (stream->status != PCXHR_STREAM_STATUS_SCHEDULE_STOP) { - snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state " - "CANNOT be stopped\n"); + dev_err(chip->card->dev, + "pcxhr_set_stream_state CANNOT be stopped\n"); return -EINVAL; } start = 0; @@ -560,6 +560,7 @@ static int pcxhr_set_format(struct pcxhr_stream *stream) struct pcxhr_rmh rmh; unsigned int header; + chip = snd_pcm_substream_chip(stream->substream); switch (stream->format) { case SNDRV_PCM_FORMAT_U8: header = HEADER_FMT_BASE_LIN; @@ -582,11 +583,10 @@ static int pcxhr_set_format(struct pcxhr_stream *stream) header = HEADER_FMT_BASE_FLOAT | HEADER_FMT_INTEL; break; default: - snd_printk(KERN_ERR - "error pcxhr_set_format() : unknown format\n"); + dev_err(chip->card->dev, + "error pcxhr_set_format() : unknown format\n"); return -EINVAL; } - chip = snd_pcm_substream_chip(stream->substream); sample_rate = chip->mgr->sample_rate; if (sample_rate <= 32000 && sample_rate !=0) { @@ -643,11 +643,11 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream) is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE); stream_num = is_capture ? 0 : subs->number; - snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : " - "addr(%p) bytes(%zx) subs(%d)\n", - is_capture ? 'c' : 'p', - chip->chip_idx, (void *)(long)subs->runtime->dma_addr, - subs->runtime->dma_bytes, subs->number); + dev_dbg(chip->card->dev, + "pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n", + is_capture ? 'c' : 'p', + chip->chip_idx, (void *)(long)subs->runtime->dma_addr, + subs->runtime->dma_bytes, subs->number); pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, @@ -687,7 +687,7 @@ static int pcxhr_pipe_sample_count(struct pcxhr_stream *stream, *sample_count = ((snd_pcm_uframes_t)rmh.stat[0]) << 24; *sample_count += (snd_pcm_uframes_t)rmh.stat[1]; } - snd_printdd("PIPE_SAMPLE_COUNT = %lx\n", *sample_count); + dev_dbg(chip->card->dev, "PIPE_SAMPLE_COUNT = %lx\n", *sample_count); return err; } #endif @@ -779,12 +779,12 @@ static void pcxhr_start_linked_stream(struct pcxhr_mgr *mgr) for (j = 0; j < chip->nb_streams_capt; j++) { stream = &chip->capture_stream[j]; if (pcxhr_stream_scheduled_get_pipe(stream, &pipe)) - err = pcxhr_set_stream_state(stream); + err = pcxhr_set_stream_state(chip, stream); } for (j = 0; j < chip->nb_streams_play; j++) { stream = &chip->playback_stream[j]; if (pcxhr_stream_scheduled_get_pipe(stream, &pipe)) - err = pcxhr_set_stream_state(stream); + err = pcxhr_set_stream_state(chip, stream); } } @@ -839,12 +839,12 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) { struct pcxhr_stream *stream; struct snd_pcm_substream *s; + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); switch (cmd) { case SNDRV_PCM_TRIGGER_START: - snd_printdd("SNDRV_PCM_TRIGGER_START\n"); + dev_dbg(chip->card->dev, "SNDRV_PCM_TRIGGER_START\n"); if (snd_pcm_stream_linked(subs)) { - struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); snd_pcm_group_for_each_entry(s, subs) { if (snd_pcm_substream_chip(s) != chip) continue; @@ -856,7 +856,7 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) pcxhr_start_linked_stream(chip->mgr); } else { stream = subs->runtime->private_data; - snd_printdd("Only one Substream %c %d\n", + dev_dbg(chip->card->dev, "Only one Substream %c %d\n", stream->pipe->is_capture ? 'C' : 'P', stream->pipe->first_audio); if (pcxhr_set_format(stream)) @@ -865,17 +865,17 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) return -EINVAL; stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; - if (pcxhr_set_stream_state(stream)) + if (pcxhr_set_stream_state(chip, stream)) return -EINVAL; stream->status = PCXHR_STREAM_STATUS_RUNNING; } break; case SNDRV_PCM_TRIGGER_STOP: - snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); + dev_dbg(chip->card->dev, "SNDRV_PCM_TRIGGER_STOP\n"); snd_pcm_group_for_each_entry(s, subs) { stream = s->runtime->private_data; stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; - if (pcxhr_set_stream_state(stream)) + if (pcxhr_set_stream_state(chip, stream)) return -EINVAL; snd_pcm_trigger_done(s, subs); } -- cgit v1.2.3-59-g8ed1b From 6e1d7a51392f06899bd7b693f28ac60fa1e00032 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 10 Dec 2014 16:26:21 +0300 Subject: ALSA: pcxhr: NULL dereference on probe failure "card" is NULL if snd_card_new() fails. Signed-off-by: Dan Carpenter Signed-off-by: Takashi Iwai --- sound/pci/pcxhr/pcxhr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/pci/pcxhr/pcxhr.c') diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index a60293015267..c6092e48ceb6 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c @@ -1638,7 +1638,7 @@ static int pcxhr_probe(struct pci_dev *pci, 0, &card); if (err < 0) { - dev_err(card->dev, "cannot allocate the card %d\n", i); + dev_err(&pci->dev, "cannot allocate the card %d\n", i); pcxhr_free(mgr); return err; } -- cgit v1.2.3-59-g8ed1b