]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - sound/pci/asihpi/asihpi.c
ALSA: asihpi: fix sign bug
[net-next-2.6.git] / sound / pci / asihpi / asihpi.c
index 91218f77217f60a9388ce693a6bb05c94eccacbc..c80b0b863c5493dfa54561b201a5259a660fd2ee 100644 (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);
        int err;
        u16 format;
+       int width;
        unsigned int bytes_per_sec;
 
        print_hwparams(params);
@@ -512,9 +513,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream,
                                dpcm->hpi_buffer_attached);
        }
        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;
-       if (bytes_per_sec <= 0)
+       if (width < 0 || bytes_per_sec == 0)
                return -EINVAL;
 
        dpcm->bytes_per_sec = bytes_per_sec;