Skip to content

Commit

Permalink
Staging: ti-st: make use of linux err codes
Browse files Browse the repository at this point in the history
remove custom error code definitions from the header and
make use of the agreed upon linux error codes.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Pavan Savoy authored and Greg Kroah-Hartman committed Jul 22, 2010
1 parent 771dafd commit 320920c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 56 deletions.
6 changes: 3 additions & 3 deletions drivers/staging/ti-st/bt_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int hci_st_open(struct hci_dev *hdev)

/* Register with ST layer */
err = st_register(&hci_st_proto);
if (err == ST_ERR_PENDING) {
if (err == -EINPROGRESS) {
/* Prepare wait-for-completion handler data structures.
* Needed to syncronize this and st_registration_completion_cb()
* functions.
Expand Down Expand Up @@ -232,7 +232,7 @@ static int hci_st_open(struct hci_dev *hdev)
return -EAGAIN;
}
err = 0;
} else if (err == ST_ERR_FAILURE) {
} else if (err == -1) {
BT_DRV_ERR("st_register failed %d", err);
BTDRV_API_EXIT(-EAGAIN);
return -EAGAIN;
Expand Down Expand Up @@ -280,7 +280,7 @@ static int hci_st_close(struct hci_dev *hdev)
/* Unregister from ST layer */
if (test_and_clear_bit(BT_ST_REGISTERED, &hst->flags)) {
err = st_unregister(ST_BT);
if (err != ST_SUCCESS) {
if (err != 0) {
BT_DRV_ERR("st_unregister failed %d", err);
BTDRV_API_EXIT(-EBUSY);
return -EBUSY;
Expand Down
9 changes: 0 additions & 9 deletions drivers/staging/ti-st/st.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ enum proto_type {
ST_MAX,
};

enum {
ST_ERR_FAILURE = -1, /* check struct */
ST_SUCCESS,
ST_ERR_PENDING = -5, /* to call reg_complete_cb */
ST_ERR_ALREADY, /* already registered */
ST_ERR_INPROGRESS,
ST_ERR_NOPROTO, /* protocol not supported */
};

/* per protocol structure
* for BT/FM and GPS
*/
Expand Down
38 changes: 19 additions & 19 deletions drivers/staging/ti-st/st_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int st_int_write(struct st_data_s *st_gdata,
struct tty_struct *tty;
if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
pr_err("tty unavailable to perform write");
return ST_ERR_FAILURE;
return -1;
}
tty = st_gdata->tty;
#ifdef VERBOSE
Expand Down Expand Up @@ -123,7 +123,7 @@ void st_send_frame(enum proto_type protoid, struct st_data_s *st_gdata)
*/
if (likely(st_gdata->list[protoid]->recv != NULL)) {
if (unlikely(st_gdata->list[protoid]->recv(st_gdata->rx_skb)
!= ST_SUCCESS)) {
!= 0)) {
pr_err(" proto stack %d's ->recv failed", protoid);
kfree_skb(st_gdata->rx_skb);
return;
Expand Down Expand Up @@ -601,25 +601,25 @@ void kim_st_list_protocols(struct st_data_s *st_gdata, char *buf)
long st_register(struct st_proto_s *new_proto)
{
struct st_data_s *st_gdata;
long err = ST_SUCCESS;
long err = 0;
unsigned long flags = 0;

st_kim_ref(&st_gdata);
pr_info("%s(%d) ", __func__, new_proto->type);
if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
|| new_proto->reg_complete_cb == NULL) {
pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
return ST_ERR_FAILURE;
return -1;
}

if (new_proto->type < ST_BT || new_proto->type >= ST_MAX) {
pr_err("protocol %d not supported", new_proto->type);
return ST_ERR_NOPROTO;
return -EPROTONOSUPPORT;
}

if (st_gdata->list[new_proto->type] != NULL) {
pr_err("protocol %d already registered", new_proto->type);
return ST_ERR_ALREADY;
return -EALREADY;
}

/* can be from process context only */
Expand All @@ -636,7 +636,7 @@ long st_register(struct st_proto_s *new_proto)

set_bit(ST_REG_PENDING, &st_gdata->st_state);
spin_unlock_irqrestore(&st_gdata->lock, flags);
return ST_ERR_PENDING;
return -EINPROGRESS;
} else if (st_gdata->protos_registered == ST_EMPTY) {
pr_info(" protocol list empty :%d ", new_proto->type);
set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
Expand All @@ -651,15 +651,15 @@ long st_register(struct st_proto_s *new_proto)
* since it involves BT fw download
*/
err = st_kim_start(st_gdata->kim_data);
if (err != ST_SUCCESS) {
if (err != 0) {
clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
if ((st_gdata->protos_registered != ST_EMPTY) &&
(test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
pr_err(" KIM failure complete callback ");
st_reg_complete(st_gdata, ST_ERR_FAILURE);
st_reg_complete(st_gdata, -1);
}

return ST_ERR_FAILURE;
return -1;
}

/* the protocol might require other gpios to be toggled
Expand All @@ -675,7 +675,7 @@ long st_register(struct st_proto_s *new_proto)
if ((st_gdata->protos_registered != ST_EMPTY) &&
(test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
pr_info(" call reg complete callback ");
st_reg_complete(st_gdata, ST_SUCCESS);
st_reg_complete(st_gdata, 0);
}
clear_bit(ST_REG_PENDING, &st_gdata->st_state);

Expand All @@ -685,7 +685,7 @@ long st_register(struct st_proto_s *new_proto)
if (st_gdata->list[new_proto->type] != NULL) {
pr_err(" proto %d already registered ",
new_proto->type);
return ST_ERR_ALREADY;
return -EALREADY;
}

spin_lock_irqsave(&st_gdata->lock, flags);
Expand All @@ -709,7 +709,7 @@ long st_register(struct st_proto_s *new_proto)
default:
pr_err("%d protocol not supported",
new_proto->type);
err = ST_ERR_NOPROTO;
err = -EPROTONOSUPPORT;
/* something wrong */
break;
}
Expand All @@ -730,7 +730,7 @@ EXPORT_SYMBOL_GPL(st_register);
*/
long st_unregister(enum proto_type type)
{
long err = ST_SUCCESS;
long err = 0;
unsigned long flags = 0;
struct st_data_s *st_gdata;

Expand All @@ -739,15 +739,15 @@ long st_unregister(enum proto_type type)
st_kim_ref(&st_gdata);
if (type < ST_BT || type >= ST_MAX) {
pr_err(" protocol %d not supported", type);
return ST_ERR_NOPROTO;
return -EPROTONOSUPPORT;
}

spin_lock_irqsave(&st_gdata->lock, flags);

if (st_gdata->list[type] == NULL) {
pr_err(" protocol %d not registered", type);
spin_unlock_irqrestore(&st_gdata->lock, flags);
return ST_ERR_NOPROTO;
return -EPROTONOSUPPORT;
}

st_gdata->protos_registered--;
Expand Down Expand Up @@ -794,7 +794,7 @@ long st_write(struct sk_buff *skb)
if (unlikely(skb == NULL || st_gdata == NULL
|| st_gdata->tty == NULL)) {
pr_err("data/tty unavailable to perform write");
return ST_ERR_FAILURE;
return -1;
}
#ifdef DEBUG /* open-up skb to read the 1st byte */
switch (skb->data[0]) {
Expand All @@ -813,7 +813,7 @@ long st_write(struct sk_buff *skb)
if (unlikely(st_gdata->list[protoid] == NULL)) {
pr_err(" protocol %d not registered, and writing? ",
protoid);
return ST_ERR_FAILURE;
return -1;
}
#endif
pr_info("%d to be written", skb->len);
Expand All @@ -837,7 +837,7 @@ EXPORT_SYMBOL_GPL(st_unregister);
*/
static int st_tty_open(struct tty_struct *tty)
{
int err = ST_SUCCESS;
int err = 0;
struct st_data_s *st_gdata;
pr_info("%s ", __func__);

Expand Down
46 changes: 23 additions & 23 deletions drivers/staging/ti-st/st_kim.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
INIT_COMPLETION(kim_gdata->kim_rcvd);
if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) {
pr_err("kim: couldn't write 4 bytes");
return ST_ERR_FAILURE;
return -1;
}

if (!wait_for_completion_timeout
(&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) {
pr_err(" waiting for ver info- timed out ");
return ST_ERR_FAILURE;
return -1;
}

version =
Expand All @@ -275,15 +275,15 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
kim_gdata->version.min_ver = min_ver;

pr_info("%s", bts_scr_name);
return ST_SUCCESS;
return 0;
}

/* internal function which parses through the .bts firmware script file
* intreprets SEND, DELAY actions only as of now
*/
static long download_firmware(struct kim_data_s *kim_gdata)
{
long err = ST_SUCCESS;
long err = 0;
long len = 0;
register unsigned char *ptr = NULL;
register unsigned char *action_ptr = NULL;
Expand All @@ -292,7 +292,7 @@ static long download_firmware(struct kim_data_s *kim_gdata)
pr_info("%s", __func__);

err = read_local_version(kim_gdata, bts_scr_name);
if (err != ST_SUCCESS) {
if (err != 0) {
pr_err("kim: failed to read local ver");
return err;
}
Expand All @@ -303,7 +303,7 @@ static long download_firmware(struct kim_data_s *kim_gdata)
(kim_gdata->fw_entry->size == 0))) {
pr_err(" request_firmware failed(errno %ld) for %s", err,
bts_scr_name);
return ST_ERR_FAILURE;
return -1;
}
ptr = (void *)kim_gdata->fw_entry->data;
len = kim_gdata->fw_entry->size;
Expand Down Expand Up @@ -338,7 +338,7 @@ static long download_firmware(struct kim_data_s *kim_gdata)
((struct bts_action *)ptr)->size);
if (unlikely(err < 0)) {
release_firmware(kim_gdata->fw_entry);
return ST_ERR_FAILURE;
return -1;
}
if (!wait_for_completion_timeout
(&kim_gdata->kim_rcvd,
Expand All @@ -347,7 +347,7 @@ static long download_firmware(struct kim_data_s *kim_gdata)
(" response timeout during fw download ");
/* timed out */
release_firmware(kim_gdata->fw_entry);
return ST_ERR_FAILURE;
return -1;
}
break;
case ACTION_DELAY: /* sleep */
Expand All @@ -365,7 +365,7 @@ static long download_firmware(struct kim_data_s *kim_gdata)
}
/* fw download complete */
release_firmware(kim_gdata->fw_entry);
return ST_SUCCESS;
return 0;
}

/**********************************************************************/
Expand Down Expand Up @@ -451,7 +451,7 @@ void st_kim_complete(void *kim_data)
*/
long st_kim_start(void *kim_data)
{
long err = ST_SUCCESS;
long err = 0;
long retry = POR_RETRY_COUNT;
struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;

Expand All @@ -475,7 +475,7 @@ long st_kim_start(void *kim_data)
err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0);
if (err != 0) {
pr_info(" sending SIGUSR2 to uim failed %ld", err);
err = ST_ERR_FAILURE;
err = -1;
continue;
}
#endif
Expand All @@ -486,13 +486,13 @@ long st_kim_start(void *kim_data)
msecs_to_jiffies(LDISC_TIME));
if (!err) { /* timeout */
pr_err("line disc installation timed out ");
err = ST_ERR_FAILURE;
err = -1;
continue;
} else {
/* ldisc installed now */
pr_info(" line discipline installed ");
err = download_firmware(kim_gdata);
if (err != ST_SUCCESS) {
if (err != 0) {
pr_err("download firmware failed");
continue;
} else { /* on success don't retry */
Expand All @@ -507,7 +507,7 @@ long st_kim_start(void *kim_data)
*/
long st_kim_stop(void *kim_data)
{
long err = ST_SUCCESS;
long err = 0;
struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;

INIT_COMPLETION(kim_gdata->ldisc_installed);
Expand All @@ -516,7 +516,7 @@ long st_kim_stop(void *kim_data)
err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 1);
if (err != 0) {
pr_err("sending SIGUSR2 to uim failed %ld", err);
return ST_ERR_FAILURE;
return -1;
}
#endif
/* set BT rfkill to be blocked */
Expand All @@ -527,7 +527,7 @@ long st_kim_stop(void *kim_data)
msecs_to_jiffies(LDISC_TIME));
if (!err) { /* timeout */
pr_err(" timed out waiting for ldisc to be un-installed");
return ST_ERR_FAILURE;
return -1;
}

/* By default configure BT nShutdown to LOW state */
Expand Down Expand Up @@ -607,7 +607,7 @@ static int kim_toggle_radio(void *data, bool blocked)
pr_err(" wrong proto type ");
break;
}
return ST_SUCCESS;
return 0;
}

void st_kim_ref(struct st_data_s **core_data)
Expand Down Expand Up @@ -643,7 +643,7 @@ static int kim_probe(struct platform_device *pdev)
status = st_core_init(&kim_gdata->core_data);
if (status != 0) {
pr_err(" ST core init failed");
return ST_ERR_FAILURE;
return -1;
}
/* refer to itself */
kim_gdata->core_data->kim_data = kim_gdata;
Expand Down Expand Up @@ -716,7 +716,7 @@ static int kim_probe(struct platform_device *pdev)
return -1;
}
pr_info(" sysfs entries created ");
return ST_SUCCESS;
return 0;
}

static int kim_remove(struct platform_device *pdev)
Expand Down Expand Up @@ -745,21 +745,21 @@ static int kim_remove(struct platform_device *pdev)

kfree(kim_gdata);
kim_gdata = NULL;
return ST_SUCCESS;
return 0;
}

/**********************************************************************/
/* entry point for ST KIM module, called in from ST Core */

static int __init st_kim_init(void)
{
long ret = ST_SUCCESS;
long ret = 0;
ret = platform_driver_register(&kim_platform_driver);
if (ret != 0) {
pr_err("platform drv registration failed");
return ST_ERR_FAILURE;
return -1;
}
return ST_SUCCESS;
return 0;
}

static void __exit st_kim_deinit(void)
Expand Down
Loading

0 comments on commit 320920c

Please sign in to comment.