diff options
author | Pavan Savoy <pavan_savoy@ti.com> | 2011-02-04 03:23:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-04 15:41:20 -0500 |
commit | 704426649dd4324b34cefea322f4333e5280f852 (patch) | |
tree | 5f3b511437974e542e07bfc4a4e2558086be25c8 /drivers/misc | |
parent | ec60d0ad20ff8796dc41b30a9dce485478ccd263 (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')
-rw-r--r-- | drivers/misc/ti-st/st_core.c | 31 | ||||
-rw-r--r-- | drivers/misc/ti-st/st_kim.c | 18 | ||||
-rw-r--r-- | drivers/misc/ti-st/st_ll.c | 2 |
3 files changed, 24 insertions, 27 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; |
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c index a7fda8141758..ccc46a7b0abb 100644 --- a/drivers/misc/ti-st/st_kim.c +++ b/drivers/misc/ti-st/st_kim.c | |||
@@ -201,13 +201,13 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name) | |||
201 | INIT_COMPLETION(kim_gdata->kim_rcvd); | 201 | INIT_COMPLETION(kim_gdata->kim_rcvd); |
202 | if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { | 202 | if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { |
203 | pr_err("kim: couldn't write 4 bytes"); | 203 | pr_err("kim: couldn't write 4 bytes"); |
204 | return -1; | 204 | return -EIO; |
205 | } | 205 | } |
206 | 206 | ||
207 | if (!wait_for_completion_timeout | 207 | if (!wait_for_completion_timeout |
208 | (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { | 208 | (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { |
209 | pr_err(" waiting for ver info- timed out "); | 209 | pr_err(" waiting for ver info- timed out "); |
210 | return -1; | 210 | return -ETIMEDOUT; |
211 | } | 211 | } |
212 | 212 | ||
213 | version = | 213 | version = |
@@ -257,7 +257,7 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
257 | (kim_gdata->fw_entry->size == 0))) { | 257 | (kim_gdata->fw_entry->size == 0))) { |
258 | pr_err(" request_firmware failed(errno %ld) for %s", err, | 258 | pr_err(" request_firmware failed(errno %ld) for %s", err, |
259 | bts_scr_name); | 259 | bts_scr_name); |
260 | return -1; | 260 | return -EINVAL; |
261 | } | 261 | } |
262 | ptr = (void *)kim_gdata->fw_entry->data; | 262 | ptr = (void *)kim_gdata->fw_entry->data; |
263 | len = kim_gdata->fw_entry->size; | 263 | len = kim_gdata->fw_entry->size; |
@@ -292,7 +292,7 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
292 | ((struct bts_action *)ptr)->size); | 292 | ((struct bts_action *)ptr)->size); |
293 | if (unlikely(err < 0)) { | 293 | if (unlikely(err < 0)) { |
294 | release_firmware(kim_gdata->fw_entry); | 294 | release_firmware(kim_gdata->fw_entry); |
295 | return -1; | 295 | return err; |
296 | } | 296 | } |
297 | if (!wait_for_completion_timeout | 297 | if (!wait_for_completion_timeout |
298 | (&kim_gdata->kim_rcvd, | 298 | (&kim_gdata->kim_rcvd, |
@@ -301,7 +301,7 @@ static long download_firmware(struct kim_data_s *kim_gdata) | |||
301 | (" response timeout during fw download "); | 301 | (" response timeout during fw download "); |
302 | /* timed out */ | 302 | /* timed out */ |
303 | release_firmware(kim_gdata->fw_entry); | 303 | release_firmware(kim_gdata->fw_entry); |
304 | return -1; | 304 | return -ETIMEDOUT; |
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | case ACTION_DELAY: /* sleep */ | 307 | case ACTION_DELAY: /* sleep */ |
@@ -436,7 +436,7 @@ long st_kim_start(void *kim_data) | |||
436 | pr_info("ldisc_install = 0"); | 436 | pr_info("ldisc_install = 0"); |
437 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, | 437 | sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, |
438 | NULL, "install"); | 438 | NULL, "install"); |
439 | err = -1; | 439 | err = -ETIMEDOUT; |
440 | continue; | 440 | continue; |
441 | } else { | 441 | } else { |
442 | /* ldisc installed now */ | 442 | /* ldisc installed now */ |
@@ -482,7 +482,7 @@ long st_kim_stop(void *kim_data) | |||
482 | msecs_to_jiffies(LDISC_TIME)); | 482 | msecs_to_jiffies(LDISC_TIME)); |
483 | if (!err) { /* timeout */ | 483 | if (!err) { /* timeout */ |
484 | pr_err(" timed out waiting for ldisc to be un-installed"); | 484 | pr_err(" timed out waiting for ldisc to be un-installed"); |
485 | return -1; | 485 | return -ETIMEDOUT; |
486 | } | 486 | } |
487 | 487 | ||
488 | /* By default configure BT nShutdown to LOW state */ | 488 | /* By default configure BT nShutdown to LOW state */ |
@@ -642,7 +642,7 @@ static int kim_probe(struct platform_device *pdev) | |||
642 | status = st_core_init(&kim_gdata->core_data); | 642 | status = st_core_init(&kim_gdata->core_data); |
643 | if (status != 0) { | 643 | if (status != 0) { |
644 | pr_err(" ST core init failed"); | 644 | pr_err(" ST core init failed"); |
645 | return -1; | 645 | return -EIO; |
646 | } | 646 | } |
647 | /* refer to itself */ | 647 | /* refer to itself */ |
648 | kim_gdata->core_data->kim_data = kim_gdata; | 648 | kim_gdata->core_data->kim_data = kim_gdata; |
@@ -704,7 +704,7 @@ static int kim_probe(struct platform_device *pdev) | |||
704 | if (IS_ERR(kim_debugfs_dir)) { | 704 | if (IS_ERR(kim_debugfs_dir)) { |
705 | pr_err(" debugfs entries creation failed "); | 705 | pr_err(" debugfs entries creation failed "); |
706 | kim_debugfs_dir = NULL; | 706 | kim_debugfs_dir = NULL; |
707 | return -1; | 707 | return -EIO; |
708 | } | 708 | } |
709 | 709 | ||
710 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, | 710 | debugfs_create_file("version", S_IRUGO, kim_debugfs_dir, |
diff --git a/drivers/misc/ti-st/st_ll.c b/drivers/misc/ti-st/st_ll.c index 2bda8dea15b0..f72de6b8c343 100644 --- a/drivers/misc/ti-st/st_ll.c +++ b/drivers/misc/ti-st/st_ll.c | |||
@@ -130,7 +130,7 @@ unsigned long st_ll_sleep_state(struct st_data_s *st_data, | |||
130 | break; | 130 | break; |
131 | default: | 131 | default: |
132 | pr_err(" unknown input/state "); | 132 | pr_err(" unknown input/state "); |
133 | return -1; | 133 | return -EINVAL; |
134 | } | 134 | } |
135 | return 0; | 135 | return 0; |
136 | } | 136 | } |