author | Florian Pose <fp@igh-essen.com> |
Wed, 04 Jun 2008 10:41:50 +0000 | |
changeset 949 | e424c0074c67 |
parent 847 | 92266462d411 |
child 962 | ea83a7aab57a |
permissions | -rw-r--r-- |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
36 |
CANopen Sdo functions. |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
430
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
419
diff
changeset
|
43 |
#include "master.h" |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
45 |
#include "sdo.h" |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
46 |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
ssize_t ec_show_sdo_attribute(struct kobject *, struct attribute *, char *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
void ec_sdo_clear(struct kobject *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
/** \cond */ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
EC_SYSFS_READ_ATTR(info); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
static struct attribute *sdo_def_attrs[] = { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
&attr_info, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
NULL, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
}; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
static struct sysfs_ops sdo_sysfs_ops = { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
.show = &ec_show_sdo_attribute, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
.store = NULL |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
}; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
static struct kobj_type ktype_ec_sdo = { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
.release = ec_sdo_clear, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
.sysfs_ops = &sdo_sysfs_ops, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
.default_attrs = sdo_def_attrs |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
}; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
/** \endcond */ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
78 |
/** Sdo constructor. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
79 |
* |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
80 |
* \todo Turn parameters. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
81 |
*/ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
82 |
int ec_sdo_init( |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
83 |
ec_sdo_t *sdo, /**< Sdo. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
84 |
uint16_t index, /**< Sdo index. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
85 |
ec_slave_t *slave /**< Parent slave. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
86 |
) |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
{ |
430
74754f45d5fa
Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents:
419
diff
changeset
|
88 |
sdo->slave = slave; |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
sdo->index = index; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
sdo->object_code = 0x00; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
sdo->name = NULL; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
sdo->subindices = 0; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
INIT_LIST_HEAD(&sdo->entries); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
95 |
// Init kobject and add it to the hierarchy |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
memset(&sdo->kobj, 0x00, sizeof(struct kobject)); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
kobject_init(&sdo->kobj); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
sdo->kobj.ktype = &ktype_ec_sdo; |
419
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
409
diff
changeset
|
99 |
sdo->kobj.parent = &slave->sdo_kobj; |
cf724fc82a00
Moved SDO dictionary fetching to master FSMs; added SDO parent kobj.
Florian Pose <fp@igh-essen.com>
parents:
409
diff
changeset
|
100 |
if (kobject_set_name(&sdo->kobj, "%4X", sdo->index)) { |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
EC_ERR("Failed to set kobj name.\n"); |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
102 |
kobject_put(&sdo->kobj); |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
103 |
return -1; |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
104 |
} |
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
105 |
if (kobject_add(&sdo->kobj)) { |
814 | 106 |
EC_ERR("Failed to add Sdo kobject.\n"); |
484
9fde4a17b820
kobject_add() in constructors.
Florian Pose <fp@igh-essen.com>
parents:
448
diff
changeset
|
107 |
kobject_put(&sdo->kobj); |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
return -1; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
return 0; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
116 |
/** Sdo destructor. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
117 |
* |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
118 |
* Clears and frees an Sdo object. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
119 |
*/ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
120 |
void ec_sdo_destroy( |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
121 |
ec_sdo_t *sdo /**< Sdo. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
122 |
) |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
123 |
{ |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
ec_sdo_entry_t *entry, *next; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
// free all entries |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
list_for_each_entry_safe(entry, next, &sdo->entries, list) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
list_del(&entry->list); |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
129 |
ec_sdo_entry_destroy(entry); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
130 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
131 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
132 |
// destroy self |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
133 |
kobject_del(&sdo->kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
134 |
kobject_put(&sdo->kobj); |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
135 |
} |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
136 |
|
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
137 |
/*****************************************************************************/ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
138 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
139 |
/** Clear and free Sdo. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
140 |
* |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
141 |
* This method is called by the kobject, |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
142 |
* once there are no more references to it. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
143 |
*/ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
144 |
void ec_sdo_clear( |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
145 |
struct kobject *kobj /**< Sdo's kobject. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
146 |
) |
448
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
147 |
{ |
e4b76dc7910c
FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents:
441
diff
changeset
|
148 |
ec_sdo_t *sdo = container_of(kobj, ec_sdo_t, kobj); |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
if (sdo->name) kfree(sdo->name); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
kfree(sdo); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
157 |
/** Get and Sdo entry from an Sdo via its subindex. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
158 |
* |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
159 |
* \retval >0 Pointer to the requested Sdo entry. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
160 |
* \retval NULL Sdo entry not found. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
161 |
*/ |
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
162 |
ec_sdo_entry_t *ec_sdo_get_entry( |
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
163 |
ec_sdo_t *sdo, /**< Sdo. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
164 |
uint8_t subindex /**< Entry subindex. */ |
740
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
165 |
) |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
166 |
{ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
167 |
ec_sdo_entry_t *entry; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
168 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
169 |
list_for_each_entry(entry, &sdo->entries, list) { |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
170 |
if (entry->subindex != subindex) continue; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
171 |
return entry; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
172 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
173 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
174 |
return NULL; |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
175 |
} |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
176 |
|
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
177 |
/*****************************************************************************/ |
68d83b45dfa2
Added ec_slave_get_sdo() and ec_sdo_get_entry().
Florian Pose <fp@igh-essen.com>
parents:
739
diff
changeset
|
178 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
179 |
/** Print Sdo information to a buffer. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
180 |
* |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
740
diff
changeset
|
181 |
* /return size of bytes written to buffer. |
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
740
diff
changeset
|
182 |
*/ |
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
183 |
ssize_t ec_sdo_info( |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
184 |
ec_sdo_t *sdo, /**< Sdo. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
185 |
char *buffer /**< Target buffer. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
186 |
) |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
off_t off = 0; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
off += sprintf(buffer + off, "Index: 0x%04X\n", sdo->index); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
off += sprintf(buffer + off, "Name: %s\n", sdo->name ? sdo->name : ""); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
off += sprintf(buffer + off, "Subindices: %i\n", sdo->subindices); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
return off; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
|
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
199 |
/** Show a Sysfs attribute of an Sdo. |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
200 |
* |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
201 |
* /return Number of bytes written to buffer. |
758
8fa6f825eb7d
Updated Doxygen documentation.
Florian Pose <fp@igh-essen.com>
parents:
740
diff
changeset
|
202 |
*/ |
847
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
203 |
ssize_t ec_show_sdo_attribute( |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
204 |
struct kobject *kobj, /**< kobject */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
205 |
struct attribute *attr, /**< Requested attribute. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
206 |
char *buffer /**< Buffer to write the data in. */ |
92266462d411
Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
207 |
) |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
ec_sdo_t *sdo = container_of(kobj, ec_sdo_t, kobj); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
if (attr == &attr_info) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
return ec_sdo_info(sdo, buffer); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
return 0; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
/*****************************************************************************/ |