caif: Bugfix not all services uses flow-ctrl.

Flow control is not used by all CAIF services.
The usage of flow control is now part of the gerneal
initialization function for CAIF Services.

Signed-off-by: Sjur Braendeland@stericsson.com
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Sjur Braendeland 2010-06-17 06:55:38 +00:00 committed by David S. Miller
parent c14c643b3d
commit b1c74247b9
9 changed files with 26 additions and 18 deletions

View File

@ -16,6 +16,7 @@ struct cfsrvl {
bool open; bool open;
bool phy_flow_on; bool phy_flow_on;
bool modem_flow_on; bool modem_flow_on;
bool supports_flowctrl;
struct dev_info dev_info; struct dev_info dev_info;
struct kref ref; struct kref ref;
}; };
@ -30,8 +31,9 @@ struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
void cfservl_destroy(struct cflayer *layer); void cfservl_destroy(struct cflayer *layer);
void cfsrvl_init(struct cfsrvl *service, void cfsrvl_init(struct cfsrvl *service,
u8 channel_id, u8 channel_id,
struct dev_info *dev_info); struct dev_info *dev_info,
bool supports_flowctrl);
bool cfsrvl_ready(struct cfsrvl *service, int *err); bool cfsrvl_ready(struct cfsrvl *service, int *err);
u8 cfsrvl_getphyid(struct cflayer *layer); u8 cfsrvl_getphyid(struct cflayer *layer);

View File

@ -43,7 +43,7 @@ struct cflayer *cfctrl_create(void)
memset(&dev_info, 0, sizeof(dev_info)); memset(&dev_info, 0, sizeof(dev_info));
dev_info.id = 0xff; dev_info.id = 0xff;
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
cfsrvl_init(&this->serv, 0, &dev_info); cfsrvl_init(&this->serv, 0, &dev_info, false);
atomic_set(&this->req_seq_no, 1); atomic_set(&this->req_seq_no, 1);
atomic_set(&this->rsp_seq_no, 1); atomic_set(&this->rsp_seq_no, 1);
this->serv.layer.receive = cfctrl_recv; this->serv.layer.receive = cfctrl_recv;

View File

@ -22,7 +22,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
} }
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(dbg, 0, sizeof(struct cfsrvl)); memset(dbg, 0, sizeof(struct cfsrvl));
cfsrvl_init(dbg, channel_id, dev_info); cfsrvl_init(dbg, channel_id, dev_info, false);
dbg->layer.receive = cfdbgl_receive; dbg->layer.receive = cfdbgl_receive;
dbg->layer.transmit = cfdbgl_transmit; dbg->layer.transmit = cfdbgl_transmit;
snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id); snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id);

View File

@ -30,7 +30,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
} }
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(dgm, 0, sizeof(struct cfsrvl)); memset(dgm, 0, sizeof(struct cfsrvl));
cfsrvl_init(dgm, channel_id, dev_info); cfsrvl_init(dgm, channel_id, dev_info, true);
dgm->layer.receive = cfdgml_receive; dgm->layer.receive = cfdgml_receive;
dgm->layer.transmit = cfdgml_transmit; dgm->layer.transmit = cfdgml_transmit;
snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id); snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id);

View File

