Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - use proper types (uint16_t instead of uint32_t)
details: https://anonhg.NetBSD.org/src/rev/88f59cc37257
branches: trunk
changeset: 790525:88f59cc37257
user: christos <christos%NetBSD.org@localhost>
date: Wed Oct 16 17:39:09 2013 +0000
description:
- use proper types (uint16_t instead of uint32_t)
- don't index past the end of arrays
- use __arraycount() consistently instead of manual cruft.
- remove useless cast
diffstat:
sys/dev/pci/esa.c | 24 +++++++++++-------------
sys/dev/pci/esadsp.h | 6 +++---
2 files changed, 14 insertions(+), 16 deletions(-)
diffs (108 lines):
diff -r dacba7d07e9d -r 88f59cc37257 sys/dev/pci/esa.c
--- a/sys/dev/pci/esa.c Wed Oct 16 17:31:28 2013 +0000
+++ b/sys/dev/pci/esa.c Wed Oct 16 17:39:09 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: esa.c,v 1.58 2012/01/30 19:41:19 drochner Exp $ */
+/* $NetBSD: esa.c,v 1.59 2013/10/16 17:39:09 christos Exp $ */
/*
* Copyright (c) 2001-2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.58 2012/01/30 19:41:19 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esa.c,v 1.59 2013/10/16 17:39:09 christos Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -653,7 +653,7 @@
ESA_DMAC_BLOCKF_SELECTOR);
/* Set an armload of static initializers */
- for (i = 0; i < (sizeof(esa_playvals) / sizeof(esa_playvals[0])); i++)
+ for (i = 0; i < __arraycount(esa_playvals); i++)
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, dac_data +
esa_playvals[i].addr, esa_playvals[i].val);
@@ -787,7 +787,7 @@
ESA_DMAC_PAGE3_SELECTOR + ESA_DMAC_BLOCKF_SELECTOR);
/* Set an armload of static initializers */
- for (i = 0; i < (sizeof(esa_recvals) / sizeof(esa_recvals[0])); i++)
+ for (i = 0; i < __arraycount(esa_recvals); i++)
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, adc_data +
esa_recvals[i].addr, esa_recvals[i].val);
@@ -930,7 +930,7 @@
p->size = size;
error = bus_dmamem_alloc(sc->sc_dmat, p->size, align, 0,
- p->segs, sizeof(p->segs) / sizeof(p->segs[0]),
+ p->segs, __arraycount(p->segs),
&p->nsegs, BUS_DMA_WAITOK);
if (error)
return error;
@@ -1090,7 +1090,7 @@
/* create suspend save area */
sc->savememsz = sizeof(uint16_t) * (ESA_REV_B_CODE_MEMORY_LENGTH
+ ESA_REV_B_DATA_MEMORY_LENGTH + 1);
- sc->savemem = (uint16_t *)kmem_zalloc(sc->savememsz, KM_SLEEP);
+ sc->savemem = kmem_zalloc(sc->savememsz, KM_SLEEP);
if (sc->savemem == NULL) {
aprint_error_dev(sc->sc_dev,
"unable to allocate suspend buffer\n");
@@ -1385,21 +1385,19 @@
ESA_KDATA_DMA_XFER0);
/* Write kernel code into memory */
- size = sizeof(esa_assp_kernel_image);
- for (i = 0; i < size / 2; i++)
+ for (i = 0; i < __arraycount(esa_assp_kernel_image); i++)
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_CODE,
ESA_REV_B_CODE_MEMORY_BEGIN + i, esa_assp_kernel_image[i]);
- size = sizeof(esa_assp_minisrc_image);
- for (i = 0; i < size / 2; i++)
+ for (i = 0; i < __arraycount(esa_assp_minisrc_image); i++)
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_CODE, 0x400 + i,
esa_assp_minisrc_image[i]);
/* Write the coefficients for the low pass filter */
- size = sizeof(esa_minisrc_lpf_image);
- for (i = 0; i < size / 2; i++)
+ for (i = 0; i < __arraycount(esa_minisrc_lpf_image); i++)
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_CODE,
- 0x400 + ESA_MINISRC_COEF_LOC + i, esa_minisrc_lpf_image[i]);
+ 0x400 + ESA_MINISRC_COEF_LOC + i,
+ esa_minisrc_lpf_image[i]);
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_CODE,
0x400 + ESA_MINISRC_COEF_LOC + size, 0x8000);
esa_write_assp(sc, ESA_MEMTYPE_INTERNAL_DATA, ESA_KDATA_TASK0, 0x400);
diff -r dacba7d07e9d -r 88f59cc37257 sys/dev/pci/esadsp.h
--- a/sys/dev/pci/esadsp.h Wed Oct 16 17:31:28 2013 +0000
+++ b/sys/dev/pci/esadsp.h Wed Oct 16 17:39:09 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: esadsp.h,v 1.6 2005/12/11 12:22:49 christos Exp $ */
+/* $NetBSD: esadsp.h,v 1.7 2013/10/16 17:39:09 christos Exp $ */
/*
* Copyright (c) 2002 Lennart Augustsson
@@ -93,7 +93,7 @@
{ ESA_SRC3_DIRECTION_OFFSET + 22, 0xff}
};
-static uint32_t esa_assp_kernel_image[] = {
+static uint16_t esa_assp_kernel_image[] = {
0x7980, 0x0030, 0x7980, 0x03b4, 0x7980, 0x03b4, 0x7980, 0x00fb,
0x7980, 0x00dd, 0x7980, 0x03b4, 0x7980, 0x0332, 0x7980, 0x0287,
0x7980, 0x03b4, 0x7980, 0x03b4, 0x7980, 0x03b4, 0x7980, 0x03b4,
@@ -215,7 +215,7 @@
0x0267, 0x0368, 0x0469, 0x056a, 0xbe3a,
};
-static uint32_t esa_assp_minisrc_image[] = {
+static uint16_t esa_assp_minisrc_image[] = {
0xbf80, 0x101e, 0x906e,
0x006e, 0x8b88, 0x6980, 0xef88, 0x906f, 0x0d6f, 0x6900, 0xeb08,
0x0412, 0xbc20, 0x696e, 0xb801, 0x906e, 0x7980, 0x0403, 0xb90e,
Home |
Main Index |
Thread Index |
Old Index