author | Florian Pose <fp@igh-essen.com> |
Wed, 05 Nov 2008 13:48:14 +0000 | |
branch | stable-1.4 |
changeset 1670 | f6222c3e311a |
parent 1637 | 96da44b24111 |
child 1685 | 399ef727bf62 |
permissions | -rw-r--r-- |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT master character device. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "cdev.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
#include "master.h" |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
45 |
#include "slave_config.h" |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
#include "ioctl.h" |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
/** \cond */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
int eccdev_open(struct inode *, struct file *); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
int eccdev_release(struct inode *, struct file *); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
54 |
long eccdev_ioctl(struct file *, unsigned int, unsigned long); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
static struct file_operations eccdev_fops = { |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
59 |
.owner = THIS_MODULE, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
60 |
.open = eccdev_open, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
61 |
.release = eccdev_release, |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
62 |
.unlocked_ioctl = eccdev_ioctl |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
}; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
/** \endcond */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
/** Constructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
* \return 0 in case of success, else < 0 |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
int ec_cdev_init( |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
ec_cdev_t *cdev, /**< EtherCAT master character device. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
ec_master_t *master, /**< Parent master. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
dev_t dev_num /**< Device number. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
cdev->master = master; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
cdev_init(&cdev->cdev, &eccdev_fops); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
cdev->cdev.owner = THIS_MODULE; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
if (cdev_add(&cdev->cdev, |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
MKDEV(MAJOR(dev_num), master->index), 1)) { |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
EC_ERR("Failed to add character device!\n"); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
return -1; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
/** Destructor. |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
*/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
void ec_cdev_clear(ec_cdev_t *cdev /**< EtherCAT XML device */) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
cdev_del(&cdev->cdev); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
102 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
103 |
|
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
104 |
/** Copies a string to an ioctl structure. |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
105 |
*/ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
106 |
void ec_cdev_strcpy( |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
107 |
char *target, /**< Target. */ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
108 |
const char *source /**< Source. */ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
109 |
) |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
110 |
{ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
111 |
if (source) { |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
112 |
strncpy(target, source, EC_IOCTL_STRING_SIZE); |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
113 |
target[EC_IOCTL_STRING_SIZE - 1] = 0; |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
114 |
} else { |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
115 |
target[0] = 0; |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
116 |
} |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
117 |
} |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
118 |
|
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
119 |
/*****************************************************************************/ |
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
120 |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
121 |
/** Get master information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
122 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
123 |
int ec_cdev_ioctl_master( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
124 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
125 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
126 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
127 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
128 |
ec_ioctl_master_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
129 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
130 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
131 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
132 |
data.slave_count = master->slave_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
133 |
data.config_count = ec_master_config_count(master); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
134 |
data.domain_count = ec_master_domain_count(master); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
135 |
data.phase = (uint8_t) master->phase; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
136 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
137 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
138 |
if (down_interruptible(&master->device_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
139 |
return -EINTR; |
1162
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
140 |
if (master->main_device.dev) { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
141 |
memcpy(data.devices[0].address, |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
142 |
master->main_device.dev->dev_addr, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
143 |
} else { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
144 |
memcpy(data.devices[0].address, master->main_mac, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
145 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
146 |
data.devices[0].attached = master->main_device.dev ? 1 : 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
147 |
data.devices[0].tx_count = master->main_device.tx_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
148 |
data.devices[0].rx_count = master->main_device.rx_count; |
1162
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
149 |
|
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
150 |
if (master->backup_device.dev) { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
151 |
memcpy(data.devices[1].address, |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
152 |
master->backup_device.dev->dev_addr, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
153 |
} else { |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
154 |
memcpy(data.devices[1].address, master->backup_mac, ETH_ALEN); |
51a8b41d3dbc
Display real ethernet address.
Florian Pose <fp@igh-essen.com>
parents:
1150
diff
changeset
|
155 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
156 |
data.devices[1].attached = master->backup_device.dev ? 1 : 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
157 |
data.devices[1].tx_count = master->backup_device.tx_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
158 |
data.devices[1].rx_count = master->backup_device.rx_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
159 |
up(&master->device_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
160 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
161 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
162 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
163 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
164 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
165 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
166 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
167 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
168 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
169 |
/** Get slave information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
170 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
171 |
int ec_cdev_ioctl_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
172 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
173 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
174 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
175 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
176 |
ec_ioctl_slave_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
177 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
178 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
179 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
180 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
181 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
182 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
183 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
184 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
185 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
186 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
187 |
master, 0, data.position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
188 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
189 |
EC_ERR("Slave %u does not exist!\n", data.position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
190 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
191 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
192 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
193 |
data.vendor_id = slave->sii.vendor_id; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
194 |
data.product_code = slave->sii.product_code; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
195 |
data.revision_number = slave->sii.revision_number; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
196 |
data.serial_number = slave->sii.serial_number; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
197 |
data.alias = slave->sii.alias; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
198 |
data.rx_mailbox_offset = slave->sii.rx_mailbox_offset; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
199 |
data.rx_mailbox_size = slave->sii.rx_mailbox_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
200 |
data.tx_mailbox_offset = slave->sii.tx_mailbox_offset; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
201 |
data.tx_mailbox_size = slave->sii.tx_mailbox_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
202 |
data.mailbox_protocols = slave->sii.mailbox_protocols; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
203 |
data.has_general_category = slave->sii.has_general; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
204 |
data.coe_details = slave->sii.coe_details; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
205 |
data.general_flags = slave->sii.general_flags; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
206 |
data.current_on_ebus = slave->sii.current_on_ebus; |
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1147
diff
changeset
|
207 |
data.al_state = slave->current_state; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
208 |
data.error_flag = slave->error_flag; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
209 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
210 |
data.sync_count = slave->sii.sync_count; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
211 |
data.sdo_count = ec_slave_sdo_count(slave); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
212 |
data.sii_nwords = slave->sii_nwords; |
1109
11ac4051db6b
Group/Image/Order strings in slave ioctl; order number as text content
Florian Pose <fp@igh-essen.com>
parents:
1108
diff
changeset
|
213 |
ec_cdev_strcpy(data.group, slave->sii.group); |
11ac4051db6b
Group/Image/Order strings in slave ioctl; order number as text content
Florian Pose <fp@igh-essen.com>
parents:
1108
diff
changeset
|
214 |
ec_cdev_strcpy(data.image, slave->sii.image); |
11ac4051db6b
Group/Image/Order strings in slave ioctl; order number as text content
Florian Pose <fp@igh-essen.com>
parents:
1108
diff
changeset
|
215 |
ec_cdev_strcpy(data.order, slave->sii.order); |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
216 |
ec_cdev_strcpy(data.name, slave->sii.name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
217 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
218 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
219 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
220 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
221 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
222 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
223 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
224 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
225 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
226 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
227 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
228 |
/** Get slave sync manager information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
229 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
230 |
int ec_cdev_ioctl_slave_sync( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
231 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
232 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
233 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
234 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
235 |
ec_ioctl_slave_sync_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
236 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
237 |
const ec_sync_t *sync; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
238 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
239 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
240 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
241 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
242 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
243 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
244 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
245 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
246 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
247 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
248 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
249 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
250 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
251 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
252 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
253 |
if (data.sync_index >= slave->sii.sync_count) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
254 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
255 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
256 |
data.sync_index, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
257 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
258 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
259 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
260 |
sync = &slave->sii.syncs[data.sync_index]; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
261 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
262 |
data.physical_start_address = sync->physical_start_address; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
263 |
data.default_size = sync->default_length; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
264 |
data.control_register = sync->control_register; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
265 |
data.enable = sync->enable; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
266 |
data.pdo_count = ec_pdo_list_count(&sync->pdos); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
267 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
268 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
269 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
270 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
271 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
272 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
273 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
274 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
275 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
276 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
277 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
278 |
/** Get slave sync manager Pdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
279 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
280 |
int ec_cdev_ioctl_slave_sync_pdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
281 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
282 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
283 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
284 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
285 |
ec_ioctl_slave_sync_pdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
286 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
287 |
const ec_sync_t *sync; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
288 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
289 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
290 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
291 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
292 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
293 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
294 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
295 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
296 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
297 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
298 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
299 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
300 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
301 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
302 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
303 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
304 |
if (data.sync_index >= slave->sii.sync_count) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
305 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
306 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
307 |
data.sync_index, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
308 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
309 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
310 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
311 |
sync = &slave->sii.syncs[data.sync_index]; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
312 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
313 |
&sync->pdos, data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
314 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
315 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
316 |
"position %u in slave %u!\n", data.sync_index, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
317 |
data.pdo_pos, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
318 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
319 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
320 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
321 |
data.index = pdo->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
322 |
data.entry_count = ec_pdo_entry_count(pdo); |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
323 |
ec_cdev_strcpy(data.name, pdo->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
324 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
325 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
326 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
327 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
328 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
329 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
330 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
331 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
332 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
333 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
334 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
335 |
/** Get slave sync manager Pdo entry information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
336 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
337 |
int ec_cdev_ioctl_slave_sync_pdo_entry( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
338 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
339 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
340 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
341 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
342 |
ec_ioctl_slave_sync_pdo_entry_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
343 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
344 |
const ec_sync_t *sync; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
345 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
346 |
const ec_pdo_entry_t *entry; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
347 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
348 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
349 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
350 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
351 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
352 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
353 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
354 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
355 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
356 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
357 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
358 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
359 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
360 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
361 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
362 |
if (data.sync_index >= slave->sii.sync_count) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
363 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
364 |
EC_ERR("Sync manager %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
365 |
data.sync_index, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
366 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
367 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
368 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
369 |
sync = &slave->sii.syncs[data.sync_index]; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
370 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
371 |
&sync->pdos, data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
372 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
373 |
EC_ERR("Sync manager %u does not contain a Pdo with " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
374 |
"position %u in slave %u!\n", data.sync_index, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
375 |
data.pdo_pos, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
376 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
377 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
378 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
379 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
380 |
pdo, data.entry_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
381 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
382 |
EC_ERR("Pdo 0x%04X does not contain an entry with " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
383 |
"position %u in slave %u!\n", data.pdo_pos, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
384 |
data.entry_pos, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
385 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
386 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
387 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
388 |
data.index = entry->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
389 |
data.subindex = entry->subindex; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
390 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
391 |
ec_cdev_strcpy(data.name, entry->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
392 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
393 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
394 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
395 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
396 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
397 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
398 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
399 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
400 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
401 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
402 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
403 |
/** Get domain information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
404 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
405 |
int ec_cdev_ioctl_domain( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
406 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
407 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
408 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
409 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
410 |
ec_ioctl_domain_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
411 |
const ec_domain_t *domain; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
412 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
413 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
414 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
415 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
416 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
417 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
418 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
419 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
420 |
if (!(domain = ec_master_find_domain_const(master, data.index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
421 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
422 |
EC_ERR("Domain %u does not exist!\n", data.index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
423 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
424 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
425 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
426 |
data.data_size = domain->data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
427 |
data.logical_base_address = domain->logical_base_address; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
428 |
data.working_counter = domain->working_counter; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
429 |
data.expected_working_counter = domain->expected_working_counter; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
430 |
data.fmmu_count = ec_domain_fmmu_count(domain); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
431 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
432 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
433 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
434 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
435 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
436 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
437 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
438 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
439 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
440 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
441 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
442 |
/** Get domain FMMU information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
443 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
444 |
int ec_cdev_ioctl_domain_fmmu( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
445 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
446 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
447 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
448 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
449 |
ec_ioctl_domain_fmmu_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
450 |
const ec_domain_t *domain; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
451 |
const ec_fmmu_config_t *fmmu; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
452 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
453 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
454 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
455 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
456 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
457 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
458 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
459 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
460 |
if (!(domain = ec_master_find_domain_const(master, data.domain_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
461 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
462 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
463 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
464 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
465 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
466 |
if (!(fmmu = ec_domain_find_fmmu(domain, data.fmmu_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
467 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
468 |
EC_ERR("Domain %u has less than %u fmmu configurations.\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
469 |
data.domain_index, data.fmmu_index + 1); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
470 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
471 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
472 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
473 |
data.slave_config_alias = fmmu->sc->alias; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
474 |
data.slave_config_position = fmmu->sc->position; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
475 |
data.sync_index = fmmu->sync_index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
476 |
data.dir = fmmu->dir; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
477 |
data.logical_address = fmmu->logical_start_address; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
478 |
data.data_size = fmmu->data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
479 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
480 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
481 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
482 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
483 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
484 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
485 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
486 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
487 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
488 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
489 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
490 |
/** Get domain data. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
491 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
492 |
int ec_cdev_ioctl_domain_data( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
493 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
494 |
unsigned long arg /**< Userspace address to store the results. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
495 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
496 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
497 |
ec_ioctl_domain_data_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
498 |
const ec_domain_t *domain; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
499 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
500 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
501 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
502 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
503 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
504 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
505 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
506 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
507 |
if (!(domain = ec_master_find_domain_const(master, data.domain_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
508 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
509 |
EC_ERR("Domain %u does not exist!\n", data.domain_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
510 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
511 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
512 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
513 |
if (domain->data_size != data.data_size) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
514 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
515 |
EC_ERR("Data size mismatch %u/%u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
516 |
data.data_size, domain->data_size); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
517 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
518 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
519 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
520 |
if (copy_to_user((void __user *) data.target, domain->data, |
1637
96da44b24111
merge -c1454 trunk: Missing up().
Florian Pose <fp@igh-essen.com>
parents:
1196
diff
changeset
|
521 |
domain->data_size)) { |
96da44b24111
merge -c1454 trunk: Missing up().
Florian Pose <fp@igh-essen.com>
parents:
1196
diff
changeset
|
522 |
up(&master->master_sem); |
96da44b24111
merge -c1454 trunk: Missing up().
Florian Pose <fp@igh-essen.com>
parents:
1196
diff
changeset
|
523 |
return -EFAULT; |
96da44b24111
merge -c1454 trunk: Missing up().
Florian Pose <fp@igh-essen.com>
parents:
1196
diff
changeset
|
524 |
} |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
525 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
526 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
527 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
528 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
529 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
530 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
531 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
532 |
/** Set master debug level. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
533 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
534 |
int ec_cdev_ioctl_master_debug( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
535 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
536 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
537 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
538 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
539 |
if (ec_master_debug_level(master, (unsigned int) arg)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
540 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
541 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
542 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
543 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
544 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
545 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
546 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
547 |
/** Set slave state. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
548 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
549 |
int ec_cdev_ioctl_slave_state( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
550 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
551 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
552 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
553 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
554 |
ec_ioctl_slave_state_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
555 |
ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
556 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
557 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
558 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
559 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
560 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
561 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
562 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
563 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
564 |
if (!(slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
565 |
master, 0, data.slave_position))) { |
1196 | 566 |
up(&master->master_sem); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
567 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
568 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
569 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
570 |
|
1150 | 571 |
ec_slave_request_state(slave, data.al_state); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
572 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
573 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
574 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
575 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
576 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
577 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
578 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
579 |
/** Get slave Sdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
580 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
581 |
int ec_cdev_ioctl_slave_sdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
582 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
583 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
584 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
585 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
586 |
ec_ioctl_slave_sdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
587 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
588 |
const ec_sdo_t *sdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
589 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
590 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
591 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
592 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
593 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
594 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
595 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
596 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
597 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
598 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
599 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
600 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
601 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
602 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
603 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
604 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
605 |
slave, data.sdo_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
606 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
607 |
EC_ERR("Sdo %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
608 |
data.sdo_position, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
609 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
610 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
611 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
612 |
data.sdo_index = sdo->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
613 |
data.max_subindex = sdo->max_subindex; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
614 |
ec_cdev_strcpy(data.name, sdo->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
615 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
616 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
617 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
618 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
619 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
620 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
621 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
622 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
623 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
624 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
625 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
626 |
/** Get slave Sdo entry information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
627 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
628 |
int ec_cdev_ioctl_slave_sdo_entry( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
629 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
630 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
631 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
632 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
633 |
ec_ioctl_slave_sdo_entry_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
634 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
635 |
const ec_sdo_t *sdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
636 |
const ec_sdo_entry_t *entry; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
637 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
638 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
639 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
640 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
641 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
642 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
643 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
644 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
645 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
646 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
647 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
648 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
649 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
650 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
651 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
652 |
if (data.sdo_spec <= 0) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
653 |
if (!(sdo = ec_slave_get_sdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
654 |
slave, -data.sdo_spec))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
655 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
656 |
EC_ERR("Sdo %u does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
657 |
-data.sdo_spec, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
658 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
659 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
660 |
} else { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
661 |
if (!(sdo = ec_slave_get_sdo_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
662 |
slave, data.sdo_spec))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
663 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
664 |
EC_ERR("Sdo 0x%04X does not exist in slave %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
665 |
data.sdo_spec, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
666 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
667 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
668 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
669 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
670 |
if (!(entry = ec_sdo_get_entry_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
671 |
sdo, data.sdo_entry_subindex))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
672 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
673 |
EC_ERR("Sdo entry 0x%04X:%02X does not exist " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
674 |
"in slave %u!\n", sdo->index, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
675 |
data.sdo_entry_subindex, data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
676 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
677 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
678 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
679 |
data.data_type = entry->data_type; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
680 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
681 |
ec_cdev_strcpy(data.description, entry->description); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
682 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
683 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
684 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
685 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
686 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
687 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
688 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
689 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
690 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
691 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
692 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
693 |
/** Upload Sdo. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
694 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
695 |
int ec_cdev_ioctl_slave_sdo_upload( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
696 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
697 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
698 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
699 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
700 |
ec_ioctl_slave_sdo_upload_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
701 |
ec_master_sdo_request_t request; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
702 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
703 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
704 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
705 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
706 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
707 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
708 |
ec_sdo_request_init(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
709 |
ec_sdo_request_address(&request.req, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
710 |
data.sdo_index, data.sdo_entry_subindex); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
711 |
ecrt_sdo_request_read(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
712 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
713 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
714 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
715 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
716 |
if (!(request.slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
717 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
718 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
719 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
720 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
721 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
722 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
723 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
724 |
// schedule request. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
725 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
726 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
727 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
728 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
729 |
// wait for processing through FSM |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
730 |
if (wait_event_interruptible(master->sdo_queue, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
731 |
request.req.state != EC_REQUEST_QUEUED)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
732 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
733 |
down(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
734 |
if (request.req.state == EC_REQUEST_QUEUED) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
735 |
list_del(&request.req.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
736 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
737 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
738 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
739 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
740 |
// request already processing: interrupt not possible. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
741 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
742 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
743 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
744 |
// wait until master FSM has finished processing |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
745 |
wait_event(master->sdo_queue, request.req.state != EC_REQUEST_BUSY); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
746 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
747 |
data.abort_code = request.req.abort_code; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
748 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
749 |
if (request.req.state != EC_REQUEST_SUCCESS) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
750 |
data.data_size = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
751 |
retval = -EIO; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
752 |
} else { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
753 |
if (request.req.data_size > data.target_size) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
754 |
EC_ERR("Buffer too small.\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
755 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
756 |
return -EOVERFLOW; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
757 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
758 |
data.data_size = request.req.data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
759 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
760 |
if (copy_to_user((void __user *) data.target, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
761 |
request.req.data, data.data_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
762 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
763 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
764 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
765 |
retval = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
766 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
767 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
768 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
769 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
770 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
771 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
772 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
773 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
774 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
775 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
776 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
777 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
778 |
/** Download Sdo. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
779 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
780 |
int ec_cdev_ioctl_slave_sdo_download( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
781 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
782 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
783 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
784 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
785 |
ec_ioctl_slave_sdo_download_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
786 |
ec_master_sdo_request_t request; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
787 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
788 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
789 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
790 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
791 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
792 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
793 |
// copy data to download |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
794 |
if (!data.data_size) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
795 |
EC_ERR("Zero data size!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
796 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
797 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
798 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
799 |
ec_sdo_request_init(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
800 |
ec_sdo_request_address(&request.req, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
801 |
data.sdo_index, data.sdo_entry_subindex); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
802 |
if (ec_sdo_request_alloc(&request.req, data.data_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
803 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
804 |
return -ENOMEM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
805 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
806 |
if (copy_from_user(request.req.data, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
807 |
(void __user *) data.data, data.data_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
808 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
809 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
810 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
811 |
request.req.data_size = data.data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
812 |
ecrt_sdo_request_write(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
813 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
814 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
815 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
816 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
817 |
if (!(request.slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
818 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
819 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
820 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
821 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
822 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
823 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
824 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
825 |
// schedule request. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
826 |
list_add_tail(&request.list, &master->slave_sdo_requests); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
827 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
828 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
829 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
830 |
// wait for processing through FSM |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
831 |
if (wait_event_interruptible(master->sdo_queue, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
832 |
request.req.state != EC_REQUEST_QUEUED)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
833 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
834 |
down(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
835 |
if (request.req.state == EC_REQUEST_QUEUED) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
836 |
list_del(&request.req.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
837 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
838 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
839 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
840 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
841 |
// request already processing: interrupt not possible. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
842 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
843 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
844 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
845 |
// wait until master FSM has finished processing |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
846 |
wait_event(master->sdo_queue, request.req.state != EC_REQUEST_BUSY); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
847 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
848 |
data.abort_code = request.req.abort_code; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
849 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
850 |
retval = request.req.state == EC_REQUEST_SUCCESS ? 0 : -EIO; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
851 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
852 |
if (__copy_to_user((void __user *) arg, &data, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
853 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
854 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
855 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
856 |
ec_sdo_request_clear(&request.req); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
857 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
858 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
859 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
860 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
861 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
862 |
/** Read a slave's SII. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
863 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
864 |
int ec_cdev_ioctl_slave_sii_read( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
865 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
866 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
867 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
868 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
869 |
ec_ioctl_slave_sii_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
870 |
const ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
871 |
int retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
872 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
873 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
874 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
875 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
876 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
877 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
878 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
879 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
880 |
if (!(slave = ec_master_find_slave_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
881 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
882 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
883 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
884 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
885 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
886 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
887 |
if (!data.nwords |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
888 |
|| data.offset + data.nwords > slave->sii_nwords) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
889 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
890 |
EC_ERR("Invalid SII read offset/size %u/%u for slave " |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
891 |
"SII size %u!\n", data.offset, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
892 |
data.nwords, slave->sii_nwords); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
893 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
894 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
895 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
896 |
if (copy_to_user((void __user *) data.words, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
897 |
slave->sii_words + data.offset, data.nwords * 2)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
898 |
retval = -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
899 |
else |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
900 |
retval = 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
901 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
902 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
903 |
return retval; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
904 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
905 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
906 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
907 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
908 |
/** Write a slave's SII. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
909 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
910 |
int ec_cdev_ioctl_slave_sii_write( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
911 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
912 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
913 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
914 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
915 |
ec_ioctl_slave_sii_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
916 |
ec_slave_t *slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
917 |
unsigned int byte_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
918 |
uint16_t *words; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
919 |
ec_sii_write_request_t request; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
920 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
921 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
922 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
923 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
924 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
925 |
if (!data.nwords) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
926 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
927 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
928 |
byte_size = sizeof(uint16_t) * data.nwords; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
929 |
if (!(words = kmalloc(byte_size, GFP_KERNEL))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
930 |
EC_ERR("Failed to allocate %u bytes for SII contents.\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
931 |
byte_size); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
932 |
return -ENOMEM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
933 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
934 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
935 |
if (copy_from_user(words, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
936 |
(void __user *) data.words, byte_size)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
937 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
938 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
939 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
940 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
941 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
942 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
943 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
944 |
if (!(slave = ec_master_find_slave( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
945 |
master, 0, data.slave_position))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
946 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
947 |
EC_ERR("Slave %u does not exist!\n", data.slave_position); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
948 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
949 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
950 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
951 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
952 |
// init SII write request |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
953 |
INIT_LIST_HEAD(&request.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
954 |
request.slave = slave; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
955 |
request.words = words; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
956 |
request.offset = data.offset; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
957 |
request.nwords = data.nwords; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
958 |
request.state = EC_REQUEST_QUEUED; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
959 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
960 |
// schedule SII write request. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
961 |
list_add_tail(&request.list, &master->sii_requests); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
962 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
963 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
964 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
965 |
// wait for processing through FSM |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
966 |
if (wait_event_interruptible(master->sii_queue, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
967 |
request.state != EC_REQUEST_QUEUED)) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
968 |
// interrupted by signal |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
969 |
down(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
970 |
if (request.state == EC_REQUEST_QUEUED) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
971 |
// abort request |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
972 |
list_del(&request.list); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
973 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
974 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
975 |
return -EINTR; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
976 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
977 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
978 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
979 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
980 |
// wait until master FSM has finished processing |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
981 |
wait_event(master->sii_queue, request.state != EC_REQUEST_BUSY); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
982 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
983 |
kfree(words); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
984 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
985 |
return request.state == EC_REQUEST_SUCCESS ? 0 : -EIO; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
986 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
987 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
988 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
989 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
990 |
/** Get slave configuration information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
991 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
992 |
int ec_cdev_ioctl_config( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
993 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
994 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
995 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
996 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
997 |
ec_ioctl_config_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
998 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
999 |
uint8_t i; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1000 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1001 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1002 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1003 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1004 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1005 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1006 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1007 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1008 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1009 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1010 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1011 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1012 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1013 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1014 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1015 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1016 |
data.alias = sc->alias; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1017 |
data.position = sc->position; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1018 |
data.vendor_id = sc->vendor_id; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1019 |
data.product_code = sc->product_code; |
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1020 |
for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1021 |
data.syncs[i].dir = sc->sync_configs[i].dir; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1022 |
data.syncs[i].pdo_count = |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1023 |
ec_pdo_list_count(&sc->sync_configs[i].pdos); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1024 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1025 |
data.sdo_count = ec_slave_config_sdo_count(sc); |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1109
diff
changeset
|
1026 |
data.slave_position = sc->slave ? sc->slave->ring_position : -1; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1027 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1028 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1029 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1030 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1031 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1032 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1033 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1034 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1035 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1036 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1037 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1038 |
/** Get slave configuration Pdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1039 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1040 |
int ec_cdev_ioctl_config_pdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1041 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1042 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1043 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1044 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1045 |
ec_ioctl_config_pdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1046 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1047 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1048 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1049 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1050 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1051 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1052 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1053 |
if (data.sync_index >= EC_MAX_SYNC_MANAGERS) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1054 |
EC_ERR("Invalid sync manager index %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1055 |
data.sync_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1056 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1057 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1058 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1059 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1060 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1061 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1062 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1063 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1064 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1065 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1066 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1067 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1068 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1069 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1070 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1071 |
&sc->sync_configs[data.sync_index].pdos, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1072 |
data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1073 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1074 |
EC_ERR("Invalid Pdo position!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1075 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1076 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1077 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1078 |
data.index = pdo->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1079 |
data.entry_count = ec_pdo_entry_count(pdo); |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
1080 |
ec_cdev_strcpy(data.name, pdo->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1081 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1082 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1083 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1084 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1085 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1086 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1087 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1088 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1089 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1090 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1091 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1092 |
/** Get slave configuration Pdo entry information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1093 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1094 |
int ec_cdev_ioctl_config_pdo_entry( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1095 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1096 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1097 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1098 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1099 |
ec_ioctl_config_pdo_entry_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1100 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1101 |
const ec_pdo_t *pdo; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1102 |
const ec_pdo_entry_t *entry; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1103 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1104 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1105 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1106 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1107 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
1108 |
if (data.sync_index >= EC_MAX_SYNC_MANAGERS) { |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1109 |
EC_ERR("Invalid sync manager index %u!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1110 |
data.sync_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1111 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1112 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1113 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1114 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1115 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1116 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1117 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1118 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1119 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1120 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1121 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1122 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1123 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1124 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1125 |
if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1126 |
&sc->sync_configs[data.sync_index].pdos, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1127 |
data.pdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1128 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1129 |
EC_ERR("Invalid Pdo position!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1130 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1131 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1132 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1133 |
if (!(entry = ec_pdo_find_entry_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1134 |
pdo, data.entry_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1135 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1136 |
EC_ERR("Entry not found!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1137 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1138 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1139 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1140 |
data.index = entry->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1141 |
data.subindex = entry->subindex; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1142 |
data.bit_length = entry->bit_length; |
1108
7beba3e7e6b4
Added ec_cdev_strcpy() function.
Florian Pose <fp@igh-essen.com>
parents:
1092
diff
changeset
|
1143 |
ec_cdev_strcpy(data.name, entry->name); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1144 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1145 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1146 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1147 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1148 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1149 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1150 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1151 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1152 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1153 |
/*****************************************************************************/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1154 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1155 |
/** Get slave configuration Sdo information. |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1156 |
*/ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1157 |
int ec_cdev_ioctl_config_sdo( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1158 |
ec_master_t *master, /**< EtherCAT master. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1159 |
unsigned long arg /**< ioctl() argument. */ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1160 |
) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1161 |
{ |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1162 |
ec_ioctl_config_sdo_t data; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1163 |
const ec_slave_config_t *sc; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1164 |
const ec_sdo_request_t *req; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1165 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1166 |
if (copy_from_user(&data, (void __user *) arg, sizeof(data))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1167 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1168 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1169 |
|
1189
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1170 |
if (down_interruptible(&master->master_sem)) |
acc6430bfb32
Use down_interruptible() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1183
diff
changeset
|
1171 |
return -EINTR; |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1172 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1173 |
if (!(sc = ec_master_get_config_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1174 |
master, data.config_index))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1175 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1176 |
EC_ERR("Slave config %u does not exist!\n", |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1177 |
data.config_index); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1178 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1179 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1180 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1181 |
if (!(req = ec_slave_config_get_sdo_by_pos_const( |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1182 |
sc, data.sdo_pos))) { |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1183 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1184 |
EC_ERR("Invalid Sdo position!\n"); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1185 |
return -EINVAL; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1186 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1187 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1188 |
data.index = req->index; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1189 |
data.subindex = req->subindex; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1190 |
data.size = req->data_size; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1191 |
memcpy(&data.data, req->data, min((u32) data.size, (u32) 4)); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1192 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1193 |
up(&master->master_sem); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1194 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1195 |
if (copy_to_user((void __user *) arg, &data, sizeof(data))) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1196 |
return -EFAULT; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1197 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1198 |
return 0; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1199 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1200 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1201 |
/****************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1202 |
* File operations |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1203 |
*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1204 |
|
1092 | 1205 |
/** Called when the cdev is opened. |
1206 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1207 |
int eccdev_open(struct inode *inode, struct file *filp) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1208 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1209 |
ec_cdev_t *cdev = container_of(inode->i_cdev, ec_cdev_t, cdev); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1210 |
ec_master_t *master = cdev->master; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1211 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1212 |
filp->private_data = cdev; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1213 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1214 |
EC_DBG("File opened.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1215 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1216 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1217 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1218 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1219 |
|
1092 | 1220 |
/** Called when the cdev is closed. |
1221 |
*/ |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1222 |
int eccdev_release(struct inode *inode, struct file *filp) |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1223 |
{ |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1224 |
ec_cdev_t *cdev = (ec_cdev_t *) filp->private_data; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1225 |
ec_master_t *master = cdev->master; |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1226 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1227 |
if (master->debug_level) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1228 |
EC_DBG("File closed.\n"); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1229 |
return 0; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1230 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1231 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1232 |
/*****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1233 |
|
1092 | 1234 |
/** Called when an ioctl() command is issued. |
1235 |
*/ |
|
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1236 |
long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1237 |
{ |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1238 |
ec_cdev_t *cdev = (ec_cdev_t *) filp->private_data; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1239 |
ec_master_t *master = cdev->master; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1240 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1241 |
if (master->debug_level) |
981
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
1242 |
EC_DBG("ioctl(filp = %x, cmd = %u (%u), arg = %x)\n", |
5a2bd04c555c
Output decoded ioctl command number.
Florian Pose <fp@igh-essen.com>
parents:
980
diff
changeset
|
1243 |
(u32) filp, (u32) cmd, (u32) _IOC_NR(cmd), (u32) arg); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1244 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1245 |
switch (cmd) { |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
1246 |
case EC_IOCTL_MASTER: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1247 |
return ec_cdev_ioctl_master(master, arg); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
1248 |
case EC_IOCTL_SLAVE: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1249 |
return ec_cdev_ioctl_slave(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1250 |
case EC_IOCTL_SLAVE_SYNC: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1251 |
return ec_cdev_ioctl_slave_sync(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1252 |
case EC_IOCTL_SLAVE_SYNC_PDO: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1253 |
return ec_cdev_ioctl_slave_sync_pdo(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1254 |
case EC_IOCTL_SLAVE_SYNC_PDO_ENTRY: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1255 |
return ec_cdev_ioctl_slave_sync_pdo_entry(master, arg); |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
1256 |
case EC_IOCTL_DOMAIN: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1257 |
return ec_cdev_ioctl_domain(master, arg); |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
1258 |
case EC_IOCTL_DOMAIN_FMMU: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1259 |
return ec_cdev_ioctl_domain_fmmu(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1260 |
case EC_IOCTL_DOMAIN_DATA: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1261 |
return ec_cdev_ioctl_domain_data(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1262 |
case EC_IOCTL_MASTER_DEBUG: |
972 | 1263 |
if (!(filp->f_mode & FMODE_WRITE)) |
1264 |
return -EPERM; |
|
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1265 |
return ec_cdev_ioctl_master_debug(master, arg); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
1266 |
case EC_IOCTL_SLAVE_STATE: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1267 |
if (!(filp->f_mode & FMODE_WRITE)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1268 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1269 |
return ec_cdev_ioctl_slave_state(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1270 |
case EC_IOCTL_SLAVE_SDO: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1271 |
return ec_cdev_ioctl_slave_sdo(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1272 |
case EC_IOCTL_SLAVE_SDO_ENTRY: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1273 |
return ec_cdev_ioctl_slave_sdo_entry(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1274 |
case EC_IOCTL_SLAVE_SDO_UPLOAD: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1275 |
return ec_cdev_ioctl_slave_sdo_upload(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1276 |
case EC_IOCTL_SLAVE_SDO_DOWNLOAD: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1277 |
if (!(filp->f_mode & FMODE_WRITE)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1278 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1279 |
return ec_cdev_ioctl_slave_sdo_download(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1280 |
case EC_IOCTL_SLAVE_SII_READ: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1281 |
return ec_cdev_ioctl_slave_sii_read(master, arg); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1282 |
case EC_IOCTL_SLAVE_SII_WRITE: |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1283 |
if (!(filp->f_mode & FMODE_WRITE)) |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1284 |
return -EPERM; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1285 |
return ec_cdev_ioctl_slave_sii_write(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1286 |
case EC_IOCTL_CONFIG: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1287 |
return ec_cdev_ioctl_config(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1288 |
case EC_IOCTL_CONFIG_PDO: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1289 |
return ec_cdev_ioctl_config_pdo(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1290 |
case EC_IOCTL_CONFIG_PDO_ENTRY: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1291 |
return ec_cdev_ioctl_config_pdo_entry(master, arg); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
1292 |
case EC_IOCTL_CONFIG_SDO: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1293 |
return ec_cdev_ioctl_config_sdo(master, arg); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1294 |
default: |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1295 |
return -ENOTTY; |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1296 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1297 |
} |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1298 |
|
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1075
diff
changeset
|
1299 |
/*****************************************************************************/ |