aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-07-14 11:43:43 -0700
committerpx4dev <px4@purgatory.org>2013-07-14 11:43:43 -0700
commit12b84597d8058412002de6292d5def559b19c7e6 (patch)
tree4d11ae011d472065c426876c23e8d64e6c3e8d20
parent7c83e928a5ac190631047ef5b1758f1ca6b01871 (diff)
downloadpx4-firmware-12b84597d8058412002de6292d5def559b19c7e6.tar.gz
px4-firmware-12b84597d8058412002de6292d5def559b19c7e6.tar.bz2
px4-firmware-12b84597d8058412002de6292d5def559b19c7e6.zip
Direct access functions return errors directly, not touching errno.
-rw-r--r--src/drivers/device/device.cpp15
-rw-r--r--src/drivers/device/device.h93
2 files changed, 46 insertions, 62 deletions
diff --git a/src/drivers/device/device.cpp b/src/drivers/device/device.cpp
index dd8074460..1c6f9b7f4 100644
--- a/src/drivers/device/device.cpp
+++ b/src/drivers/device/device.cpp
@@ -224,30 +224,21 @@ interrupt(int irq, void *context)
}
int
-Device::probe()
-{
- return -1;
-}
-
-int
Device::read(unsigned offset, void *data, unsigned count)
{
- errno = ENODEV;
- return -1;
+ return -ENODEV;
}
int
Device::write(unsigned offset, void *data, unsigned count)
{
- errno = ENODEV;
- return -1;
+ return -ENODEV;
}
int
Device::ioctl(unsigned operation, unsigned &arg)
{
- errno = ENODEV;
- return -1;
+ return -ENODEV;
}
} // namespace device \ No newline at end of file
diff --git a/src/drivers/device/device.h b/src/drivers/device/device.h
index d69d1b2d6..75f35ff0f 100644
--- a/src/drivers/device/device.h
+++ b/src/drivers/device/device.h
@@ -80,49 +80,49 @@ public:
*/
virtual void interrupt(void *ctx); /**< interrupt handler */
- /*
- * Direct access methods.
- */
-
- /**
- * Probe to test whether the device is present.
- *
- * @return Zero if present, < 0 (error) otherwise.
- */
- virtual int probe();
-
- /**
- * Read directly from the device.
- *
- * The actual size of each unit quantity is device-specific.
- *
- * @param offset The device address at which to start reading
- * @param data The buffer into which the read values should be placed.
- * @param count The number of items to read, defaults to 1.
- * @return count on success, < 0 on error.
- */
- virtual int read(unsigned address, void *data, unsigned count = 1);
-
- /**
- * Write directly to the device.
- *
- * The actual size of each unit quantity is device-specific.
- *
- * @param address The device address at which to start writing.
- * @param data The buffer from which values should be read.
- * @param count The number of registers to write, defaults to 1.
- * @return count on success, < 0 on error.
- */
- virtual int write(unsigned address, void *data, unsigned count = 1);
-
- /**
- * Perform a device-specific operation.
- *
- * @param operation The operation to perform
- * @param arg An argument to the operation.
- * @return < 0 on error
- */
- virtual int ioctl(unsigned operation, unsigned &arg);
+ /*
+ * Direct access methods.
+ */
+
+ /**
+ * Initialise the driver and make it ready for use.
+ *
+ * @return OK if the driver initialized OK, negative errno otherwise;
+ */
+ virtual int init();
+
+ /**
+ * Read directly from the device.
+ *
+ * The actual size of each unit quantity is device-specific.
+ *
+ * @param offset The device address at which to start reading
+ * @param data The buffer into which the read values should be placed.
+ * @param count The number of items to read.
+ * @return The number of items read on success, negative errno otherwise.
+ */
+ virtual int read(unsigned address, void *data, unsigned count);
+
+ /**
+ * Write directly to the device.
+ *
+ * The actual size of each unit quantity is device-specific.
+ *
+ * @param address The device address at which to start writing.
+ * @param data The buffer from which values should be read.
+ * @param count The number of items to write.
+ * @return The number of items written on success, negative errno otherwise.
+ */
+ virtual int write(unsigned address, void *data, unsigned count);
+
+ /**
+ * Perform a device-specific operation.
+ *
+ * @param operation The operation to perform.
+ * @param arg An argument to the operation.
+ * @return Negative errno on error, OK or positive value on success.
+ */
+ virtual int ioctl(unsigned operation, unsigned &arg);
protected:
const char *_name; /**< driver name */
@@ -138,13 +138,6 @@ protected:
int irq = 0);
/**
- * Initialise the driver and make it ready for use.
- *
- * @return OK if the driver initialised OK.
- */
- virtual int init();
-
- /**
* Enable the device interrupt
*/
void interrupt_enable();