master/master.c
changeset 484 9fde4a17b820
parent 483 1a507e9ab735
child 492 9c58efb2c72d
equal deleted inserted replaced
483:1a507e9ab735 484:9fde4a17b820
   201     if (kobject_set_name(&master->kobj, "ethercat%i", index)) {
   201     if (kobject_set_name(&master->kobj, "ethercat%i", index)) {
   202         EC_ERR("Failed to set kobj name.\n");
   202         EC_ERR("Failed to set kobj name.\n");
   203         kobject_put(&master->kobj);
   203         kobject_put(&master->kobj);
   204         return -1;
   204         return -1;
   205     }
   205     }
       
   206     if (kobject_add(&master->kobj)) {
       
   207         EC_ERR("Failed to add master kobj.\n");
       
   208         kobject_put(&master->kobj);
       
   209         return -1;
       
   210     }
   206 
   211 
   207     return 0;
   212     return 0;
   208 
   213 
   209  out_clear_eoe:
   214  out_clear_eoe:
   210     list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) {
   215     list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) {
  1269     ec_domain_t *domain, *last_domain;
  1274     ec_domain_t *domain, *last_domain;
  1270     unsigned int index;
  1275     unsigned int index;
  1271 
  1276 
  1272     if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) {
  1277     if (!(domain = (ec_domain_t *) kmalloc(sizeof(ec_domain_t), GFP_KERNEL))) {
  1273         EC_ERR("Error allocating domain memory!\n");
  1278         EC_ERR("Error allocating domain memory!\n");
  1274         goto out_return;
  1279         return NULL;
  1275     }
  1280     }
  1276 
  1281 
  1277     if (list_empty(&master->domains)) index = 0;
  1282     if (list_empty(&master->domains)) index = 0;
  1278     else {
  1283     else {
  1279         last_domain = list_entry(master->domains.prev, ec_domain_t, list);
  1284         last_domain = list_entry(master->domains.prev, ec_domain_t, list);
  1280         index = last_domain->index + 1;
  1285         index = last_domain->index + 1;
  1281     }
  1286     }
  1282 
  1287 
  1283     if (ec_domain_init(domain, master, index)) {
  1288     if (ec_domain_init(domain, master, index)) {
  1284         EC_ERR("Failed to init domain.\n");
  1289         EC_ERR("Failed to init domain.\n");
  1285         goto out_return;
  1290         return NULL;
  1286     }
       
  1287 
       
  1288     if (kobject_add(&domain->kobj)) {
       
  1289         EC_ERR("Failed to add domain kobject.\n");
       
  1290         goto out_put;
       
  1291     }
  1291     }
  1292 
  1292 
  1293     list_add_tail(&domain->list, &master->domains);
  1293     list_add_tail(&domain->list, &master->domains);
       
  1294 
  1294     return domain;
  1295     return domain;
  1295 
       
  1296  out_put:
       
  1297     kobject_put(&domain->kobj);
       
  1298  out_return:
       
  1299     return NULL;
       
  1300 }
  1296 }
  1301 
  1297 
  1302 /*****************************************************************************/
  1298 /*****************************************************************************/
  1303 
  1299 
  1304 /**
  1300 /**