aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/ti-st/st_core.c
diff options
context:
space:
mode:
authorPavan Savoy <pavan_savoy@ti.com>2011-02-04 03:23:11 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-02-04 15:41:20 -0500
commit704426649dd4324b34cefea322f4333e5280f852 (patch)
tree5f3b511437974e542e07bfc4a4e2558086be25c8 /drivers/misc/ti-st/st_core.c
parentec60d0ad20ff8796dc41b30a9dce485478ccd263 (diff)
drivers:misc: ti-st: fix error codes
set-right the error codes that the shared transport driver returns. Instead of magic numbers like -1, return relevant codes such as ETIMEDOUT or EIO, EAGAIN when wait times out or uart write bytes don't match expected value or when registration fails and needs to be attempted again. Signed-off-by: Pavan Savoy <pavan_savoy@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/misc/ti-st/st_core.c')
-rw-r--r--drivers/misc/ti-st/st_core.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 84d73c5cb74d..79d2dc3fca1f 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -65,7 +65,7 @@ int st_int_write(struct st_data_s *st_gdata,
65 struct tty_struct *tty; 65 struct tty_struct *tty;
66 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { 66 if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
67 pr_err("tty unavailable to perform write"); 67 pr_err("tty unavailable to perform write");
68 return -1; 68 return -EINVAL;
69 } 69 }
70 tty = st_gdata->tty; 70 tty = st_gdata->tty;
71#ifdef VERBOSE 71#ifdef VERBOSE
@@ -124,9 +124,15 @@ void st_reg_complete(struct st_data_s *st_gdata, char err)
124 pr_info(" %s ", __func__); 124 pr_info(" %s ", __func__);
125 for (i = 0; i < ST_MAX_CHANNELS; i++) { 125 for (i = 0; i < ST_MAX_CHANNELS; i++) {
126 if (likely(st_gdata != NULL && st_gdata->list[i] != NULL && 126 if (likely(st_gdata != NULL && st_gdata->list[i] != NULL &&
127 st_gdata->list[i]->reg_complete_cb != NULL)) 127 st_gdata->list[i]->reg_complete_cb != NULL)) {
128 st_gdata->list[i]->reg_complete_cb 128 st_gdata->list[i]->reg_complete_cb
129 (st_gdata->list[i]->priv_data, err); 129 (st_gdata->list[i]->priv_data, err);
130 pr_info("protocol %d's cb sent %d\n", i, err);
131 if (err) { /* cleanup registered protocol */
132 st_gdata->protos_registered--;
133 st_gdata->list[i] = NULL;
134 }
135 }
130 } 136 }
131} 137}
132 138
@@ -457,15 +463,7 @@ long st_register(struct st_proto_s *new_proto)
457 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL 463 if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
458 || new_proto->reg_complete_cb == NULL) { 464 || new_proto->reg_complete_cb == NULL) {
459 pr_err("gdata/new_proto/recv or reg_complete_cb not ready"); 465 pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
460 if (st_gdata == NULL) 466 return -EINVAL;
461 pr_err("error 1\n");
462 if (new_proto == NULL)
463 pr_err("error 2\n");
464 if (new_proto->recv == NULL)
465 pr_err("error 3\n");
466 if (new_proto->reg_complete_cb == NULL)
467 pr_err("erro 4\n");
468 return -1;
469 } 467 }
470 468
471 if (new_proto->chnl_id >= ST_MAX_CHANNELS) { 469 if (new_proto->chnl_id >= ST_MAX_CHANNELS) {
@@ -512,10 +510,9 @@ long st_register(struct st_proto_s *new_proto)
512 if ((st_gdata->protos_registered != ST_EMPTY) && 510 if ((st_gdata->protos_registered != ST_EMPTY) &&
513 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { 511 (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
514 pr_err(" KIM failure complete callback "); 512 pr_err(" KIM failure complete callback ");
515 st_reg_complete(st_gdata, -1); 513 st_reg_complete(st_gdata, err);
516 } 514 }
517 515 return -EINVAL;
518 return -1;
519 } 516 }
520 517
521 /* the chnl_id might require other gpios to be toggled 518 /* the chnl_id might require other gpios to be toggled
@@ -634,14 +631,14 @@ long st_write(struct sk_buff *skb)
634 if (unlikely(skb == NULL || st_gdata == NULL 631 if (unlikely(skb == NULL || st_gdata == NULL
635 || st_gdata->tty == NULL)) { 632 || st_gdata->tty == NULL)) {
636 pr_err("data/tty unavailable to perform write"); 633 pr_err("data/tty unavailable to perform write");
637 return -1; 634 return -EINVAL;
638 } 635 }
639#ifdef DEBUG /* open-up skb to read the 1st byte */ 636#ifdef DEBUG /* open-up skb to read the 1st byte */
640 chnl_id = skb->data[0]; 637 chnl_id = skb->data[0];
641 if (unlikely(st_gdata->list[chnl_id] == NULL)) { 638 if (unlikely(st_gdata->list[chnl_id] == NULL)) {
642 pr_err(" chnl_id %d not registered, and writing? ", 639 pr_err(" chnl_id %d not registered, and writing? ",
643 chnl_id); 640 chnl_id);
644 return -1; 641 return -EINVAL;
645 } 642 }
646#endif 643#endif
647 pr_debug("%d to be written", skb->len); 644 pr_debug("%d to be written", skb->len);
@@ -829,7 +826,7 @@ int st_core_init(struct st_data_s **core_data)
829 err = tty_unregister_ldisc(N_TI_WL); 826 err = tty_unregister_ldisc(N_TI_WL);
830 if (err) 827 if (err)
831 pr_err("unable to un-register ldisc"); 828 pr_err("unable to un-register ldisc");
832 return -1; 829 return err;
833 } 830 }
834 *core_data = st_gdata; 831 *core_data = st_gdata;
835 return 0; 832 return 0;