ALSA: asihpi: fix sign bug

bytes_per_sec is unsigned, so if snd_pcm_format_width() return error we
would not see it.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Kulikov Vasiliy 2010-07-15 22:48:19 +04:00 committed by Takashi Iwai
parent 1d8c1100fb
commit 315e8f7501

View file

@ -460,6 +460,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_card_asihpi *card = snd_pcm_substream_chip(substream); struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
int err; int err;
u16 format; u16 format;
int width;
unsigned int bytes_per_sec; unsigned int bytes_per_sec;
print_hwparams(params); print_hwparams(params);
@ -512,9 +513,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
dpcm->hpi_buffer_attached); dpcm->hpi_buffer_attached);
} }
bytes_per_sec = params_rate(params) * params_channels(params); bytes_per_sec = params_rate(params) * params_channels(params);
bytes_per_sec *= snd_pcm_format_width(params_format(params)); width = snd_pcm_format_width(params_format(params));
bytes_per_sec *= width;
bytes_per_sec /= 8; bytes_per_sec /= 8;
if (bytes_per_sec <= 0) if (width < 0 || bytes_per_sec == 0)
return -EINVAL; return -EINVAL;
dpcm->bytes_per_sec = bytes_per_sec; dpcm->bytes_per_sec = bytes_per_sec;