Commit a9686e78 authored by Christoph Jaeger's avatar Christoph Jaeger Committed by Greg Kroah-Hartman

staging: ozwpan: Simplify app interface

Simplify the somewhat overcomplicated application interface; improves
readability and saves a bunch of lines.

Use designated struct initializers for clarity.
Signed-off-by: default avatarChristoph Jaeger <email@christophjaeger.info>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a7ae725c
...@@ -49,11 +49,11 @@ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd) ...@@ -49,11 +49,11 @@ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd)
{ {
struct oz_serial_ctx *ctx; struct oz_serial_ctx *ctx;
spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
ctx = (struct oz_serial_ctx *)pd->app_ctx[OZ_APPID_SERIAL-1]; ctx = (struct oz_serial_ctx *) pd->app_ctx[OZ_APPID_SERIAL];
if (ctx) if (ctx)
atomic_inc(&ctx->ref_count); atomic_inc(&ctx->ref_count);
spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
return ctx; return ctx;
} }
...@@ -182,8 +182,8 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, ...@@ -182,8 +182,8 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf,
app_hdr->app_id = OZ_APPID_SERIAL; app_hdr->app_id = OZ_APPID_SERIAL;
if (copy_from_user(app_hdr+1, buf, count)) if (copy_from_user(app_hdr+1, buf, count))
goto out; goto out;
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
ctx = (struct oz_serial_ctx *)pd->app_ctx[OZ_APPID_SERIAL-1]; ctx = (struct oz_serial_ctx *) pd->app_ctx[OZ_APPID_SERIAL];
if (ctx) { if (ctx) {
app_hdr->elt_seq_num = ctx->tx_seq_num++; app_hdr->elt_seq_num = ctx->tx_seq_num++;
if (ctx->tx_seq_num == 0) if (ctx->tx_seq_num == 0)
...@@ -193,7 +193,7 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, ...@@ -193,7 +193,7 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf,
ei = NULL; ei = NULL;
spin_unlock(&eb->lock); spin_unlock(&eb->lock);
} }
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
out: out:
if (ei) { if (ei) {
count = 0; count = 0;
...@@ -436,14 +436,14 @@ int oz_cdev_start(struct oz_pd *pd, int resume) ...@@ -436,14 +436,14 @@ int oz_cdev_start(struct oz_pd *pd, int resume)
return -ENOMEM; return -ENOMEM;
atomic_set(&ctx->ref_count, 1); atomic_set(&ctx->ref_count, 1);
ctx->tx_seq_num = 1; ctx->tx_seq_num = 1;
spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
old_ctx = pd->app_ctx[OZ_APPID_SERIAL-1]; old_ctx = pd->app_ctx[OZ_APPID_SERIAL];
if (old_ctx) { if (old_ctx) {
spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
kfree(ctx); kfree(ctx);
} else { } else {
pd->app_ctx[OZ_APPID_SERIAL-1] = ctx; pd->app_ctx[OZ_APPID_SERIAL] = ctx;
spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
} }
spin_lock(&g_cdev.lock); spin_lock(&g_cdev.lock);
if ((g_cdev.active_pd == NULL) && if ((g_cdev.active_pd == NULL) &&
...@@ -468,10 +468,10 @@ void oz_cdev_stop(struct oz_pd *pd, int pause) ...@@ -468,10 +468,10 @@ void oz_cdev_stop(struct oz_pd *pd, int pause)
oz_dbg(ON, "Serial service paused\n"); oz_dbg(ON, "Serial service paused\n");
return; return;
} }
spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
ctx = (struct oz_serial_ctx *)pd->app_ctx[OZ_APPID_SERIAL-1]; ctx = (struct oz_serial_ctx *) pd->app_ctx[OZ_APPID_SERIAL];
pd->app_ctx[OZ_APPID_SERIAL-1] = NULL; pd->app_ctx[OZ_APPID_SERIAL] = NULL;
spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL]);
if (ctx) if (ctx)
oz_cdev_release_ctx(ctx); oz_cdev_release_ctx(ctx);
spin_lock(&g_cdev.lock); spin_lock(&g_cdev.lock);
......
...@@ -32,11 +32,6 @@ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f); ...@@ -32,11 +32,6 @@ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f);
static void oz_isoc_stream_free(struct oz_isoc_stream *st); static void oz_isoc_stream_free(struct oz_isoc_stream *st);
static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data); static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data);
static void oz_isoc_destructor(struct sk_buff *skb); static void oz_isoc_destructor(struct sk_buff *skb);
static int oz_def_app_init(void);
static void oz_def_app_term(void);
static int oz_def_app_start(struct oz_pd *pd, int resume);
static void oz_def_app_stop(struct oz_pd *pd, int pause);
static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt);
/* /*
* Counts the uncompleted isoc frames submitted to netcard. * Counts the uncompleted isoc frames submitted to netcard.
...@@ -45,80 +40,25 @@ static atomic_t g_submitted_isoc = ATOMIC_INIT(0); ...@@ -45,80 +40,25 @@ static atomic_t g_submitted_isoc = ATOMIC_INIT(0);
/* Application handler functions. /* Application handler functions.
*/ */
static const struct oz_app_if g_app_if[OZ_APPID_MAX] = { static const struct oz_app_if g_app_if[OZ_NB_APPS] = {
{oz_usb_init, [OZ_APPID_USB] = {
oz_usb_term, .init = oz_usb_init,
oz_usb_start, .term = oz_usb_term,
oz_usb_stop, .start = oz_usb_start,
oz_usb_rx, .stop = oz_usb_stop,
oz_usb_heartbeat, .rx = oz_usb_rx,
oz_usb_farewell, .heartbeat = oz_usb_heartbeat,
OZ_APPID_USB}, .farewell = oz_usb_farewell,
},
{oz_def_app_init, [OZ_APPID_SERIAL] = {
oz_def_app_term, .init = oz_cdev_init,
oz_def_app_start, .term = oz_cdev_term,
oz_def_app_stop, .start = oz_cdev_start,
oz_def_app_rx, .stop = oz_cdev_stop,
NULL, .rx = oz_cdev_rx,
NULL, },
OZ_APPID_UNUSED1},
{oz_def_app_init,
oz_def_app_term,
oz_def_app_start,
oz_def_app_stop,
oz_def_app_rx,
NULL,
NULL,
OZ_APPID_UNUSED2},
{oz_cdev_init,
oz_cdev_term,
oz_cdev_start,
oz_cdev_stop,
oz_cdev_rx,
NULL,
NULL,
OZ_APPID_SERIAL},
}; };
/*
* Context: process
*/
static int oz_def_app_init(void)
{
return 0;
}
/*
* Context: process
*/
static void oz_def_app_term(void)
{
}
/*
* Context: softirq
*/
static int oz_def_app_start(struct oz_pd *pd, int resume)
{
return 0;
}
/*
* Context: softirq
*/
static void oz_def_app_stop(struct oz_pd *pd, int pause)
{
}
/*
* Context: softirq
*/
static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt)
{
}
/* /*
* Context: softirq or process * Context: softirq or process
...@@ -169,7 +109,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) ...@@ -169,7 +109,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr)
if (pd) { if (pd) {
int i; int i;
atomic_set(&pd->ref_count, 2); atomic_set(&pd->ref_count, 2);
for (i = 0; i < OZ_APPID_MAX; i++) for (i = 0; i < OZ_NB_APPS; i++)
spin_lock_init(&pd->app_lock[i]); spin_lock_init(&pd->app_lock[i]);
pd->last_rx_pkt_num = 0xffffffff; pd->last_rx_pkt_num = 0xffffffff;
oz_pd_set_state(pd, OZ_PD_S_IDLE); oz_pd_set_state(pd, OZ_PD_S_IDLE);
...@@ -269,23 +209,21 @@ void oz_pd_destroy(struct oz_pd *pd) ...@@ -269,23 +209,21 @@ void oz_pd_destroy(struct oz_pd *pd)
*/ */
int oz_services_start(struct oz_pd *pd, u16 apps, int resume) int oz_services_start(struct oz_pd *pd, u16 apps, int resume)
{ {
const struct oz_app_if *ai; int i, rc = 0;
int rc = 0;
oz_pd_dbg(pd, ON, "%s: (0x%x) resume(%d)\n", __func__, apps, resume); oz_pd_dbg(pd, ON, "%s: (0x%x) resume(%d)\n", __func__, apps, resume);
for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { for (i = 0; i < OZ_NB_APPS; i++) {
if (apps & (1<<ai->app_id)) { if (g_app_if[i].start && (apps & (1 << i))) {
if (ai->start(pd, resume)) { if (g_app_if[i].start(pd, resume)) {
rc = -1; rc = -1;
oz_pd_dbg(pd, ON, oz_pd_dbg(pd, ON,
"Unable to start service %d\n", "Unable to start service %d\n", i);
ai->app_id);
break; break;
} }
spin_lock_bh(&g_polling_lock); spin_lock_bh(&g_polling_lock);
pd->total_apps |= (1<<ai->app_id); pd->total_apps |= (1 << i);
if (resume) if (resume)
pd->paused_apps &= ~(1<<ai->app_id); pd->paused_apps &= ~(1 << i);
spin_unlock_bh(&g_polling_lock); spin_unlock_bh(&g_polling_lock);
} }
} }
...@@ -297,20 +235,20 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) ...@@ -297,20 +235,20 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume)
*/ */
void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) void oz_services_stop(struct oz_pd *pd, u16 apps, int pause)
{ {
const struct oz_app_if *ai; int i;
oz_pd_dbg(pd, ON, "%s: (0x%x) pause(%d)\n", __func__, apps, pause); oz_pd_dbg(pd, ON, "%s: (0x%x) pause(%d)\n", __func__, apps, pause);
for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { for (i = 0; i < OZ_NB_APPS; i++) {
if (apps & (1<<ai->app_id)) { if (g_app_if[i].stop && (apps & (1 << i))) {
spin_lock_bh(&g_polling_lock); spin_lock_bh(&g_polling_lock);
if (pause) { if (pause) {
pd->paused_apps |= (1<<ai->app_id); pd->paused_apps |= (1 << i);
} else { } else {
pd->total_apps &= ~(1<<ai->app_id); pd->total_apps &= ~(1 << i);
pd->paused_apps &= ~(1<<ai->app_id); pd->paused_apps &= ~(1 << i);
} }
spin_unlock_bh(&g_polling_lock); spin_unlock_bh(&g_polling_lock);
ai->stop(pd, pause); g_app_if[i].stop(pd, pause);
} }
} }
} }
...@@ -320,12 +258,11 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) ...@@ -320,12 +258,11 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause)
*/ */
void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) void oz_pd_heartbeat(struct oz_pd *pd, u16 apps)
{ {
const struct oz_app_if *ai; int i, more = 0;
int more = 0;
for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { for (i = 0; i < OZ_NB_APPS; i++) {
if (ai->heartbeat && (apps & (1<<ai->app_id))) { if (g_app_if[i].heartbeat && (apps & (1 << i))) {
if (ai->heartbeat(pd)) if (g_app_if[i].heartbeat(pd))
more = 1; more = 1;
} }
} }
...@@ -957,9 +894,10 @@ void oz_apps_init(void) ...@@ -957,9 +894,10 @@ void oz_apps_init(void)
{ {
int i; int i;
for (i = 0; i < OZ_APPID_MAX; i++) for (i = 0; i < OZ_NB_APPS; i++) {
if (g_app_if[i].init) if (g_app_if[i].init)
g_app_if[i].init(); g_app_if[i].init();
}
} }
/* /*
...@@ -970,9 +908,10 @@ void oz_apps_term(void) ...@@ -970,9 +908,10 @@ void oz_apps_term(void)
int i; int i;
/* Terminate all the apps. */ /* Terminate all the apps. */
for (i = 0; i < OZ_APPID_MAX; i++) for (i = 0; i < OZ_NB_APPS; i++) {
if (g_app_if[i].term) if (g_app_if[i].term)
g_app_if[i].term(); g_app_if[i].term();
}
} }
/* /*
...@@ -980,12 +919,8 @@ void oz_apps_term(void) ...@@ -980,12 +919,8 @@ void oz_apps_term(void)
*/ */
void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt)
{ {
const struct oz_app_if *ai; if (app_id < OZ_NB_APPS && g_app_if[app_id].rx)
g_app_if[app_id].rx(pd, elt);
if (app_id == 0 || app_id > OZ_APPID_MAX)
return;
ai = &g_app_if[app_id-1];
ai->rx(pd, elt);
} }
/* /*
...@@ -994,7 +929,7 @@ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) ...@@ -994,7 +929,7 @@ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt)
void oz_pd_indicate_farewells(struct oz_pd *pd) void oz_pd_indicate_farewells(struct oz_pd *pd)
{ {
struct oz_farewell *f; struct oz_farewell *f;
const struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; const struct oz_app_if *ai = &g_app_if[OZ_APPID_USB];
while (1) { while (1) {
spin_lock_bh(&g_polling_lock); spin_lock_bh(&g_polling_lock);
......
...@@ -81,8 +81,8 @@ struct oz_pd { ...@@ -81,8 +81,8 @@ struct oz_pd {
unsigned long presleep; unsigned long presleep;
unsigned long keep_alive; unsigned long keep_alive;
struct oz_elt_buf elt_buff; struct oz_elt_buf elt_buff;
void *app_ctx[OZ_APPID_MAX]; void *app_ctx[OZ_NB_APPS];
spinlock_t app_lock[OZ_APPID_MAX]; spinlock_t app_lock[OZ_NB_APPS];
int max_tx_size; int max_tx_size;
u8 mode; u8 mode;
u8 ms_per_isoc; u8 ms_per_isoc;
......
...@@ -614,7 +614,7 @@ struct oz_pd *oz_pd_find(const u8 *mac_addr) ...@@ -614,7 +614,7 @@ struct oz_pd *oz_pd_find(const u8 *mac_addr)
*/ */
void oz_app_enable(int app_id, int enable) void oz_app_enable(int app_id, int enable)
{ {
if (app_id <= OZ_APPID_MAX) { if (app_id < OZ_NB_APPS) {
spin_lock_bh(&g_polling_lock); spin_lock_bh(&g_polling_lock);
if (enable) if (enable)
g_apps |= (1<<app_id); g_apps |= (1<<app_id);
......
...@@ -46,7 +46,6 @@ struct oz_app_if { ...@@ -46,7 +46,6 @@ struct oz_app_if {
oz_app_rx_fn_t rx; oz_app_rx_fn_t rx;
oz_app_heartbeat_fn_t heartbeat; oz_app_heartbeat_fn_t heartbeat;
oz_app_farewell_fn_t farewell; oz_app_farewell_fn_t farewell;
int app_id;
}; };
int oz_protocol_init(char *devs); int oz_protocol_init(char *devs);
......
...@@ -139,8 +139,6 @@ struct oz_app_hdr { ...@@ -139,8 +139,6 @@ struct oz_app_hdr {
/* Values for app_id. /* Values for app_id.
*/ */
#define OZ_APPID_USB 0x1 #define OZ_APPID_USB 0x1
#define OZ_APPID_UNUSED1 0x2
#define OZ_APPID_UNUSED2 0x3
#define OZ_APPID_SERIAL 0x4 #define OZ_APPID_SERIAL 0x4
#define OZ_APPID_MAX OZ_APPID_SERIAL #define OZ_APPID_MAX OZ_APPID_SERIAL
#define OZ_NB_APPS (OZ_APPID_MAX+1) #define OZ_NB_APPS (OZ_APPID_MAX+1)
......
...@@ -73,12 +73,12 @@ int oz_usb_start(struct oz_pd *pd, int resume) ...@@ -73,12 +73,12 @@ int oz_usb_start(struct oz_pd *pd, int resume)
* If it does already have one then destroy the one we have just * If it does already have one then destroy the one we have just
* created. * created.
*/ */
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
old_ctx = pd->app_ctx[OZ_APPID_USB-1]; old_ctx = pd->app_ctx[OZ_APPID_USB];
if (old_ctx == NULL) if (old_ctx == NULL)
pd->app_ctx[OZ_APPID_USB-1] = usb_ctx; pd->app_ctx[OZ_APPID_USB] = usb_ctx;
oz_usb_get(pd->app_ctx[OZ_APPID_USB-1]); oz_usb_get(pd->app_ctx[OZ_APPID_USB]);
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
if (old_ctx) { if (old_ctx) {
oz_dbg(ON, "Already have USB context\n"); oz_dbg(ON, "Already have USB context\n");
kfree(usb_ctx); kfree(usb_ctx);
...@@ -99,9 +99,9 @@ int oz_usb_start(struct oz_pd *pd, int resume) ...@@ -99,9 +99,9 @@ int oz_usb_start(struct oz_pd *pd, int resume)
usb_ctx->hport = oz_hcd_pd_arrived(usb_ctx); usb_ctx->hport = oz_hcd_pd_arrived(usb_ctx);
if (usb_ctx->hport == NULL) { if (usb_ctx->hport == NULL) {
oz_dbg(ON, "USB hub returned null port\n"); oz_dbg(ON, "USB hub returned null port\n");
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
pd->app_ctx[OZ_APPID_USB-1] = NULL; pd->app_ctx[OZ_APPID_USB] = NULL;
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
oz_usb_put(usb_ctx); oz_usb_put(usb_ctx);
rc = -1; rc = -1;
} }
...@@ -122,10 +122,10 @@ void oz_usb_stop(struct oz_pd *pd, int pause) ...@@ -122,10 +122,10 @@ void oz_usb_stop(struct oz_pd *pd, int pause)
oz_dbg(ON, "USB service paused\n"); oz_dbg(ON, "USB service paused\n");
return; return;
} }
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; usb_ctx = (struct oz_usb_ctx *) pd->app_ctx[OZ_APPID_USB];
pd->app_ctx[OZ_APPID_USB-1] = NULL; pd->app_ctx[OZ_APPID_USB] = NULL;
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
if (usb_ctx) { if (usb_ctx) {
struct timespec ts, now; struct timespec ts, now;
getnstimeofday(&ts); getnstimeofday(&ts);
...@@ -187,11 +187,11 @@ int oz_usb_heartbeat(struct oz_pd *pd) ...@@ -187,11 +187,11 @@ int oz_usb_heartbeat(struct oz_pd *pd)
struct oz_usb_ctx *usb_ctx; struct oz_usb_ctx *usb_ctx;
int rc = 0; int rc = 0;
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; usb_ctx = (struct oz_usb_ctx *) pd->app_ctx[OZ_APPID_USB];
if (usb_ctx) if (usb_ctx)
oz_usb_get(usb_ctx); oz_usb_get(usb_ctx);
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
if (usb_ctx == NULL) if (usb_ctx == NULL)
return rc; return rc;
if (usb_ctx->stopped) if (usb_ctx->stopped)
......
...@@ -364,11 +364,11 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) ...@@ -364,11 +364,11 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt)
struct oz_usb_hdr *usb_hdr = (struct oz_usb_hdr *)(elt + 1); struct oz_usb_hdr *usb_hdr = (struct oz_usb_hdr *)(elt + 1);
struct oz_usb_ctx *usb_ctx; struct oz_usb_ctx *usb_ctx;
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB];
if (usb_ctx) if (usb_ctx)
oz_usb_get(usb_ctx); oz_usb_get(usb_ctx);
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
if (usb_ctx == NULL) if (usb_ctx == NULL)
return; /* Context has gone so nothing to do. */ return; /* Context has gone so nothing to do. */
if (usb_ctx->stopped) if (usb_ctx->stopped)
...@@ -434,11 +434,11 @@ void oz_usb_farewell(struct oz_pd *pd, u8 ep_num, u8 *data, u8 len) ...@@ -434,11 +434,11 @@ void oz_usb_farewell(struct oz_pd *pd, u8 ep_num, u8 *data, u8 len)
{ {
struct oz_usb_ctx *usb_ctx; struct oz_usb_ctx *usb_ctx;
spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_lock_bh(&pd->app_lock[OZ_APPID_USB]);
usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB];
if (usb_ctx) if (usb_ctx)
oz_usb_get(usb_ctx); oz_usb_get(usb_ctx);
spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);
if (usb_ctx == NULL) if (usb_ctx == NULL)
return; /* Context has gone so nothing to do. */ return; /* Context has gone so nothing to do. */
if (!usb_ctx->stopped) { if (!usb_ctx->stopped) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment