Commit 0ca3a017 authored by Jan Kiszka's avatar Jan Kiszka Committed by David S. Miller

CAPI: Rework locking of controller data structures

This patch applies the mutex so far only protecting the controller list
to (almost) all accesses of controller data structures. It also reworks
waiting on state changes in old_capi_manufacturer so that it no longer
poll and holds a module reference to the controller owner while waiting
(the latter was partly done already). Modification and checking of the
blocked state remains racy by design, the caller is responsible for
dealing with this.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ef69bb2e
This diff is collapsed.
...@@ -24,6 +24,7 @@ printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ ...@@ -24,6 +24,7 @@ printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \
#endif #endif
enum { enum {
CAPI_CTR_DETACHED = 0,
CAPI_CTR_DETECTED = 1, CAPI_CTR_DETECTED = 1,
CAPI_CTR_LOADING = 2, CAPI_CTR_LOADING = 2,
CAPI_CTR_RUNNING = 3, CAPI_CTR_RUNNING = 3,
...@@ -32,8 +33,10 @@ enum { ...@@ -32,8 +33,10 @@ enum {
extern struct list_head capi_drivers; extern struct list_head capi_drivers;
extern struct mutex capi_drivers_lock; extern struct mutex capi_drivers_lock;
extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
extern struct capi_ctr *capi_controller[CAPI_MAXCONTR]; extern struct capi_ctr *capi_controller[CAPI_MAXCONTR];
extern struct mutex capi_controller_lock;
extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
...@@ -35,7 +35,10 @@ static char *state2str(unsigned short state) ...@@ -35,7 +35,10 @@ static char *state2str(unsigned short state)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static void *controller_start(struct seq_file *seq, loff_t *pos) static void *controller_start(struct seq_file *seq, loff_t *pos)
__acquires(capi_controller_lock)
{ {
mutex_lock(&capi_controller_lock);
if (*pos < CAPI_MAXCONTR) if (*pos < CAPI_MAXCONTR)
return &capi_controller[*pos]; return &capi_controller[*pos];
...@@ -52,7 +55,9 @@ static void *controller_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -52,7 +55,9 @@ static void *controller_next(struct seq_file *seq, void *v, loff_t *pos)
} }
static void controller_stop(struct seq_file *seq, void *v) static void controller_stop(struct seq_file *seq, void *v)
__releases(capi_controller_lock)
{ {
mutex_unlock(&capi_controller_lock);
} }
static int controller_show(struct seq_file *seq, void *v) static int controller_show(struct seq_file *seq, void *v)
......
...@@ -66,9 +66,10 @@ struct capi_ctr { ...@@ -66,9 +66,10 @@ struct capi_ctr {
unsigned long nsentdatapkt; unsigned long nsentdatapkt;
int cnr; /* controller number */ int cnr; /* controller number */
volatile unsigned short state; /* controller state */ unsigned short state; /* controller state */
volatile int blocked; /* output blocked */ int blocked; /* output blocked */
int traceflag; /* capi trace */ int traceflag; /* capi trace */
wait_queue_head_t state_wait_queue;
struct proc_dir_entry *procent; struct proc_dir_entry *procent;
char procfn[128]; char procfn[128];
......
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