diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2013-02-09 21:02:18 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2013-02-09 21:02:18 +0000 |
commit | 536f52b0492346eb392a71db35ec7445216f6d62 (patch) | |
tree | 6faecf5330414973cfa40e7ed10f1537ca49514c /sys/dev | |
parent | ad03c03bcca73d79a2dda4f17e6a4cde6117094f (diff) |
Replace a bunch of if () else if () else if () else if () ... with that
modern brand new construct known as `switch'.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/azalia.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/sys/dev/pci/azalia.c b/sys/dev/pci/azalia.c index c7f11db97da..57282ace881 100644 --- a/sys/dev/pci/azalia.c +++ b/sys/dev/pci/azalia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: azalia.c,v 1.202 2012/10/19 15:20:42 deraadt Exp $ */ +/* $OpenBSD: azalia.c,v 1.203 2013/02/09 21:02:17 miod Exp $ */ /* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */ /*- @@ -4325,36 +4325,45 @@ azalia_params2fmt(const audio_params_t *param, uint16_t *fmt) break; } - if (param->sample_rate == 384000) { - printf("%s: invalid sample_rate: %u\n", __func__, + switch (param->sample_rate) { + default: + case 384000: + printf("%s: invalid sample_rate: %lu\n", __func__, param->sample_rate); return EINVAL; - } else if (param->sample_rate == 192000) { + case 192000: ret |= HDA_SD_FMT_BASE_48 | HDA_SD_FMT_MULT_X4 | HDA_SD_FMT_DIV_BY1; - } else if (param->sample_rate == 176400) { + break; + case 176400: ret |= HDA_SD_FMT_BASE_44 | HDA_SD_FMT_MULT_X4 | HDA_SD_FMT_DIV_BY1; - } else if (param->sample_rate == 96000) { + break; + case 96000: ret |= HDA_SD_FMT_BASE_48 | HDA_SD_FMT_MULT_X2 | HDA_SD_FMT_DIV_BY1; - } else if (param->sample_rate == 88200) { + break; + case 88200: ret |= HDA_SD_FMT_BASE_44 | HDA_SD_FMT_MULT_X2 | HDA_SD_FMT_DIV_BY1; - } else if (param->sample_rate == 48000) { + break; + case 48000: ret |= HDA_SD_FMT_BASE_48 | HDA_SD_FMT_MULT_X1 | HDA_SD_FMT_DIV_BY1; - } else if (param->sample_rate == 44100) { + break; + case 44100: ret |= HDA_SD_FMT_BASE_44 | HDA_SD_FMT_MULT_X1 | HDA_SD_FMT_DIV_BY1; - } else if (param->sample_rate == 32000) { + break; + case 32000: ret |= HDA_SD_FMT_BASE_48 | HDA_SD_FMT_MULT_X2 | HDA_SD_FMT_DIV_BY3; - } else if (param->sample_rate == 22050) { + break; + case 22050: ret |= HDA_SD_FMT_BASE_44 | HDA_SD_FMT_MULT_X1 | HDA_SD_FMT_DIV_BY2; - } else if (param->sample_rate == 16000) { + break; + case 16000: ret |= HDA_SD_FMT_BASE_48 | HDA_SD_FMT_MULT_X1 | HDA_SD_FMT_DIV_BY3; - } else if (param->sample_rate == 11025) { + break; + case 11025: ret |= HDA_SD_FMT_BASE_44 | HDA_SD_FMT_MULT_X1 | HDA_SD_FMT_DIV_BY4; - } else if (param->sample_rate == 8000) { + break; + case 8000: ret |= HDA_SD_FMT_BASE_48 | HDA_SD_FMT_MULT_X1 | HDA_SD_FMT_DIV_BY6; - } else { - printf("%s: invalid sample_rate: %u\n", __func__, - param->sample_rate); - return EINVAL; + break; } *fmt = ret; return 0; |