aboutsummaryrefslogtreecommitdiffstats
path: root/net/caif/cfcnfg.c
diff options
context:
space:
mode:
authorsjur.brandeland@stericsson.com <sjur.brandeland@stericsson.com>2011-11-30 04:22:47 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-30 23:30:48 -0500
commit7c18d2205ea76eef9674e59e1ecae4f332a53e9e (patch)
tree2d6ed4be50e52408b8806ca67f0bd6fb15362efa /net/caif/cfcnfg.c
parent200c5a3b387c415e49639ee0f6de37804522b745 (diff)
caif: Restructure how link caif link layer enroll
Enrolling CAIF link layers are refactored. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/caif/cfcnfg.c')
-rw-r--r--net/caif/cfcnfg.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
index 00523ecc4ced..598aafb4cb51 100644
--- a/net/caif/cfcnfg.c
+++ b/net/caif/cfcnfg.c
@@ -45,8 +45,8 @@ struct cfcnfg_phyinfo {
45 /* Interface index */ 45 /* Interface index */
46 int ifindex; 46 int ifindex;
47 47
48 /* Use Start of frame extension */ 48 /* Protocol head room added for CAIF link layer */
49 bool use_stx; 49 int head_room;
50 50
51 /* Use Start of frame checksum */ 51 /* Use Start of frame checksum */
52 bool use_fcs; 52 bool use_fcs;
@@ -187,11 +187,11 @@ int caif_disconnect_client(struct net *net, struct cflayer *adap_layer)
187 if (channel_id != 0) { 187 if (channel_id != 0) {
188 struct cflayer *servl; 188 struct cflayer *servl;
189 servl = cfmuxl_remove_uplayer(cfg->mux, channel_id); 189 servl = cfmuxl_remove_uplayer(cfg->mux, channel_id);
190 cfctrl_linkdown_req(cfg->ctrl, channel_id, adap_layer);
190 if (servl != NULL) 191 if (servl != NULL)
191 layer_set_up(servl, NULL); 192 layer_set_up(servl, NULL);
192 } else 193 } else
193 pr_debug("nothing to disconnect\n"); 194 pr_debug("nothing to disconnect\n");
194 cfctrl_linkdown_req(cfg->ctrl, channel_id, adap_layer);
195 195
196 /* Do RCU sync before initiating cleanup */ 196 /* Do RCU sync before initiating cleanup */
197 synchronize_rcu(); 197 synchronize_rcu();
@@ -350,9 +350,7 @@ int caif_connect_client(struct net *net, struct caif_connect_request *conn_req,
350 350
351 *ifindex = phy->ifindex; 351 *ifindex = phy->ifindex;
352 *proto_tail = 2; 352 *proto_tail = 2;
353 *proto_head = 353 *proto_head = protohead[param.linktype] + phy->head_room;
354
355 protohead[param.linktype] + (phy->use_stx ? 1 : 0);
356 354
357 rcu_read_unlock(); 355 rcu_read_unlock();
358 356
@@ -460,13 +458,13 @@ unlock:
460} 458}
461 459
462void 460void
463cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, 461cfcnfg_add_phy_layer(struct cfcnfg *cnfg,
464 struct net_device *dev, struct cflayer *phy_layer, 462 struct net_device *dev, struct cflayer *phy_layer,
465 enum cfcnfg_phy_preference pref, 463 enum cfcnfg_phy_preference pref,
466 bool fcs, bool stx) 464 struct cflayer *link_support,
465 bool fcs, int head_room)
467{ 466{
468 struct cflayer *frml; 467 struct cflayer *frml;
469 struct cflayer *phy_driver = NULL;
470 struct cfcnfg_phyinfo *phyinfo = NULL; 468 struct cfcnfg_phyinfo *phyinfo = NULL;
471 int i; 469 int i;
472 u8 phyid; 470 u8 phyid;
@@ -482,26 +480,13 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
482 goto got_phyid; 480 goto got_phyid;
483 } 481 }
484 pr_warn("Too many CAIF Link Layers (max 6)\n"); 482 pr_warn("Too many CAIF Link Layers (max 6)\n");
485 goto out_err; 483 goto out;
486 484
487got_phyid: 485got_phyid:
488 phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC); 486 phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC);
489 if (!phyinfo) 487 if (!phyinfo)
490 goto out_err; 488 goto out_err;
491 489
492 switch (phy_type) {
493 case CFPHYTYPE_FRAG:
494 phy_driver =
495 cfserl_create(CFPHYTYPE_FRAG, phyid, stx);
496 if (!phy_driver)
497 goto out_err;
498 break;
499 case CFPHYTYPE_CAIF:
500 phy_driver = NULL;
501 break;
502 default:
503 goto out_err;
504 }
505 phy_layer->id = phyid; 490 phy_layer->id = phyid;
506 phyinfo->pref = pref; 491 phyinfo->pref = pref;
507 phyinfo->id = phyid; 492 phyinfo->id = phyid;
@@ -509,7 +494,7 @@ got_phyid:
509 phyinfo->dev_info.dev = dev; 494 phyinfo->dev_info.dev = dev;
510 phyinfo->phy_layer = phy_layer; 495 phyinfo->phy_layer = phy_layer;
511 phyinfo->ifindex = dev->ifindex; 496 phyinfo->ifindex = dev->ifindex;
512 phyinfo->use_stx = stx; 497 phyinfo->head_room = head_room;
513 phyinfo->use_fcs = fcs; 498 phyinfo->use_fcs = fcs;
514 499
515 frml = cffrml_create(phyid, fcs); 500 frml = cffrml_create(phyid, fcs);
@@ -519,23 +504,23 @@ got_phyid:
519 phyinfo->frm_layer = frml; 504 phyinfo->frm_layer = frml;
520 layer_set_up(frml, cnfg->mux); 505 layer_set_up(frml, cnfg->mux);
521 506
522 if (phy_driver != NULL) { 507 if (link_support != NULL) {
523 phy_driver->id = phyid; 508 link_support->id = phyid;
524 layer_set_dn(frml, phy_driver); 509 layer_set_dn(frml, link_support);
525 layer_set_up(phy_driver, frml); 510 layer_set_up(link_support, frml);
526 layer_set_dn(phy_driver, phy_layer); 511 layer_set_dn(link_support, phy_layer);
527 layer_set_up(phy_layer, phy_driver); 512 layer_set_up(phy_layer, link_support);
528 } else { 513 } else {
529 layer_set_dn(frml, phy_layer); 514 layer_set_dn(frml, phy_layer);
530 layer_set_up(phy_layer, frml); 515 layer_set_up(phy_layer, frml);
531 } 516 }
532 517
533 list_add_rcu(&phyinfo->node, &cnfg->phys); 518 list_add_rcu(&phyinfo->node, &cnfg->phys);
519out:
534 mutex_unlock(&cnfg->lock); 520 mutex_unlock(&cnfg->lock);
535 return; 521 return;
536 522
537out_err: 523out_err:
538 kfree(phy_driver);
539 kfree(phyinfo); 524 kfree(phyinfo);
540 mutex_unlock(&cnfg->lock); 525 mutex_unlock(&cnfg->lock);
541} 526}