aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/bhnd
diff options
context:
space:
mode:
authorLandon J. Fuller <landonf@FreeBSD.org>2017-05-23 22:30:15 +0000
committerLandon J. Fuller <landonf@FreeBSD.org>2017-05-23 22:30:15 +0000
commit26e4f220379d70e286fee639849f7b3eba9c2538 (patch)
treece0a962677336524aee57ac68b7356cbf4381300 /sys/dev/bhnd
parentbb2a5bfade28cb37a87ea79f95badc0cae25f4b8 (diff)
Notes
Diffstat (limited to 'sys/dev/bhnd')
-rw-r--r--sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c10
-rw-r--r--sys/dev/bhnd/nvram/bhnd_sprom.c6
2 files changed, 10 insertions, 6 deletions
diff --git a/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c b/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c
index 12035a84b112..480e507cbaf3 100644
--- a/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c
+++ b/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c
@@ -184,6 +184,7 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram_io *io,
u_char buf[512];
size_t nread;
uint16_t magic;
+ uint8_t srevcrc[2];
uint8_t srev;
bool crc_valid;
bool have_magic;
@@ -224,12 +225,15 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram_io *io,
nbytes += nr;
}
- /* Read SPROM revision */
- error = bhnd_nvram_io_read(io, layout->srev_offset, &srev,
- sizeof(srev));
+ /* Read 8-bit SPROM revision, maintaining 16-bit size alignment
+ * required by some OTP/SPROM chipsets. */
+ error = bhnd_nvram_io_read(io, layout->srev_offset, &srevcrc,
+ sizeof(srevcrc));
if (error)
return (error);
+ srev = srevcrc[0];
+
/* Early sromrev 1 devices (specifically some BCM440x enet
* cards) are reported to have been incorrectly programmed
* with a revision of 0x10. */
diff --git a/sys/dev/bhnd/nvram/bhnd_sprom.c b/sys/dev/bhnd/nvram/bhnd_sprom.c
index 0ec7291e2f89..d830af9785d1 100644
--- a/sys/dev/bhnd/nvram/bhnd_sprom.c
+++ b/sys/dev/bhnd/nvram/bhnd_sprom.c
@@ -120,9 +120,9 @@ bhnd_sprom_attach(device_t dev, bus_size_t offset)
sprom_size = r_size - offset;
- /* Allocate an I/O context for the SPROM parser. SPROM reads do not
- * appear to require any specific alignment. */
- io = bhnd_nvram_iores_new(r, offset, sprom_size, 1);
+ /* Allocate an I/O context for the SPROM parser. All SPROM reads
+ * must be 16-bit aligned */
+ io = bhnd_nvram_iores_new(r, offset, sprom_size, sizeof(uint16_t));
if (io == NULL) {
error = ENXIO;
goto failed;