46 |
46 |
47 /*****************************************************************************/ |
47 /*****************************************************************************/ |
48 |
48 |
49 /** Time difference [ns] to tolerate without setting a new system time offset. |
49 /** Time difference [ns] to tolerate without setting a new system time offset. |
50 */ |
50 */ |
|
51 #ifdef EC_HAVE_CYCLES |
|
52 #define EC_SYSTEM_TIME_TOLERANCE_NS 10000 |
|
53 #else |
51 #define EC_SYSTEM_TIME_TOLERANCE_NS 100000000 |
54 #define EC_SYSTEM_TIME_TOLERANCE_NS 100000000 |
|
55 #endif |
52 |
56 |
53 /*****************************************************************************/ |
57 /*****************************************************************************/ |
54 |
58 |
55 void ec_fsm_master_state_start(ec_fsm_master_t *); |
59 void ec_fsm_master_state_start(ec_fsm_master_t *); |
56 void ec_fsm_master_state_broadcast(ec_fsm_master_t *); |
60 void ec_fsm_master_state_broadcast(ec_fsm_master_t *); |
79 ec_datagram_t *datagram /**< Datagram object to use. */ |
83 ec_datagram_t *datagram /**< Datagram object to use. */ |
80 ) |
84 ) |
81 { |
85 { |
82 fsm->master = master; |
86 fsm->master = master; |
83 fsm->datagram = datagram; |
87 fsm->datagram = datagram; |
|
88 fsm->mbox = &master->fsm_mbox; |
84 fsm->state = ec_fsm_master_state_start; |
89 fsm->state = ec_fsm_master_state_start; |
85 fsm->idle = 0; |
90 fsm->idle = 0; |
86 fsm->link_state = 0; |
91 fsm->link_state = 0; |
87 fsm->slaves_responding = 0; |
92 fsm->slaves_responding = 0; |
88 fsm->rescan_required = 0; |
93 fsm->rescan_required = 0; |
89 fsm->slave_states = EC_SLAVE_STATE_UNKNOWN; |
94 fsm->slave_states = EC_SLAVE_STATE_UNKNOWN; |
90 |
95 |
91 // init sub-state-machines |
96 // init sub-state-machines |
92 ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram); |
97 ec_fsm_coe_init(&fsm->fsm_coe, fsm->mbox); |
93 ec_fsm_pdo_init(&fsm->fsm_pdo, &fsm->fsm_coe); |
98 ec_fsm_pdo_init(&fsm->fsm_pdo, &fsm->fsm_coe); |
94 ec_fsm_change_init(&fsm->fsm_change, fsm->datagram); |
99 ec_fsm_change_init(&fsm->fsm_change, fsm->datagram); |
95 ec_fsm_slave_config_init(&fsm->fsm_slave_config, fsm->datagram, |
100 ec_fsm_slave_config_init(&fsm->fsm_slave_config, fsm->datagram, |
96 &fsm->fsm_change, &fsm->fsm_coe, &fsm->fsm_pdo); |
101 &fsm->fsm_change, &fsm->fsm_coe, &fsm->fsm_pdo); |
97 ec_fsm_slave_scan_init(&fsm->fsm_slave_scan, fsm->datagram, |
102 ec_fsm_slave_scan_init(&fsm->fsm_slave_scan, fsm->datagram, |
127 */ |
132 */ |
128 int ec_fsm_master_exec( |
133 int ec_fsm_master_exec( |
129 ec_fsm_master_t *fsm /**< Master state machine. */ |
134 ec_fsm_master_t *fsm /**< Master state machine. */ |
130 ) |
135 ) |
131 { |
136 { |
132 if (fsm->datagram->state == EC_DATAGRAM_SENT |
137 if (ec_mbox_is_datagram_state(fsm->mbox,EC_DATAGRAM_QUEUED) |
133 || fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
138 || ec_mbox_is_datagram_state(fsm->mbox,EC_DATAGRAM_SENT)) { |
134 // datagram was not sent or received yet. |
139 // datagram was not sent or received yet. |
135 return 0; |
140 return 0; |
136 } |
141 } |
137 |
|
138 fsm->state(fsm); |
142 fsm->state(fsm); |
139 return 1; |
143 return 1; |
140 } |
144 } |
141 |
145 |
142 /*****************************************************************************/ |
146 /*****************************************************************************/ |
209 |
213 |
210 if (fsm->link_state && !master->main_device.link_state) { // link went down |
214 if (fsm->link_state && !master->main_device.link_state) { // link went down |
211 EC_MASTER_DBG(master, 1, "Master state machine detected " |
215 EC_MASTER_DBG(master, 1, "Master state machine detected " |
212 "link down. Clearing slave list.\n"); |
216 "link down. Clearing slave list.\n"); |
213 |
217 |
214 #ifdef EC_EOE |
|
215 ec_master_eoe_stop(master); |
|
216 ec_master_clear_eoe_handlers(master); |
|
217 #endif |
|
218 ec_master_clear_slaves(master); |
218 ec_master_clear_slaves(master); |
219 fsm->slave_states = 0x00; |
219 fsm->slave_states = 0x00; |
220 } |
220 } |
221 fsm->link_state = master->main_device.link_state; |
221 fsm->link_state = master->main_device.link_state; |
222 |
222 |
236 } else { |
236 } else { |
237 fsm->slave_states = 0x00; |
237 fsm->slave_states = 0x00; |
238 } |
238 } |
239 |
239 |
240 if (fsm->rescan_required) { |
240 if (fsm->rescan_required) { |
241 down(&master->scan_sem); |
241 ec_mutex_lock(&master->scan_mutex); |
242 if (!master->allow_scan) { |
242 if (!master->allow_scan) { |
243 up(&master->scan_sem); |
243 ec_mutex_unlock(&master->scan_mutex); |
244 } else { |
244 } else { |
245 master->scan_busy = 1; |
245 master->scan_busy = 1; |
246 up(&master->scan_sem); |
246 ec_mutex_unlock(&master->scan_mutex); |
247 |
247 |
248 // clear all slaves and scan the bus |
248 // clear all slaves and scan the bus |
249 fsm->rescan_required = 0; |
249 fsm->rescan_required = 0; |
250 fsm->idle = 0; |
250 fsm->idle = 0; |
251 fsm->scan_jiffies = jiffies; |
251 fsm->scan_jiffies = jiffies; |
252 |
252 |
253 #ifdef EC_EOE |
253 #ifdef EC_EOE |
254 ec_master_eoe_stop(master); |
|
255 ec_master_clear_eoe_handlers(master); |
254 ec_master_clear_eoe_handlers(master); |
256 #endif |
255 #endif |
257 ec_master_clear_slaves(master); |
256 ec_master_clear_slaves(master); |
258 |
257 |
259 master->slave_count = fsm->slaves_responding; |
258 master->slave_count = fsm->slaves_responding; |
390 if (request->length > fsm->datagram->mem_size) { |
389 if (request->length > fsm->datagram->mem_size) { |
391 EC_MASTER_ERR(master, "Request length (%zu) exceeds maximum " |
390 EC_MASTER_ERR(master, "Request length (%zu) exceeds maximum " |
392 "datagram size (%zu)!\n", request->length, |
391 "datagram size (%zu)!\n", request->length, |
393 fsm->datagram->mem_size); |
392 fsm->datagram->mem_size); |
394 request->state = EC_INT_REQUEST_FAILURE; |
393 request->state = EC_INT_REQUEST_FAILURE; |
|
394 kref_put(&request->refcount,ec_master_reg_request_release); |
395 wake_up(&master->reg_queue); |
395 wake_up(&master->reg_queue); |
396 continue; |
396 continue; |
397 } |
397 } |
398 |
398 |
399 fsm->reg_request = request; |
399 fsm->reg_request = request; |
569 // Does the slave have to be configured? |
569 // Does the slave have to be configured? |
570 if ((slave->current_state != slave->requested_state |
570 if ((slave->current_state != slave->requested_state |
571 || slave->force_config) && !slave->error_flag) { |
571 || slave->force_config) && !slave->error_flag) { |
572 |
572 |
573 // Start slave configuration, if it is allowed. |
573 // Start slave configuration, if it is allowed. |
574 down(&master->config_sem); |
574 ec_mutex_lock(&master->config_mutex); |
575 if (!master->allow_config) { |
575 if (!master->allow_config) { |
576 up(&master->config_sem); |
576 ec_mutex_unlock(&master->config_mutex); |
577 } else { |
577 } else { |
578 master->config_busy = 1; |
578 master->config_busy = 1; |
579 up(&master->config_sem); |
579 ec_mutex_unlock(&master->config_mutex); |
580 |
580 |
581 if (master->debug_level) { |
581 if (master->debug_level) { |
582 char old_state[EC_STATE_STRING_SIZE], |
582 char old_state[EC_STATE_STRING_SIZE], |
583 new_state[EC_STATE_STRING_SIZE]; |
583 new_state[EC_STATE_STRING_SIZE]; |
584 ec_state_string(slave->current_state, old_state, 0); |
584 ec_state_string(slave->current_state, old_state, 0); |
800 ec_master_calc_dc(master); |
800 ec_master_calc_dc(master); |
801 |
801 |
802 // Attach slave configurations |
802 // Attach slave configurations |
803 ec_master_attach_slave_configs(master); |
803 ec_master_attach_slave_configs(master); |
804 |
804 |
805 #ifdef EC_EOE |
|
806 // check if EoE processing has to be started |
|
807 ec_master_eoe_start(master); |
|
808 #endif |
|
809 |
|
810 if (master->slave_count) { |
805 if (master->slave_count) { |
811 fsm->slave = master->slaves; // begin with first slave |
806 fsm->slave = master->slaves; // begin with first slave |
812 ec_fsm_master_enter_write_system_times(fsm); |
807 ec_fsm_master_enter_write_system_times(fsm); |
813 } else { |
808 } else { |
814 ec_fsm_master_restart(fsm); |
809 ec_fsm_master_restart(fsm); |
887 */ |
882 */ |
888 u64 ec_fsm_master_dc_offset32( |
883 u64 ec_fsm_master_dc_offset32( |
889 ec_fsm_master_t *fsm, /**< Master state machine. */ |
884 ec_fsm_master_t *fsm, /**< Master state machine. */ |
890 u64 system_time, /**< System time register. */ |
885 u64 system_time, /**< System time register. */ |
891 u64 old_offset, /**< Time offset register. */ |
886 u64 old_offset, /**< Time offset register. */ |
892 unsigned long jiffies_since_read /**< Jiffies for correction. */ |
887 u64 correction /**< Correction. */ |
893 ) |
888 ) |
894 { |
889 { |
895 ec_slave_t *slave = fsm->slave; |
890 ec_slave_t *slave = fsm->slave; |
896 u32 correction, system_time32, old_offset32, new_offset; |
891 u32 correction32, system_time32, old_offset32, new_offset; |
897 s32 time_diff; |
892 s32 time_diff; |
898 |
893 |
899 system_time32 = (u32) system_time; |
894 system_time32 = (u32) system_time; |
900 old_offset32 = (u32) old_offset; |
895 // correct read system time by elapsed time between read operation |
901 |
896 // and app_time set time |
902 // correct read system time by elapsed time since read operation |
897 correction32 = (u32)correction; |
903 correction = jiffies_since_read * 1000 / HZ * 1000000; |
898 system_time32 -= correction32; |
904 system_time32 += correction; |
899 old_offset32 = (u32) old_offset; |
905 time_diff = (u32) slave->master->app_time - system_time32; |
900 |
|
901 time_diff = (u32) slave->master->app_start_time - system_time32; |
906 |
902 |
907 EC_SLAVE_DBG(slave, 1, "DC system time offset calculation:" |
903 EC_SLAVE_DBG(slave, 1, "DC system time offset calculation:" |
908 " system_time=%u (corrected with %u)," |
904 " system_time=%u (corrected with %u)," |
909 " app_time=%llu, diff=%i\n", |
905 " app_start_time=%llu, diff=%i\n", |
910 system_time32, correction, |
906 system_time32, correction32, |
911 slave->master->app_time, time_diff); |
907 slave->master->app_start_time, time_diff); |
912 |
908 |
913 if (EC_ABS(time_diff) > EC_SYSTEM_TIME_TOLERANCE_NS) { |
909 if (EC_ABS(time_diff) > EC_SYSTEM_TIME_TOLERANCE_NS) { |
914 new_offset = time_diff + old_offset32; |
910 new_offset = time_diff + old_offset32; |
915 EC_SLAVE_DBG(slave, 1, "Setting time offset to %u (was %u)\n", |
911 EC_SLAVE_DBG(slave, 1, "Setting time offset to %u (was %u)\n", |
916 new_offset, old_offset32); |
912 new_offset, old_offset32); |
927 */ |
923 */ |
928 u64 ec_fsm_master_dc_offset64( |
924 u64 ec_fsm_master_dc_offset64( |
929 ec_fsm_master_t *fsm, /**< Master state machine. */ |
925 ec_fsm_master_t *fsm, /**< Master state machine. */ |
930 u64 system_time, /**< System time register. */ |
926 u64 system_time, /**< System time register. */ |
931 u64 old_offset, /**< Time offset register. */ |
927 u64 old_offset, /**< Time offset register. */ |
932 unsigned long jiffies_since_read /**< Jiffies for correction. */ |
928 u64 correction /**< Correction. */ |
933 ) |
929 ) |
934 { |
930 { |
935 ec_slave_t *slave = fsm->slave; |
931 ec_slave_t *slave = fsm->slave; |
936 u64 new_offset, correction; |
932 u64 new_offset; |
937 s64 time_diff; |
933 s64 time_diff; |
938 |
934 |
939 // correct read system time by elapsed time since read operation |
935 // correct read system time by elapsed time between read operation |
940 correction = (u64) (jiffies_since_read * 1000 / HZ) * 1000000; |
936 // and app_time set time |
941 system_time += correction; |
937 system_time -= correction; |
942 time_diff = fsm->slave->master->app_time - system_time; |
938 time_diff = fsm->slave->master->app_start_time - system_time; |
943 |
939 |
944 EC_SLAVE_DBG(slave, 1, "DC system time offset calculation:" |
940 EC_SLAVE_DBG(slave, 1, "DC system time offset calculation:" |
945 " system_time=%llu (corrected with %llu)," |
941 " system_time=%llu (corrected with %llu)," |
946 " app_time=%llu, diff=%lli\n", |
942 " app_start_time=%llu, diff=%lli\n", |
947 system_time, correction, |
943 system_time, correction, |
948 slave->master->app_time, time_diff); |
944 slave->master->app_start_time, time_diff); |
949 |
945 |
950 if (EC_ABS(time_diff) > EC_SYSTEM_TIME_TOLERANCE_NS) { |
946 if (EC_ABS(time_diff) > EC_SYSTEM_TIME_TOLERANCE_NS) { |
951 new_offset = time_diff + old_offset; |
947 new_offset = time_diff + old_offset; |
952 EC_SLAVE_DBG(slave, 1, "Setting time offset to %llu (was %llu)\n", |
948 EC_SLAVE_DBG(slave, 1, "Setting time offset to %llu (was %llu)\n", |
953 new_offset, old_offset); |
949 new_offset, old_offset); |
967 ec_fsm_master_t *fsm /**< Master state machine. */ |
963 ec_fsm_master_t *fsm /**< Master state machine. */ |
968 ) |
964 ) |
969 { |
965 { |
970 ec_datagram_t *datagram = fsm->datagram; |
966 ec_datagram_t *datagram = fsm->datagram; |
971 ec_slave_t *slave = fsm->slave; |
967 ec_slave_t *slave = fsm->slave; |
972 u64 system_time, old_offset, new_offset; |
968 u64 system_time, old_offset, new_offset, correction; |
973 unsigned long jiffies_since_read; |
|
974 |
969 |
975 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
970 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
976 return; |
971 return; |
977 |
972 |
978 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
973 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
991 return; |
986 return; |
992 } |
987 } |
993 |
988 |
994 system_time = EC_READ_U64(datagram->data); // 0x0910 |
989 system_time = EC_READ_U64(datagram->data); // 0x0910 |
995 old_offset = EC_READ_U64(datagram->data + 16); // 0x0920 |
990 old_offset = EC_READ_U64(datagram->data + 16); // 0x0920 |
996 jiffies_since_read = jiffies - datagram->jiffies_sent; |
991 /* correct read system time by elapsed time since read operation |
|
992 and the app_time set time */ |
|
993 #ifdef EC_HAVE_CYCLES |
|
994 correction = |
|
995 (datagram->cycles_sent - slave->master->dc_cycles_app_start_time) |
|
996 * 1000000LL; |
|
997 do_div(correction,cpu_khz); |
|
998 #else |
|
999 correction = |
|
1000 (u64) ((datagram->jiffies_sent-slave->master->dc_jiffies_app_start_time) * 1000 / HZ) |
|
1001 * 1000000; |
|
1002 #endif |
997 |
1003 |
998 if (slave->base_dc_range == EC_DC_32) { |
1004 if (slave->base_dc_range == EC_DC_32) { |
999 new_offset = ec_fsm_master_dc_offset32(fsm, |
1005 new_offset = ec_fsm_master_dc_offset32(fsm, |
1000 system_time, old_offset, jiffies_since_read); |
1006 system_time, old_offset, correction); |
1001 } else { |
1007 } else { |
1002 new_offset = ec_fsm_master_dc_offset64(fsm, |
1008 new_offset = ec_fsm_master_dc_offset64(fsm, |
1003 system_time, old_offset, jiffies_since_read); |
1009 system_time, old_offset, correction); |
1004 } |
1010 } |
1005 |
1011 |
1006 // set DC system time offset and transmission delay |
1012 // set DC system time offset and transmission delay |
1007 ec_datagram_fpwr(datagram, slave->station_address, 0x0920, 12); |
1013 ec_datagram_fpwr(datagram, slave->station_address, 0x0920, 12); |
1008 EC_WRITE_U64(datagram->data, new_offset); |
1014 EC_WRITE_U64(datagram->data, new_offset); |
1061 if (ec_fsm_sii_exec(&fsm->fsm_sii)) return; |
1067 if (ec_fsm_sii_exec(&fsm->fsm_sii)) return; |
1062 |
1068 |
1063 if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
1069 if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
1064 EC_SLAVE_ERR(slave, "Failed to write SII data.\n"); |
1070 EC_SLAVE_ERR(slave, "Failed to write SII data.\n"); |
1065 request->state = EC_INT_REQUEST_FAILURE; |
1071 request->state = EC_INT_REQUEST_FAILURE; |
|
1072 kref_put(&request->refcount,ec_master_sii_write_request_release); |
1066 wake_up(&master->sii_queue); |
1073 wake_up(&master->sii_queue); |
1067 ec_fsm_master_restart(fsm); |
1074 ec_fsm_master_restart(fsm); |
1068 return; |
1075 return; |
1069 } |
1076 } |
1070 |
1077 |
1089 slave->effective_alias = slave->sii.alias; |
1096 slave->effective_alias = slave->sii.alias; |
1090 } |
1097 } |
1091 // TODO: Evaluate other SII contents! |
1098 // TODO: Evaluate other SII contents! |
1092 |
1099 |
1093 request->state = EC_INT_REQUEST_SUCCESS; |
1100 request->state = EC_INT_REQUEST_SUCCESS; |
|
1101 kref_put(&request->refcount,ec_master_sii_write_request_release); |
1094 wake_up(&master->sii_queue); |
1102 wake_up(&master->sii_queue); |
1095 |
1103 |
1096 // check for another SII write request |
1104 // check for another SII write request |
1097 if (ec_fsm_master_action_process_sii(fsm)) |
1105 if (ec_fsm_master_action_process_sii(fsm)) |
1098 return; // processing another request |
1106 return; // processing another request |
1182 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1190 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
1183 EC_MASTER_ERR(master, "Failed to receive register" |
1191 EC_MASTER_ERR(master, "Failed to receive register" |
1184 " request datagram: "); |
1192 " request datagram: "); |
1185 ec_datagram_print_state(datagram); |
1193 ec_datagram_print_state(datagram); |
1186 request->state = EC_INT_REQUEST_FAILURE; |
1194 request->state = EC_INT_REQUEST_FAILURE; |
|
1195 kref_put(&request->refcount,ec_master_reg_request_release); |
1187 wake_up(&master->reg_queue); |
1196 wake_up(&master->reg_queue); |
1188 ec_fsm_master_restart(fsm); |
1197 ec_fsm_master_restart(fsm); |
1189 return; |
1198 return; |
1190 } |
1199 } |
1191 |
1200 |
1196 request->data = kmalloc(request->length, GFP_KERNEL); |
1205 request->data = kmalloc(request->length, GFP_KERNEL); |
1197 if (!request->data) { |
1206 if (!request->data) { |
1198 EC_MASTER_ERR(master, "Failed to allocate %zu bytes" |
1207 EC_MASTER_ERR(master, "Failed to allocate %zu bytes" |
1199 " of memory for register data.\n", request->length); |
1208 " of memory for register data.\n", request->length); |
1200 request->state = EC_INT_REQUEST_FAILURE; |
1209 request->state = EC_INT_REQUEST_FAILURE; |
|
1210 kref_put(&request->refcount,ec_master_reg_request_release); |
1201 wake_up(&master->reg_queue); |
1211 wake_up(&master->reg_queue); |
1202 ec_fsm_master_restart(fsm); |
1212 ec_fsm_master_restart(fsm); |
1203 return; |
1213 return; |
1204 } |
1214 } |
1205 memcpy(request->data, datagram->data, request->length); |
1215 memcpy(request->data, datagram->data, request->length); |
1210 } else { |
1220 } else { |
1211 request->state = EC_INT_REQUEST_FAILURE; |
1221 request->state = EC_INT_REQUEST_FAILURE; |
1212 EC_MASTER_ERR(master, "Register request failed.\n"); |
1222 EC_MASTER_ERR(master, "Register request failed.\n"); |
1213 } |
1223 } |
1214 |
1224 |
|
1225 kref_put(&request->refcount,ec_master_reg_request_release); |
1215 wake_up(&master->reg_queue); |
1226 wake_up(&master->reg_queue); |
1216 |
1227 |
1217 // check for another register request |
1228 // check for another register request |
1218 if (ec_fsm_master_action_process_register(fsm)) |
1229 if (ec_fsm_master_action_process_register(fsm)) |
1219 return; // processing another request |
1230 return; // processing another request |
1220 |
1231 |
1221 ec_fsm_master_restart(fsm); |
1232 ec_fsm_master_restart(fsm); |
1222 } |
1233 } |
1223 |
1234 |
1224 /*****************************************************************************/ |
1235 /*****************************************************************************/ |
|
1236 |
|
1237 /** called by kref_put if the SII write request's refcount becomes zero. |
|
1238 * |
|
1239 */ |
|
1240 void ec_master_sii_write_request_release(struct kref *ref) |
|
1241 { |
|
1242 ec_sii_write_request_t *request = container_of(ref, ec_sii_write_request_t, refcount); |
|
1243 if (request->slave) |
|
1244 EC_SLAVE_DBG(request->slave, 1, "Releasing SII write request %p.\n",request); |
|
1245 kfree(request->words); |
|
1246 kfree(request); |
|
1247 } |
|
1248 |
|
1249 /*****************************************************************************/ |
|
1250 |
|
1251 /** called by kref_put if the reg request's refcount becomes zero. |
|
1252 * |
|
1253 */ |
|
1254 void ec_master_reg_request_release(struct kref *ref) |
|
1255 { |
|
1256 ec_reg_request_t *request = container_of(ref, ec_reg_request_t, refcount); |
|
1257 if (request->slave) |
|
1258 EC_SLAVE_DBG(request->slave, 1, "Releasing reg request %p.\n",request); |
|
1259 if (request->data) |
|
1260 kfree(request->data); |
|
1261 kfree(request); |
|
1262 } |
|
1263 |
|
1264 /*****************************************************************************/ |
|
1265 |
|
1266 /** called by kref_put if the SDO request's refcount becomes zero. |
|
1267 * |
|
1268 */ |
|
1269 void ec_master_sdo_request_release(struct kref *ref) |
|
1270 { |
|
1271 ec_master_sdo_request_t *request = container_of(ref, ec_master_sdo_request_t, refcount); |
|
1272 if (request->slave) |
|
1273 EC_SLAVE_DBG(request->slave, 1, "Releasing SDO request %p.\n",request); |
|
1274 ec_sdo_request_clear(&request->req); |
|
1275 kfree(request); |
|
1276 } |
|
1277 |
|
1278 /*****************************************************************************/ |
|
1279 |
|
1280 /** called by kref_put if the FoE request's refcount becomes zero. |
|
1281 * |
|
1282 */ |
|
1283 void ec_master_foe_request_release(struct kref *ref) |
|
1284 { |
|
1285 ec_master_foe_request_t *request = container_of(ref, ec_master_foe_request_t, refcount); |
|
1286 if (request->slave) |
|
1287 EC_SLAVE_DBG(request->slave, 1, "Releasing FoE request %p.\n",request); |
|
1288 ec_foe_request_clear(&request->req); |
|
1289 kfree(request); |
|
1290 } |
|
1291 |
|
1292 /*****************************************************************************/ |
|
1293 |
|
1294 /** called by kref_put if the SoE request's refcount becomes zero. |
|
1295 * |
|
1296 */ |
|
1297 void ec_master_soe_request_release(struct kref *ref) |
|
1298 { |
|
1299 ec_master_soe_request_t *request = container_of(ref, ec_master_soe_request_t, refcount); |
|
1300 if (request->slave) |
|
1301 EC_SLAVE_DBG(request->slave, 1, "Releasing SoE request %p.\n",request); |
|
1302 ec_soe_request_clear(&request->req); |
|
1303 kfree(request); |
|
1304 } |