63 static int ec_master_operation_thread(ec_master_t *); |
63 static int ec_master_operation_thread(ec_master_t *); |
64 #ifdef EC_EOE |
64 #ifdef EC_EOE |
65 void ec_master_eoe_run(unsigned long); |
65 void ec_master_eoe_run(unsigned long); |
66 #endif |
66 #endif |
67 ssize_t ec_show_master_attribute(struct kobject *, struct attribute *, char *); |
67 ssize_t ec_show_master_attribute(struct kobject *, struct attribute *, char *); |
68 ssize_t ec_store_master_attribute(struct kobject *, struct attribute *, |
|
69 const char *, size_t); |
|
70 |
68 |
71 /*****************************************************************************/ |
69 /*****************************************************************************/ |
72 |
70 |
73 /** \cond */ |
71 /** \cond */ |
74 |
72 |
75 EC_SYSFS_READ_ATTR(info); |
73 EC_SYSFS_READ_ATTR(info); |
76 EC_SYSFS_READ_WRITE_ATTR(debug_level); |
|
77 |
74 |
78 static struct attribute *ec_def_attrs[] = { |
75 static struct attribute *ec_def_attrs[] = { |
79 &attr_info, |
76 &attr_info, |
80 &attr_debug_level, |
|
81 NULL, |
77 NULL, |
82 }; |
78 }; |
83 |
79 |
84 static struct sysfs_ops ec_sysfs_ops = { |
80 static struct sysfs_ops ec_sysfs_ops = { |
85 .show = &ec_show_master_attribute, |
81 .show = &ec_show_master_attribute, |
86 .store = ec_store_master_attribute |
|
87 }; |
82 }; |
88 |
83 |
89 static struct kobj_type ktype_ec_master = { |
84 static struct kobj_type ktype_ec_master = { |
90 .release = NULL, |
85 .release = NULL, |
91 .sysfs_ops = &ec_sysfs_ops, |
86 .sysfs_ops = &ec_sysfs_ops, |
1083 ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
1078 ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
1084 |
1079 |
1085 if (attr == &attr_info) { |
1080 if (attr == &attr_info) { |
1086 return ec_master_info(master, buffer); |
1081 return ec_master_info(master, buffer); |
1087 } |
1082 } |
1088 else if (attr == &attr_debug_level) { |
|
1089 return sprintf(buffer, "%i\n", master->debug_level); |
|
1090 } |
|
1091 |
1083 |
1092 return 0; |
1084 return 0; |
1093 } |
|
1094 |
|
1095 /*****************************************************************************/ |
|
1096 |
|
1097 /** |
|
1098 Formats attribute data for SysFS write access. |
|
1099 \return number of bytes processed, or negative error code |
|
1100 */ |
|
1101 |
|
1102 ssize_t ec_store_master_attribute(struct kobject *kobj, /**< slave's kobject */ |
|
1103 struct attribute *attr, /**< attribute */ |
|
1104 const char *buffer, /**< memory with data */ |
|
1105 size_t size /**< size of data to store */ |
|
1106 ) |
|
1107 { |
|
1108 ec_master_t *master = container_of(kobj, ec_master_t, kobj); |
|
1109 |
|
1110 if (attr == &attr_debug_level) { |
|
1111 if (!strcmp(buffer, "0\n")) { |
|
1112 master->debug_level = 0; |
|
1113 } |
|
1114 else if (!strcmp(buffer, "1\n")) { |
|
1115 master->debug_level = 1; |
|
1116 } |
|
1117 else if (!strcmp(buffer, "2\n")) { |
|
1118 master->debug_level = 2; |
|
1119 } |
|
1120 else { |
|
1121 EC_ERR("Invalid debug level value!\n"); |
|
1122 return -EINVAL; |
|
1123 } |
|
1124 |
|
1125 EC_INFO("Master debug level set to %i.\n", master->debug_level); |
|
1126 return size; |
|
1127 } |
|
1128 |
|
1129 return -EINVAL; |
|
1130 } |
1085 } |
1131 |
1086 |
1132 /*****************************************************************************/ |
1087 /*****************************************************************************/ |
1133 |
1088 |
1134 #ifdef EC_EOE |
1089 #ifdef EC_EOE |
1337 } |
1292 } |
1338 |
1293 |
1339 return NULL; |
1294 return NULL; |
1340 } |
1295 } |
1341 |
1296 |
|
1297 /*****************************************************************************/ |
|
1298 |
|
1299 int ec_master_debug_level( |
|
1300 ec_master_t *master, |
|
1301 int level |
|
1302 ) |
|
1303 { |
|
1304 if (level < 0 || level > 2) { |
|
1305 EC_ERR("Invalid debug level %i!\n", level); |
|
1306 return -1; |
|
1307 } |
|
1308 |
|
1309 if (level != master->debug_level) { |
|
1310 master->debug_level = level; |
|
1311 EC_INFO("Master debug level set to %i.\n", master->debug_level); |
|
1312 } |
|
1313 |
|
1314 return 0; |
|
1315 } |
|
1316 |
1342 /****************************************************************************** |
1317 /****************************************************************************** |
1343 * Realtime interface |
1318 * Realtime interface |
1344 *****************************************************************************/ |
1319 *****************************************************************************/ |
1345 |
1320 |
1346 ec_domain_t *ecrt_master_create_domain(ec_master_t *master /**< master */) |
1321 ec_domain_t *ecrt_master_create_domain(ec_master_t *master /**< master */) |