aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sound/pci/hda/hdaa.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/sound/pci/hda/hdaa.c')
-rw-r--r--sys/dev/sound/pci/hda/hdaa.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c
index dcd10cb36510..1e486b01b168 100644
--- a/sys/dev/sound/pci/hda/hdaa.c
+++ b/sys/dev/sound/pci/hda/hdaa.c
@@ -267,7 +267,8 @@ hdaa_channels_handler(struct hdaa_audio_as *as)
struct hdaa_chan *ch = &devinfo->chans[as->chans[0]];
struct hdaa_widget *w;
uint8_t *eld;
- int i, total, sub, assume, channels;
+ int total, sub, assume, channels;
+ size_t i;
uint16_t cpins, upins, tpins;
cpins = upins = 0;
@@ -347,7 +348,7 @@ hdaa_channels_handler(struct hdaa_audio_as *as)
printf("\n");
);
/* Look for maximal fitting matrix. */
- for (i = 0; i < sizeof(matrixes) / sizeof(struct matrix); i++) {
+ for (i = 0; i < nitems(matrixes); i++) {
if (as->pinset != 0 && matrixes[i].analog == 0)
continue;
if ((matrixes[i].m.mask & ~channels) == 0) {
@@ -1252,7 +1253,8 @@ hdaa_sysctl_config(SYSCTL_HANDLER_ARGS)
static void
hdaa_config_fetch(const char *str, uint32_t *on, uint32_t *off)
{
- int i = 0, j, k, len, inv;
+ size_t k;
+ int i = 0, j, len, inv;
for (;;) {
while (str[i] != '\0' &&
@@ -1292,7 +1294,8 @@ static int
hdaa_sysctl_quirks(SYSCTL_HANDLER_ARGS)
{
char buf[256];
- int error, n = 0, i;
+ int error, n = 0;
+ size_t i;
uint32_t quirks, quirks_off;
quirks = *(uint32_t *)oidp->oid_arg1;
@@ -2909,7 +2912,7 @@ hdaa_dump_gpo(struct hdaa_devinfo *devinfo)
data = hda_command(dev,
HDA_CMD_GET_GPO_DATA(0, devinfo->nid));
for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); i++) {
- device_printf(dev, " GPO%d: state=%d", i,
+ device_printf(dev, " GPO%d: state=%d\n", i,
(data >> i) & 1);
}
}
@@ -3030,8 +3033,7 @@ hdaa_audio_ctl_parse(struct hdaa_devinfo *devinfo)
if (max < 1)
return;
- ctls = (struct hdaa_audio_ctl *)malloc(
- sizeof(*ctls) * max, M_HDAA, M_ZERO | M_NOWAIT);
+ ctls = malloc(sizeof(*ctls) * max, M_HDAA, M_ZERO | M_NOWAIT);
if (ctls == NULL) {
/* Blekh! */
@@ -3183,8 +3185,7 @@ hdaa_audio_as_parse(struct hdaa_devinfo *devinfo)
if (max < 1)
return;
- as = (struct hdaa_audio_as *)malloc(
- sizeof(*as) * max, M_HDAA, M_ZERO | M_NOWAIT);
+ as = malloc(sizeof(*as) * max, M_HDAA, M_ZERO | M_NOWAIT);
if (as == NULL) {
/* Blekh! */
@@ -3217,7 +3218,7 @@ hdaa_audio_as_parse(struct hdaa_devinfo *devinfo)
continue;
}
KASSERT(cnt < max,
- ("%s: Associations owerflow (%d of %d)",
+ ("%s: Associations overflow (%d of %d)",
__func__, cnt, max));
type = w->wclass.pin.config &
HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
@@ -4074,8 +4075,7 @@ hdaa_audio_bind_as(struct hdaa_devinfo *devinfo)
cnt += as[j].num_chans;
}
if (devinfo->num_chans == 0) {
- devinfo->chans = (struct hdaa_chan *)malloc(
- sizeof(struct hdaa_chan) * cnt,
+ devinfo->chans = malloc(sizeof(struct hdaa_chan) * cnt,
M_HDAA, M_ZERO | M_NOWAIT);
if (devinfo->chans == NULL) {
device_printf(devinfo->dev,
@@ -5487,10 +5487,8 @@ hdaa_prepare_pcms(struct hdaa_devinfo *devinfo)
}
devinfo->num_devs =
max(ardev, apdev) + max(drdev, dpdev);
- devinfo->devs =
- (struct hdaa_pcm_devinfo *)malloc(
- devinfo->num_devs * sizeof(struct hdaa_pcm_devinfo),
- M_HDAA, M_ZERO | M_NOWAIT);
+ devinfo->devs = malloc(devinfo->num_devs *
+ sizeof(struct hdaa_pcm_devinfo), M_HDAA, M_ZERO | M_NOWAIT);
if (devinfo->devs == NULL) {
device_printf(devinfo->dev,
"Unable to allocate memory for devices\n");
@@ -5539,7 +5537,7 @@ hdaa_create_pcms(struct hdaa_devinfo *devinfo)
for (i = 0; i < devinfo->num_devs; i++) {
struct hdaa_pcm_devinfo *pdevinfo = &devinfo->devs[i];
- pdevinfo->dev = device_add_child(devinfo->dev, "pcm", -1);
+ pdevinfo->dev = device_add_child(devinfo->dev, "pcm", DEVICE_UNIT_ANY);
device_set_ivars(pdevinfo->dev, (void *)pdevinfo);
}
}
@@ -6202,7 +6200,9 @@ hdaa_configure(device_t dev)
HDA_BOOTHVERBOSE(
device_printf(dev, "Creating PCM devices...\n");
);
+ hdaa_unlock(devinfo);
hdaa_create_pcms(devinfo);
+ hdaa_lock(devinfo);
HDA_BOOTVERBOSE(
if (devinfo->quirks != 0) {
@@ -6470,7 +6470,7 @@ hdaa_sysctl_reconfig(SYSCTL_HANDLER_ARGS)
hdaa_unconfigure(dev);
hdaa_configure(dev);
hdaa_unlock(devinfo);
- bus_generic_attach(dev);
+ bus_attach_children(dev);
HDA_BOOTHVERBOSE(
device_printf(dev, "Reconfiguration done\n");
);
@@ -6622,9 +6622,8 @@ hdaa_attach(device_t dev)
);
if (devinfo->nodecnt > 0)
- devinfo->widget = (struct hdaa_widget *)malloc(
- sizeof(*(devinfo->widget)) * devinfo->nodecnt, M_HDAA,
- M_WAITOK | M_ZERO);
+ devinfo->widget = malloc(sizeof(*(devinfo->widget)) *
+ devinfo->nodecnt, M_HDAA, M_WAITOK | M_ZERO);
else
devinfo->widget = NULL;
@@ -6677,7 +6676,7 @@ hdaa_attach(device_t dev)
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
"init_clear", CTLFLAG_RW,
&devinfo->init_clear, 1,"Clear initial pin widget configuration");
- bus_generic_attach(dev);
+ bus_attach_children(dev);
return (0);
}
@@ -6687,7 +6686,7 @@ hdaa_detach(device_t dev)
struct hdaa_devinfo *devinfo = device_get_softc(dev);
int error;
- if ((error = device_delete_children(dev)) != 0)
+ if ((error = bus_generic_detach(dev)) != 0)
return (error);
hdaa_lock(devinfo);
@@ -7056,9 +7055,7 @@ hdaa_pcm_attach(device_t dev)
HDA_BOOTHVERBOSE(
device_printf(dev, "Registering PCM channels...\n");
);
- if (pcm_register(dev, pdevinfo, (pdevinfo->playas >= 0)?1:0,
- (pdevinfo->recas >= 0)?1:0) != 0)
- device_printf(dev, "Can't register PCM\n");
+ pcm_init(dev, pdevinfo);
pdevinfo->registered++;
@@ -7111,9 +7108,8 @@ hdaa_pcm_attach(device_t dev)
snprintf(status, SND_STATUSLEN, "on %s",
device_get_nameunit(device_get_parent(dev)));
- pcm_setstatus(dev, status);
- return (0);
+ return (pcm_register(dev, status));
}
static int