From owner-svn-src-head@FreeBSD.ORG Wed Apr 23 19:32:51 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D83A0EB6; Wed, 23 Apr 2014 19:32:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B956B1D68; Wed, 23 Apr 2014 19:32:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3NJWp8v002733; Wed, 23 Apr 2014 19:32:51 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3NJWpNF002730; Wed, 23 Apr 2014 19:32:51 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201404231932.s3NJWpNF002730@svn.freebsd.org> From: Marius Strobl Date: Wed, 23 Apr 2014 19:32:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264832 - head/sys/dev/sound/pci/hda X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Apr 2014 19:32:52 -0000 Author: marius Date: Wed Apr 23 19:32:50 2014 New Revision: 264832 URL: http://svnweb.freebsd.org/changeset/base/264832 Log: - Sprinkle const and static as appropriate. - Convert the remainder of snd_hda(4) to take advantage of nitems(). - Use DEVMETHOD_END. - Use NULL instead of 0 for pointers. MFC after: 3 days Modified: head/sys/dev/sound/pci/hda/hdaa.c head/sys/dev/sound/pci/hda/hdac.c head/sys/dev/sound/pci/hda/hdacc.c Modified: head/sys/dev/sound/pci/hda/hdaa.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdaa.c Wed Apr 23 19:25:59 2014 (r264831) +++ head/sys/dev/sound/pci/hda/hdaa.c Wed Apr 23 19:32:50 2014 (r264832) @@ -53,7 +53,7 @@ SND_DECLARE_FILE("$FreeBSD$"); #define hdaa_lockowned(devinfo) mtx_owned((devinfo)->lock) static const struct { - char *key; + const char *key; uint32_t value; } hdaa_quirks_tab[] = { { "softpcmvol", HDAA_QUIRK_SOFTPCMVOL }, @@ -71,28 +71,26 @@ static const struct { { "ovref", HDAA_QUIRK_OVREF }, { "vref", HDAA_QUIRK_VREF }, }; -#define HDAA_QUIRKS_TAB_LEN \ - (sizeof(hdaa_quirks_tab) / sizeof(hdaa_quirks_tab[0])) #define HDA_PARSE_MAXDEPTH 10 MALLOC_DEFINE(M_HDAA, "hdaa", "HDA Audio"); -const char *HDA_COLORS[16] = {"Unknown", "Black", "Grey", "Blue", "Green", "Red", - "Orange", "Yellow", "Purple", "Pink", "Res.A", "Res.B", "Res.C", "Res.D", - "White", "Other"}; +static const char *HDA_COLORS[16] = {"Unknown", "Black", "Grey", "Blue", + "Green", "Red", "Orange", "Yellow", "Purple", "Pink", "Res.A", "Res.B", + "Res.C", "Res.D", "White", "Other"}; -const char *HDA_DEVS[16] = {"Line-out", "Speaker", "Headphones", "CD", +static const char *HDA_DEVS[16] = {"Line-out", "Speaker", "Headphones", "CD", "SPDIF-out", "Digital-out", "Modem-line", "Modem-handset", "Line-in", "AUX", "Mic", "Telephony", "SPDIF-in", "Digital-in", "Res.E", "Other"}; -const char *HDA_CONNS[4] = {"Jack", "None", "Fixed", "Both"}; +static const char *HDA_CONNS[4] = {"Jack", "None", "Fixed", "Both"}; -const char *HDA_CONNECTORS[16] = { +static const char *HDA_CONNECTORS[16] = { "Unknown", "1/8", "1/4", "ATAPI", "RCA", "Optical", "Digital", "Analog", "DIN", "XLR", "RJ-11", "Combo", "0xc", "0xd", "0xe", "Other" }; -const char *HDA_LOCS[64] = { +static const char *HDA_LOCS[64] = { "0x00", "Rear", "Front", "Left", "Right", "Top", "Bottom", "Rear-panel", "Drive-bay", "0x09", "0x0a", "0x0b", "0x0c", "0x0d", "0x0e", "0x0f", "Internal", "0x11", "0x12", "0x13", "0x14", "0x15", "0x16", "Riser", @@ -102,10 +100,10 @@ const char *HDA_LOCS[64] = { "Other", "0x31", "0x32", "0x33", "0x34", "0x35", "Other-Bott", "Lid-In", "Lid-Out", "0x39", "0x3a", "0x3b", "0x3c", "0x3d", "0x3e", "0x3f" }; -const char *HDA_GPIO_ACTIONS[8] = { +static const char *HDA_GPIO_ACTIONS[8] = { "keep", "set", "clear", "disable", "input", "0x05", "0x06", "0x07"}; -const char *HDA_HDMI_CODING_TYPES[18] = { +static const char *HDA_HDMI_CODING_TYPES[18] = { "undefined", "LPCM", "AC-3", "MPEG1", "MP3", "MPEG2", "AAC-LC", "DTS", "ATRAC", "DSD", "E-AC-3", "DTS-HD", "MLP", "DST", "WMAPro", "HE-AAC", "HE-AACv2", "MPEG-Surround" @@ -1113,7 +1111,7 @@ hdaa_dump_pin_sb(struct sbuf *sb, struct } static void -hdaa_dump_amp_sb(struct sbuf *sb, uint32_t cap, char *banner) +hdaa_dump_amp_sb(struct sbuf *sb, uint32_t cap, const char *banner) { int offset, size, step; @@ -1274,7 +1272,7 @@ hdaa_config_fetch(const char *str, uint3 inv = 2; else inv = 0; - for (k = 0; len > inv && k < HDAA_QUIRKS_TAB_LEN; k++) { + for (k = 0; len > inv && k < nitems(hdaa_quirks_tab); k++) { if (strncmp(str + i + inv, hdaa_quirks_tab[k].key, len - inv) != 0) continue; @@ -1302,7 +1300,7 @@ hdaa_sysctl_quirks(SYSCTL_HANDLER_ARGS) quirks = *(uint32_t *)oidp->oid_arg1; buf[0] = 0; - for (i = 0; i < HDAA_QUIRKS_TAB_LEN; i++) { + for (i = 0; i < nitems(hdaa_quirks_tab); i++) { if ((quirks & hdaa_quirks_tab[i].value) != 0) n += snprintf(buf + n, sizeof(buf) - n, "%s%s", n != 0 ? "," : "", hdaa_quirks_tab[i].key); @@ -1576,7 +1574,7 @@ hdaa_widget_parse(struct hdaa_widget *w) static void hdaa_widget_postprocess(struct hdaa_widget *w) { - char *typestr; + const char *typestr; w->type = HDA_PARAM_AUDIO_WIDGET_CAP_TYPE(w->param.widget_cap); switch (w->type) { @@ -5778,7 +5776,7 @@ hdaa_dump_pin_configs(struct hdaa_devinf } static void -hdaa_dump_amp(device_t dev, uint32_t cap, char *banner) +hdaa_dump_amp(device_t dev, uint32_t cap, const char *banner) { int offset, size, step; @@ -6209,7 +6207,7 @@ hdaa_configure(device_t dev) HDA_BOOTVERBOSE( if (devinfo->quirks != 0) { device_printf(dev, "FG config/quirks:"); - for (i = 0; i < HDAA_QUIRKS_TAB_LEN; i++) { + for (i = 0; i < nitems(hdaa_quirks_tab); i++) { if ((devinfo->quirks & hdaa_quirks_tab[i].value) == hdaa_quirks_tab[i].value) @@ -6834,7 +6832,7 @@ static device_method_t hdaa_methods[] = DEVMETHOD(hdac_stream_intr, hdaa_stream_intr), DEVMETHOD(hdac_unsol_intr, hdaa_unsol_intr), DEVMETHOD(hdac_pindump, hdaa_pindump), - { 0, 0 } + DEVMETHOD_END }; static driver_t hdaa_driver = { @@ -6845,7 +6843,7 @@ static driver_t hdaa_driver = { static devclass_t hdaa_devclass; -DRIVER_MODULE(snd_hda, hdacc, hdaa_driver, hdaa_devclass, 0, 0); +DRIVER_MODULE(snd_hda, hdacc, hdaa_driver, hdaa_devclass, NULL, NULL); static void hdaa_chan_formula(struct hdaa_devinfo *devinfo, int asid, @@ -7143,7 +7141,7 @@ static device_method_t hdaa_pcm_methods[ DEVMETHOD(device_probe, hdaa_pcm_probe), DEVMETHOD(device_attach, hdaa_pcm_attach), DEVMETHOD(device_detach, hdaa_pcm_detach), - { 0, 0 } + DEVMETHOD_END }; static driver_t hdaa_pcm_driver = { @@ -7152,6 +7150,6 @@ static driver_t hdaa_pcm_driver = { PCM_SOFTC_SIZE, }; -DRIVER_MODULE(snd_hda_pcm, hdaa, hdaa_pcm_driver, pcm_devclass, 0, 0); +DRIVER_MODULE(snd_hda_pcm, hdaa, hdaa_pcm_driver, pcm_devclass, NULL, NULL); MODULE_DEPEND(snd_hda, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER); MODULE_VERSION(snd_hda, 1); Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Wed Apr 23 19:25:59 2014 (r264831) +++ head/sys/dev/sound/pci/hda/hdac.c Wed Apr 23 19:32:50 2014 (r264832) @@ -60,21 +60,19 @@ SND_DECLARE_FILE("$FreeBSD$"); #define HDAC_QUIRK_MSI (1 << 2) static const struct { - char *key; + const char *key; uint32_t value; } hdac_quirks_tab[] = { { "64bit", HDAC_QUIRK_DMAPOS }, { "dmapos", HDAC_QUIRK_DMAPOS }, { "msi", HDAC_QUIRK_MSI }, }; -#define HDAC_QUIRKS_TAB_LEN \ - (sizeof(hdac_quirks_tab) / sizeof(hdac_quirks_tab[0])) MALLOC_DEFINE(M_HDAC, "hdac", "HDA Controller"); static const struct { uint32_t model; - char *desc; + const char *desc; char quirks_on; char quirks_off; } hdac_devices[] = { @@ -170,7 +168,6 @@ static const struct { { HDA_SIS_ALL, "SiS", 0, 0 }, { HDA_ULI_ALL, "ULI", 0, 0 }, }; -#define HDAC_DEVICES_LEN (sizeof(hdac_devices) / sizeof(hdac_devices[0])) static const struct { uint16_t vendor; @@ -182,8 +179,6 @@ static const struct { { ATI_VENDORID, 0x42, 0xf8, 0x02 }, { NVIDIA_VENDORID, 0x4e, 0xf0, 0x0f }, }; -#define HDAC_PCIESNOOP_LEN \ - (sizeof(hdac_pcie_snoop) / sizeof(hdac_pcie_snoop[0])) /**************************************************************************** * Function prototypes @@ -254,7 +249,7 @@ hdac_config_fetch(struct hdac_softc *sc, inv = 2; else inv = 0; - for (k = 0; len > inv && k < HDAC_QUIRKS_TAB_LEN; k++) { + for (k = 0; len > inv && k < nitems(hdac_quirks_tab); k++) { if (strncmp(res + i + inv, hdac_quirks_tab[k].key, len - inv) != 0) continue; @@ -1024,7 +1019,7 @@ hdac_probe(device_t dev) bzero(desc, sizeof(desc)); result = ENXIO; - for (i = 0; i < HDAC_DEVICES_LEN; i++) { + for (i = 0; i < nitems(hdac_devices); i++) { if (hdac_devices[i].model == model) { strlcpy(desc, hdac_devices[i].desc, sizeof(desc)); result = BUS_PROBE_DEFAULT; @@ -1096,7 +1091,7 @@ hdac_attach(device_t dev) class = pci_get_class(dev); subclass = pci_get_subclass(dev); - for (i = 0; i < HDAC_DEVICES_LEN; i++) { + for (i = 0; i < nitems(hdac_devices); i++) { if (hdac_devices[i].model == model) { devid = i; break; @@ -1175,7 +1170,7 @@ hdac_attach(device_t dev) * * http://msdn2.microsoft.com/en-us/library/ms790324.aspx */ - for (i = 0; i < HDAC_PCIESNOOP_LEN; i++) { + for (i = 0; i < nitems(hdac_pcie_snoop); i++) { if (hdac_pcie_snoop[i].vendor != vendor) continue; sc->flags &= ~HDAC_F_DMA_NOCACHE; @@ -2078,7 +2073,7 @@ static device_method_t hdac_methods[] = DEVMETHOD(hdac_stream_getptr, hdac_stream_getptr), DEVMETHOD(hdac_unsol_alloc, hdac_unsol_alloc), DEVMETHOD(hdac_unsol_free, hdac_unsol_free), - { 0, 0 } + DEVMETHOD_END }; static driver_t hdac_driver = { @@ -2089,4 +2084,4 @@ static driver_t hdac_driver = { static devclass_t hdac_devclass; -DRIVER_MODULE(snd_hda, pci, hdac_driver, hdac_devclass, 0, 0); +DRIVER_MODULE(snd_hda, pci, hdac_driver, hdac_devclass, NULL, NULL); Modified: head/sys/dev/sound/pci/hda/hdacc.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdacc.c Wed Apr 23 19:25:59 2014 (r264831) +++ head/sys/dev/sound/pci/hda/hdacc.c Wed Apr 23 19:32:50 2014 (r264832) @@ -71,7 +71,7 @@ MALLOC_DEFINE(M_HDACC, "hdacc", "HDA COD static const struct { uint32_t id; uint16_t revid; - char *name; + const char *name; } hdacc_codecs[] = { { HDA_CODEC_CS4206, 0, "Cirrus Logic CS4206" }, { HDA_CODEC_CS4207, 0, "Cirrus Logic CS4207" }, @@ -341,7 +341,6 @@ static const struct { { HDA_CODEC_STACXXXX, 0, "Sigmatel" }, { HDA_CODEC_VTXXXX, 0, "VIA" }, }; -#define HDACC_CODECS_LEN (sizeof(hdacc_codecs) / sizeof(hdacc_codecs[0])) static int hdacc_suspend(device_t dev) @@ -381,7 +380,7 @@ hdacc_probe(device_t dev) id = ((uint32_t)hda_get_vendor_id(dev) << 16) + hda_get_device_id(dev); revid = ((uint32_t)hda_get_revision_id(dev) << 8) + hda_get_stepping_id(dev); - for (i = 0; i < HDACC_CODECS_LEN; i++) { + for (i = 0; i < nitems(hdacc_codecs); i++) { if (!HDA_DEV_MATCH(hdacc_codecs[i].id, id)) continue; if (hdacc_codecs[i].revid != 0 && @@ -389,7 +388,7 @@ hdacc_probe(device_t dev) continue; break; } - if (i < HDACC_CODECS_LEN) { + if (i < nitems(hdacc_codecs)) { if ((hdacc_codecs[i].id & 0xffff) != 0xffff) strlcpy(buf, hdacc_codecs[i].name, sizeof(buf)); else @@ -713,7 +712,7 @@ static device_method_t hdacc_methods[] = DEVMETHOD(hdac_unsol_free, hdacc_unsol_free), DEVMETHOD(hdac_unsol_intr, hdacc_unsol_intr), DEVMETHOD(hdac_pindump, hdacc_pindump), - { 0, 0 } + DEVMETHOD_END }; static driver_t hdacc_driver = { @@ -724,4 +723,4 @@ static driver_t hdacc_driver = { static devclass_t hdacc_devclass; -DRIVER_MODULE(snd_hda, hdac, hdacc_driver, hdacc_devclass, 0, 0); +DRIVER_MODULE(snd_hda, hdac, hdacc_driver, hdacc_devclass, NULL, NULL);