summaryrefslogtreecommitdiffstats
path: root/src/drivers/nvs
diff options
context:
space:
mode:
authorMichael Brown2006-12-05 00:20:56 +0100
committerMichael Brown2006-12-05 00:20:56 +0100
commit6b45947a592143ff317c4825420ff08184e95c07 (patch)
tree4b3ce757635d2869254bfabf67123db6a1dd95d9 /src/drivers/nvs
parentAdded nvs_write(). This shares a lot of code in common with nvs_read(); (diff)
downloadipxe-6b45947a592143ff317c4825420ff08184e95c07.tar.gz
ipxe-6b45947a592143ff317c4825420ff08184e95c07.tar.xz
ipxe-6b45947a592143ff317c4825420ff08184e95c07.zip
Added debug statements
Diffstat (limited to 'src/drivers/nvs')
-rw-r--r--src/drivers/nvs/spi.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/drivers/nvs/spi.c b/src/drivers/nvs/spi.c
index a4e6868c..a5bd46a1 100644
--- a/src/drivers/nvs/spi.c
+++ b/src/drivers/nvs/spi.c
@@ -85,8 +85,16 @@ int spi_read ( struct nvs_device *nvs, unsigned int address,
struct spi_bus *bus = device->bus;
unsigned int command = spi_command ( SPI_READ, address,
device->munge_address );
+ int rc;
+
+ DBG ( "SPI %p reading %d bytes from %#04x\n", device, len, address );
+ if ( ( rc = bus->rw ( bus, device, command, address,
+ NULL, data, len ) ) != 0 ) {
+ DBG ( "SPI %p failed to read data from device\n", device );
+ return rc;
+ }
- return bus->rw ( bus, device, command, address, NULL, data, len );
+ return 0;
}
/**
@@ -106,16 +114,24 @@ int spi_write ( struct nvs_device *nvs, unsigned int address,
device->munge_address );
int rc;
+ DBG ( "SPI %p writing %d bytes to %#04x\n", device, len, address );
+
if ( ( rc = bus->rw ( bus, device, SPI_WREN, -1,
- NULL, NULL, 0 ) ) != 0 )
+ NULL, NULL, 0 ) ) != 0 ) {
+ DBG ( "SPI %p failed to write-enable device\n", device );
return rc;
+ }
if ( ( rc = bus->rw ( bus, device, command, address,
- data, NULL, len ) ) != 0 )
+ data, NULL, len ) ) != 0 ) {
+ DBG ( "SPI %p failed to write data to device\n", device );
return rc;
+ }
- if ( ( rc = spi_wait ( device ) ) != 0 )
+ if ( ( rc = spi_wait ( device ) ) != 0 ) {
+ DBG ( "SPI %p failed to complete write operation\n", device );
return rc;
+ }
return 0;
}