Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
881e935a
Commit
881e935a
authored
18 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Allow only one open() on XML device.
parent
6b12229e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
master/xmldev.c
+21
-0
21 additions, 0 deletions
master/xmldev.c
master/xmldev.h
+3
-0
3 additions, 0 deletions
master/xmldev.h
with
24 additions
and
0 deletions
master/xmldev.c
+
21
−
0
View file @
881e935a
...
@@ -74,6 +74,7 @@ int ec_xmldev_init(ec_xmldev_t *xmldev, /**< EtherCAT XML device */
...
@@ -74,6 +74,7 @@ int ec_xmldev_init(ec_xmldev_t *xmldev, /**< EtherCAT XML device */
dev_t
dev_num
/**< device number */
dev_t
dev_num
/**< device number */
)
)
{
{
atomic_set
(
&
xmldev
->
available
,
1
);
cdev_init
(
&
xmldev
->
cdev
,
&
fops
);
cdev_init
(
&
xmldev
->
cdev
,
&
fops
);
xmldev
->
cdev
.
owner
=
THIS_MODULE
;
xmldev
->
cdev
.
owner
=
THIS_MODULE
;
if
(
cdev_add
(
&
xmldev
->
cdev
,
if
(
cdev_add
(
&
xmldev
->
cdev
,
...
@@ -97,11 +98,29 @@ void ec_xmldev_clear(ec_xmldev_t *xmldev /**< EtherCAT XML device */)
...
@@ -97,11 +98,29 @@ void ec_xmldev_clear(ec_xmldev_t *xmldev /**< EtherCAT XML device */)
/*****************************************************************************/
/*****************************************************************************/
int
ec_xmldev_request
(
ec_xmldev_t
*
xmldev
,
uint32_t
vendor_id
,
uint32_t
product_code
)
{
return
1
;
}
/******************************************************************************
* file_operations
*****************************************************************************/
int
ecxmldev_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
int
ecxmldev_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
{
ec_xmldev_t
*
xmldev
;
ec_xmldev_t
*
xmldev
;
xmldev
=
container_of
(
inode
->
i_cdev
,
ec_xmldev_t
,
cdev
);
xmldev
=
container_of
(
inode
->
i_cdev
,
ec_xmldev_t
,
cdev
);
if
(
!
atomic_dec_and_test
(
&
xmldev
->
available
))
{
atomic_inc
(
&
xmldev
->
available
);
return
-
EBUSY
;
}
filp
->
private_data
=
xmldev
;
filp
->
private_data
=
xmldev
;
EC_DBG
(
"File opened.
\n
"
);
EC_DBG
(
"File opened.
\n
"
);
...
@@ -113,6 +132,8 @@ int ecxmldev_open(struct inode *inode, struct file *filp)
...
@@ -113,6 +132,8 @@ int ecxmldev_open(struct inode *inode, struct file *filp)
int
ecxmldev_release
(
struct
inode
*
inode
,
struct
file
*
filp
)
int
ecxmldev_release
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
{
ec_xmldev_t
*
xmldev
=
container_of
(
inode
->
i_cdev
,
ec_xmldev_t
,
cdev
);
atomic_inc
(
&
xmldev
->
available
);
EC_DBG
(
"File closed.
\n
"
);
EC_DBG
(
"File closed.
\n
"
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
master/xmldev.h
+
3
−
0
View file @
881e935a
...
@@ -57,6 +57,7 @@ typedef struct
...
@@ -57,6 +57,7 @@ typedef struct
{
{
ec_master_t
*
master
;
/**< master owning the device */
ec_master_t
*
master
;
/**< master owning the device */
struct
cdev
cdev
;
/**< character device */
struct
cdev
cdev
;
/**< character device */
atomic_t
available
;
/**< allow only one open() */
}
}
ec_xmldev_t
;
ec_xmldev_t
;
...
@@ -65,6 +66,8 @@ ec_xmldev_t;
...
@@ -65,6 +66,8 @@ ec_xmldev_t;
int
ec_xmldev_init
(
ec_xmldev_t
*
,
ec_master_t
*
,
dev_t
);
int
ec_xmldev_init
(
ec_xmldev_t
*
,
ec_master_t
*
,
dev_t
);
void
ec_xmldev_clear
(
ec_xmldev_t
*
);
void
ec_xmldev_clear
(
ec_xmldev_t
*
);
int
ec_xmldev_request
(
ec_xmldev_t
*
,
uint32_t
,
uint32_t
);
/*****************************************************************************/
/*****************************************************************************/
#endif
#endif
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