Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
12b84597
Commit
12b84597
authored
11 years ago
by
px4dev
Browse files
Options
Downloads
Patches
Plain Diff
Direct access functions return errors directly, not touching errno.
parent
7c83e928
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/drivers/device/device.cpp
+3
-12
3 additions, 12 deletions
src/drivers/device/device.cpp
src/drivers/device/device.h
+43
-50
43 additions, 50 deletions
src/drivers/device/device.h
with
46 additions
and
62 deletions
src/drivers/device/device.cpp
+
3
−
12
View file @
12b84597
...
...
@@ -223,31 +223,22 @@ interrupt(int irq, void *context)
return
OK
;
}
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
This diff is collapsed.
Click to expand it.
src/drivers/device/device.h
+
43
−
50
View file @
12b84597
...
...
@@ -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
regis
te
r
s 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
i
te
m
s 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 */
...
...
@@ -137,13 +137,6 @@ protected:
Device
(
const
char
*
name
,
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
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment