1285 |
1285 |
1286 /*****************************************************************************/ |
1286 /*****************************************************************************/ |
1287 |
1287 |
1288 ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, |
1288 ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, |
1289 uint16_t alias, uint16_t position, uint32_t vendor_id, |
1289 uint16_t alias, uint16_t position, uint32_t vendor_id, |
1290 uint32_t product_code, uint32_t revision_number) |
1290 uint32_t product_code) |
1291 { |
1291 { |
1292 ec_slave_config_t *sc; |
1292 ec_slave_config_t *sc; |
1293 unsigned int found = 0; |
1293 unsigned int found = 0; |
1294 |
1294 |
1295 list_for_each_entry(sc, &master->configs, list) { |
1295 list_for_each_entry(sc, &master->configs, list) { |
1302 if (found) { |
1302 if (found) { |
1303 if (master->debug_level) { |
1303 if (master->debug_level) { |
1304 EC_INFO("Using existing slave configuration for %u:%u\n", |
1304 EC_INFO("Using existing slave configuration for %u:%u\n", |
1305 alias, position); |
1305 alias, position); |
1306 } |
1306 } |
1307 if (sc->vendor_id != vendor_id |
1307 if (sc->vendor_id != vendor_id || sc->product_code != product_code) { |
1308 || sc->product_code != product_code |
|
1309 || sc->revision_number != revision_number) { |
|
1310 EC_ERR("Slave type mismatch. Slave was configured as" |
1308 EC_ERR("Slave type mismatch. Slave was configured as" |
1311 " 0x%08X/0x%08X/0x%08X before. Now configuring with" |
1309 " 0x%08X/0x%08X before. Now configuring with" |
1312 " 0x%08X/0x%08X/0x%08X.\n", |
1310 " 0x%08X/0x%08X.\n", sc->vendor_id, sc->product_code, |
1313 sc->vendor_id, sc->product_code, sc->revision_number, |
1311 vendor_id, product_code); |
1314 vendor_id, product_code, revision_number); |
|
1315 return NULL; |
1312 return NULL; |
1316 } |
1313 } |
1317 } else { |
1314 } else { |
1318 if (master->debug_level) { |
1315 if (master->debug_level) { |
1319 EC_INFO("Creating slave configuration for %u:%u," |
1316 EC_INFO("Creating slave configuration for %u:%u," |
1320 " 0x%08X/0x%08X/0x%08X.\n", alias, position, |
1317 " 0x%08X/0x%08X.\n", alias, position, vendor_id, |
1321 vendor_id, product_code, revision_number); |
1318 product_code); |
1322 } |
1319 } |
1323 |
1320 |
1324 if (!(sc = (ec_slave_config_t *) kmalloc(sizeof(ec_slave_config_t), |
1321 if (!(sc = (ec_slave_config_t *) kmalloc(sizeof(ec_slave_config_t), |
1325 GFP_KERNEL))) { |
1322 GFP_KERNEL))) { |
1326 EC_ERR("Failed to allocate memory for slave configuration.\n"); |
1323 EC_ERR("Failed to allocate memory for slave configuration.\n"); |
1327 return NULL; |
1324 return NULL; |
1328 } |
1325 } |
1329 |
1326 |
1330 ec_slave_config_init(sc, master, |
1327 ec_slave_config_init(sc, master, |
1331 alias, position, vendor_id, product_code, revision_number); |
1328 alias, position, vendor_id, product_code); |
1332 |
1329 |
1333 // try to find the addressed slave |
1330 // try to find the addressed slave |
1334 ec_slave_config_attach(sc); |
1331 ec_slave_config_attach(sc); |
1335 ec_slave_config_load_default_assignment(sc); |
1332 ec_slave_config_load_default_assignment(sc); |
1336 |
1333 |