Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
88929c59
Commit
88929c59
authored
Sep 13, 2014
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
greybus: ap: convert to workqueue from thread
parent
9c8d3afd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
51 deletions
+14
-51
drivers/staging/greybus/ap.c
drivers/staging/greybus/ap.c
+14
-51
No files found.
drivers/staging/greybus/ap.c
View file @
88929c59
...
@@ -24,13 +24,10 @@ struct ap_msg {
...
@@ -24,13 +24,10 @@ struct ap_msg {
u8
*
data
;
u8
*
data
;
size_t
size
;
size_t
size
;
struct
greybus_host_device
*
hd
;
struct
greybus_host_device
*
hd
;
struct
list_head
lis
t
;
struct
work_struct
even
t
;
};
};
static
LIST_HEAD
(
ap_msg_list
);
static
struct
workqueue_struct
*
ap_workqueue
;
static
spinlock_t
ap_msg_list_lock
;
static
struct
task_struct
*
ap_thread
;
static
wait_queue_head_t
ap_wait
;
static
struct
svc_msg
*
svc_msg_alloc
(
enum
svc_function_type
type
)
static
struct
svc_msg
*
svc_msg_alloc
(
enum
svc_function_type
type
)
{
{
...
@@ -220,49 +217,22 @@ static void process_ap_message(struct ap_msg *ap_msg)
...
@@ -220,49 +217,22 @@ static void process_ap_message(struct ap_msg *ap_msg)
}
}
static
struct
ap_msg
*
get_ap_msg
(
void
)
static
void
ap_process_event
(
struct
work_struct
*
work
)
{
{
struct
ap_msg
*
ap_msg
;
struct
ap_msg
*
ap_msg
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
ap_msg_list_lock
,
flags
);
ap_msg
=
container_of
(
work
,
struct
ap_msg
,
event
);
ap_msg
=
list_first_entry_or_null
(
&
ap_msg_list
,
struct
ap_msg
,
list
);
process_ap_message
(
ap_msg
);
if
(
ap_msg
!=
NULL
)
list_del
(
&
ap_msg
->
list
);
spin_unlock_irqrestore
(
&
ap_msg_list_lock
,
flags
);
return
ap_msg
;
/* clean the message up */
}
kfree
(
ap_msg
->
data
);
kfree
(
ap_msg
);
static
int
ap_process_loop
(
void
*
data
)
{
struct
ap_msg
*
ap_msg
;
while
(
!
kthread_should_stop
())
{
wait_event_interruptible
(
ap_wait
,
kthread_should_stop
());
if
(
kthread_should_stop
())
break
;
/* Get some data off of the ap list and process it */
ap_msg
=
get_ap_msg
();
if
(
!
ap_msg
)
continue
;
process_ap_message
(
ap_msg
);
/* clean the message up */
kfree
(
ap_msg
->
data
);
kfree
(
ap_msg
);
}
return
0
;
}
}
int
gb_new_ap_msg
(
u8
*
data
,
int
size
,
struct
greybus_host_device
*
hd
)
int
gb_new_ap_msg
(
u8
*
data
,
int
size
,
struct
greybus_host_device
*
hd
)
{
{
struct
ap_msg
*
ap_msg
;
struct
ap_msg
*
ap_msg
;
unsigned
long
flags
;
/*
/*
* Totally naive copy the message into a new structure that we slowly
* Totally naive copy the message into a new structure that we slowly
...
@@ -287,12 +257,8 @@ int gb_new_ap_msg(u8 *data, int size, struct greybus_host_device *hd)
...
@@ -287,12 +257,8 @@ int gb_new_ap_msg(u8 *data, int size, struct greybus_host_device *hd)
ap_msg
->
size
=
size
;
ap_msg
->
size
=
size
;
ap_msg
->
hd
=
hd
;
ap_msg
->
hd
=
hd
;
spin_lock_irqsave
(
&
ap_msg_list_lock
,
flags
);
INIT_WORK
(
&
ap_msg
->
event
,
ap_process_event
);
list_add
(
&
ap_msg
->
list
,
&
ap_msg_list
);
queue_work
(
ap_workqueue
,
&
ap_msg
->
event
);
spin_unlock_irqrestore
(
&
ap_msg_list_lock
,
flags
);
/* kick our thread to handle the message */
wake_up_interruptible
(
&
ap_wait
);
return
0
;
return
0
;
}
}
...
@@ -307,19 +273,16 @@ EXPORT_SYMBOL_GPL(greybus_cport_in_data);
...
@@ -307,19 +273,16 @@ EXPORT_SYMBOL_GPL(greybus_cport_in_data);
int
gb_thread_init
(
void
)
int
gb_thread_init
(
void
)
{
{
init_waitqueue_head
(
&
ap_wait
);
ap_workqueue
=
alloc_workqueue
(
"greybus_ap"
,
0
,
1
);
spin_lock_init
(
&
ap_msg_list_lock
);
if
(
!
ap_workqueue
)
return
-
ENOMEM
;
ap_thread
=
kthread_run
(
ap_process_loop
,
NULL
,
"greybus_ap"
);
if
(
IS_ERR
(
ap_thread
))
return
PTR_ERR
(
ap_thread
);
return
0
;
return
0
;
}
}
void
gb_thread_destroy
(
void
)
void
gb_thread_destroy
(
void
)
{
{
kthread_stop
(
ap_thread
);
destroy_workqueue
(
ap_workqueue
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment