113 } |
113 } |
114 |
114 |
115 class = class_create(THIS_MODULE, "EtherCAT"); |
115 class = class_create(THIS_MODULE, "EtherCAT"); |
116 if (IS_ERR(class)) { |
116 if (IS_ERR(class)) { |
117 EC_ERR("Failed to create device class.\n"); |
117 EC_ERR("Failed to create device class.\n"); |
|
118 ret = PTR_ERR(class); |
118 goto out_cdev; |
119 goto out_cdev; |
119 } |
120 } |
120 |
121 |
121 // zero MAC addresses |
122 // zero MAC addresses |
122 memset(macs, 0x00, sizeof(uint8_t) * MAX_MASTERS * 2 * ETH_ALEN); |
123 memset(macs, 0x00, sizeof(uint8_t) * MAX_MASTERS * 2 * ETH_ALEN); |
123 |
124 |
124 // process MAC parameters |
125 // process MAC parameters |
125 for (i = 0; i < master_count; i++) { |
126 for (i = 0; i < master_count; i++) { |
126 if (ec_mac_parse(macs[i][0], main_devices[i], 0)) { |
127 ret = ec_mac_parse(macs[i][0], main_devices[i], 0); |
127 ret = -EINVAL; |
128 if (ret) |
128 goto out_class; |
129 goto out_class; |
129 } |
|
130 |
130 |
131 if (i < backup_count && ec_mac_parse(macs[i][1], backup_devices[i], 1)) { |
131 if (i < backup_count) { |
132 ret = -EINVAL; |
132 ret = ec_mac_parse(macs[i][1], backup_devices[i], 1); |
133 goto out_class; |
133 if (ret) |
|
134 goto out_class; |
134 } |
135 } |
135 } |
136 } |
136 |
137 |
137 // initialize static master variables |
138 // initialize static master variables |
138 ec_master_init_static(); |
139 ec_master_init_static(); |
145 goto out_class; |
146 goto out_class; |
146 } |
147 } |
147 } |
148 } |
148 |
149 |
149 for (i = 0; i < master_count; i++) { |
150 for (i = 0; i < master_count; i++) { |
150 if (ec_master_init(&masters[i], i, macs[i][0], macs[i][1], |
151 ret = ec_master_init(&masters[i], i, macs[i][0], macs[i][1], |
151 device_number, class)) { |
152 device_number, class); |
152 ret = -ENOMEM; |
153 if (ret) |
153 goto out_free_masters; |
154 goto out_free_masters; |
154 } |
|
155 } |
155 } |
156 |
156 |
157 EC_INFO("%u master%s waiting for devices.\n", |
157 EC_INFO("%u master%s waiting for devices.\n", |
158 master_count, (master_count == 1 ? "" : "s")); |
158 master_count, (master_count == 1 ? "" : "s")); |
159 return ret; |
159 return ret; |