intel-hda: fix codec addressing.

The HDA bus supports up to 15 codecs, with addresses 0 ... 14.
We get that wrong in two places:

 * When handing out addresses we accept address 15 as valid.
 * The bitmasks for two registers (WAKEEN and STATESTS) don't
   have bit 14 set.

This patch fixes it.

[ v2: codestyle: add braces ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
Gerd Hoffmann 2010-11-09 17:28:38 +01:00 committed by malc
parent e2553eb44e
commit df0db2212d

View File

@ -56,8 +56,9 @@ static int hda_codec_dev_init(DeviceState *qdev, DeviceInfo *base)
if (dev->cad == -1) { if (dev->cad == -1) {
dev->cad = bus->next_cad; dev->cad = bus->next_cad;
} }
if (dev->cad > 15) if (dev->cad >= 15) {
return -1; return -1;
}
bus->next_cad = dev->cad + 1; bus->next_cad = dev->cad + 1;
return info->init(dev); return info->init(dev);
} }
@ -643,15 +644,15 @@ static const struct IntelHDAReg regtab[] = {
[ ICH6_REG_WAKEEN ] = { [ ICH6_REG_WAKEEN ] = {
.name = "WAKEEN", .name = "WAKEEN",
.size = 2, .size = 2,
.wmask = 0x3fff, .wmask = 0x7fff,
.offset = offsetof(IntelHDAState, wake_en), .offset = offsetof(IntelHDAState, wake_en),
.whandler = intel_hda_set_wake_en, .whandler = intel_hda_set_wake_en,
}, },
[ ICH6_REG_STATESTS ] = { [ ICH6_REG_STATESTS ] = {
.name = "STATESTS", .name = "STATESTS",
.size = 2, .size = 2,
.wmask = 0x3fff, .wmask = 0x7fff,
.wclear = 0x3fff, .wclear = 0x7fff,
.offset = offsetof(IntelHDAState, state_sts), .offset = offsetof(IntelHDAState, state_sts),
.whandler = intel_hda_set_state_sts, .whandler = intel_hda_set_state_sts,
}, },