00001 /****************************************************************************** 00002 * 00003 * $Id$ 00004 * 00005 * Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH 00006 * 00007 * This file is part of the IgH EtherCAT Master. 00008 * 00009 * The IgH EtherCAT Master is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License version 2, as 00011 * published by the Free Software Foundation. 00012 * 00013 * The IgH EtherCAT Master is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 00016 * Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with the IgH EtherCAT Master; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 * --- 00023 * 00024 * The license mentioned above concerns the source code only. Using the 00025 * EtherCAT technology and brand is only permitted in compliance with the 00026 * industrial property and similar rights of Beckhoff Automation GmbH. 00027 * 00028 *****************************************************************************/ 00029 00035 /*****************************************************************************/ 00036 00037 #include <linux/slab.h> 00038 00039 #include "master.h" 00040 00041 #include "sdo.h" 00042 00043 /*****************************************************************************/ 00044 00047 void ec_sdo_init( 00048 ec_sdo_t *sdo, 00049 ec_slave_t *slave, 00050 uint16_t index 00051 ) 00052 { 00053 sdo->slave = slave; 00054 sdo->index = index; 00055 sdo->object_code = 0x00; 00056 sdo->name = NULL; 00057 sdo->max_subindex = 0; 00058 INIT_LIST_HEAD(&sdo->entries); 00059 } 00060 00061 /*****************************************************************************/ 00062 00067 void ec_sdo_clear( 00068 ec_sdo_t *sdo 00069 ) 00070 { 00071 ec_sdo_entry_t *entry, *next; 00072 00073 // free all entries 00074 list_for_each_entry_safe(entry, next, &sdo->entries, list) { 00075 list_del(&entry->list); 00076 ec_sdo_entry_clear(entry); 00077 kfree(entry); 00078 } 00079 00080 if (sdo->name) 00081 kfree(sdo->name); 00082 } 00083 00084 /*****************************************************************************/ 00085 00091 ec_sdo_entry_t *ec_sdo_get_entry( 00092 ec_sdo_t *sdo, 00093 uint8_t subindex 00094 ) 00095 { 00096 ec_sdo_entry_t *entry; 00097 00098 list_for_each_entry(entry, &sdo->entries, list) { 00099 if (entry->subindex != subindex) 00100 continue; 00101 return entry; 00102 } 00103 00104 return NULL; 00105 } 00106 00107 /*****************************************************************************/ 00108 00116 const ec_sdo_entry_t *ec_sdo_get_entry_const( 00117 const ec_sdo_t *sdo, 00118 uint8_t subindex 00119 ) 00120 { 00121 const ec_sdo_entry_t *entry; 00122 00123 list_for_each_entry(entry, &sdo->entries, list) { 00124 if (entry->subindex != subindex) 00125 continue; 00126 return entry; 00127 } 00128 00129 return NULL; 00130 } 00131 00132 /*****************************************************************************/
1.5.6