@ -23,30 +23,26 @@
static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt); static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt);
static int cfrfml_transmit(struct cflayer *layr, struct cfpkt *pkt); static int cfrfml_transmit(struct cflayer *layr, struct cfpkt *pkt);
static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl);
struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info) struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info)
{ {
struct cfsrvl *rfm = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); struct cfsrvl *rfm = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
if (!rfm) { if (!rfm) {
pr_warning("CAIF: %s(): Out of memory\n", __func__); pr_warning("CAIF: %s(): Out of memory\n", __func__);
return NULL; return NULL;
} }
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(rfm, 0, sizeof(struct cfsrvl)); memset(rfm, 0, sizeof(struct cfsrvl));
cfsrvl_init(rfm, channel_id, dev_info); cfsrvl_init(rfm, channel_id, dev_info, false);
rfm->layer.modemcmd = cfservl_modemcmd;
rfm->layer.receive = cfrfml_receive; rfm->layer.receive = cfrfml_receive;
rfm->layer.transmit = cfrfml_transmit; rfm->layer.transmit = cfrfml_transmit;
snprintf(rfm->layer.name, CAIF_LAYER_NAME_SZ, "rfm%d", channel_id); snprintf(rfm->layer.name, CAIF_LAYER_NAME_SZ, "rfm%d", channel_id);
return &rfm->layer; return &rfm->layer;
} }
static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
{
return -EPROTO;
}
static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt) static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt)
{ {
u8 tmp; u8 tmp;

View File

@ -24,8 +24,10 @@ static void cfservl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
int phyid) int phyid)
{ {
struct cfsrvl *service = container_obj(layr); struct cfsrvl *service = container_obj(layr);
caif_assert(layr->up != NULL); caif_assert(layr->up != NULL);
caif_assert(layr->up->ctrlcmd != NULL); caif_assert(layr->up->ctrlcmd != NULL);
switch (ctrl) { switch (ctrl) {
case CAIF_CTRLCMD_INIT_RSP: case CAIF_CTRLCMD_INIT_RSP:
service->open = true; service->open = true;
@ -89,9 +91,14 @@ static void cfservl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl)
{ {
struct cfsrvl *service = container_obj(layr); struct cfsrvl *service = container_obj(layr);
caif_assert(layr != NULL); caif_assert(layr != NULL);
caif_assert(layr->dn != NULL); caif_assert(layr->dn != NULL);
caif_assert(layr->dn->transmit != NULL); caif_assert(layr->dn->transmit != NULL);
if (!service->supports_flowctrl)
return 0;
switch (ctrl) { switch (ctrl) {
case CAIF_MODEMCMD_FLOW_ON_REQ: case CAIF_MODEMCMD_FLOW_ON_REQ:
{ {
@ -153,8 +160,10 @@ void cfservl_destroy(struct cflayer *layer)
} }
void cfsrvl_init(struct cfsrvl *service, void cfsrvl_init(struct cfsrvl *service,
u8 channel_id, u8 channel_id,
struct dev_info *dev_info) struct dev_info *dev_info,
bool supports_flowctrl
)
{ {
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
service->open = false; service->open = false;
@ -164,6 +173,7 @@ void cfsrvl_init(struct cfsrvl *service,
service->layer.ctrlcmd = cfservl_ctrlcmd; service->layer.ctrlcmd = cfservl_ctrlcmd;
service->layer.modemcmd = cfservl_modemcmd; service->layer.modemcmd = cfservl_modemcmd;
service->dev_info = *dev_info; service->dev_info = *dev_info;
service->supports_flowctrl = supports_flowctrl;
kref_init(&service->ref); kref_init(&service->ref);
} }

View File

@ -31,7 +31,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
} }
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(util, 0, sizeof(struct cfsrvl)); memset(util, 0, sizeof(struct cfsrvl));
cfsrvl_init(util, channel_id, dev_info); cfsrvl_init(util, channel_id, dev_info, true);
util->layer.receive = cfutill_receive; util->layer.receive = cfutill_receive;
util->layer.transmit = cfutill_transmit; util->layer.transmit = cfutill_transmit;
snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1"); snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1");

View File

@ -30,7 +30,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
} }
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(vei, 0, sizeof(struct cfsrvl)); memset(vei, 0, sizeof(struct cfsrvl));
cfsrvl_init(vei, channel_id, dev_info); cfsrvl_init(vei, channel_id, dev_info, true);
vei->layer.receive = cfvei_receive; vei->layer.receive = cfvei_receive;
vei->layer.transmit = cfvei_transmit; vei->layer.transmit = cfvei_transmit;
snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id); snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id);

View File

@ -27,7 +27,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
caif_assert(offsetof(struct cfsrvl, layer) == 0); caif_assert(offsetof(struct cfsrvl, layer) == 0);
memset(vid, 0, sizeof(struct cfsrvl)); memset(vid, 0, sizeof(struct cfsrvl));
cfsrvl_init(vid, channel_id, dev_info); cfsrvl_init(vid, channel_id, dev_info, false);
vid->layer.receive = cfvidl_receive; vid->layer.receive = cfvidl_receive;
vid->layer.transmit = cfvidl_transmit; vid->layer.transmit = cfvidl_transmit;
snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1"); snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1");