Skip to content

Commit ce8aa48

Browse files
committed
Merge branch 'for-3.10-async' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull async update from Tejun Heo: "This contains three cleanup patches for async from Lai. All three patches are essentially cosmetic." * 'for-3.10-async' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: async: rename and redefine async_func_ptr async: remove unused @node from struct async_domain async: simplify lowest_in_progress()
2 parents b97db07 + 362f2b0 commit ce8aa48

3 files changed

Lines changed: 24 additions & 31 deletions

File tree

‎arch/sh/drivers/pci/pcie-sh7786.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static unsigned int nr_ports;
3535

3636
static struct sh7786_pcie_hwops {
3737
int (*core_init)(void);
38-
async_func_ptr *port_init_hw;
38+
async_func_t port_init_hw;
3939
} *sh7786_pcie_hwops;
4040

4141
static struct resource sh7786_pci0_resources[] = {

‎include/linux/async.h‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#include <linux/list.h>
1717

1818
typedef u64 async_cookie_t;
19-
typedef void (async_func_ptr) (void *data, async_cookie_t cookie);
19+
typedef void (*async_func_t) (void *data, async_cookie_t cookie);
2020
struct async_domain {
21-
struct list_head node;
2221
struct list_head pending;
2322
unsigned registered:1;
2423
};
@@ -27,21 +26,19 @@ struct async_domain {
2726
* domain participates in global async_synchronize_full
2827
*/
2928
#define ASYNC_DOMAIN(_name) \
30-
struct async_domain _name = { .node = LIST_HEAD_INIT(_name.node), \
31-
.pending = LIST_HEAD_INIT(_name.pending), \
29+
struct async_domain _name = { .pending = LIST_HEAD_INIT(_name.pending), \
3230
.registered = 1 }
3331

3432
/*
3533
* domain is free to go out of scope as soon as all pending work is
3634
* complete, this domain does not participate in async_synchronize_full
3735
*/
3836
#define ASYNC_DOMAIN_EXCLUSIVE(_name) \
39-
struct async_domain _name = { .node = LIST_HEAD_INIT(_name.node), \
40-
.pending = LIST_HEAD_INIT(_name.pending), \
37+
struct async_domain _name = { .pending = LIST_HEAD_INIT(_name.pending), \
4138
.registered = 0 }
4239

43-
extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data);
44-
extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
40+
extern async_cookie_t async_schedule(async_func_t func, void *data);
41+
extern async_cookie_t async_schedule_domain(async_func_t func, void *data,
4542
struct async_domain *domain);
4643
void async_unregister_domain(struct async_domain *domain);
4744
extern void async_synchronize_full(void);

‎kernel/async.c‎

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct async_entry {
7373
struct list_head global_list;
7474
struct work_struct work;
7575
async_cookie_t cookie;
76-
async_func_ptr *func;
76+
async_func_t func;
7777
void *data;
7878
struct async_domain *domain;
7979
};
@@ -84,24 +84,20 @@ static atomic_t entry_count;
8484

8585
static async_cookie_t lowest_in_progress(struct async_domain *domain)
8686
{
87-
struct async_entry *first = NULL;
87+
struct list_head *pending;
8888
async_cookie_t ret = ASYNC_COOKIE_MAX;
8989
unsigned long flags;
9090

9191
spin_lock_irqsave(&async_lock, flags);
9292

93-
if (domain) {
94-
if (!list_empty(&domain->pending))
95-
first = list_first_entry(&domain->pending,
96-
struct async_entry, domain_list);
97-
} else {
98-
if (!list_empty(&async_global_pending))
99-
first = list_first_entry(&async_global_pending,
100-
struct async_entry, global_list);
101-
}
93+
if (domain)
94+
pending = &domain->pending;
95+
else
96+
pending = &async_global_pending;
10297

103-
if (first)
104-
ret = first->cookie;
98+
if (!list_empty(pending))
99+
ret = list_first_entry(pending, struct async_entry,
100+
domain_list)->cookie;
105101

106102
spin_unlock_irqrestore(&async_lock, flags);
107103
return ret;
@@ -149,7 +145,7 @@ static void async_run_entry_fn(struct work_struct *work)
149145
wake_up(&async_done);
150146
}
151147

152-
static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct async_domain *domain)
148+
static async_cookie_t __async_schedule(async_func_t func, void *data, struct async_domain *domain)
153149
{
154150
struct async_entry *entry;
155151
unsigned long flags;
@@ -169,13 +165,13 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct a
169165
spin_unlock_irqrestore(&async_lock, flags);
170166

171167
/* low on memory.. run synchronously */
172-
ptr(data, newcookie);
168+
func(data, newcookie);
173169
return newcookie;
174170
}
175171
INIT_LIST_HEAD(&entry->domain_list);
176172
INIT_LIST_HEAD(&entry->global_list);
177173
INIT_WORK(&entry->work, async_run_entry_fn);
178-
entry->func = ptr;
174+
entry->func = func;
179175
entry->data = data;
180176
entry->domain = domain;
181177

@@ -202,21 +198,21 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct a
202198

203199
/**
204200
* async_schedule - schedule a function for asynchronous execution
205-
* @ptr: function to execute asynchronously
201+
* @func: function to execute asynchronously
206202
* @data: data pointer to pass to the function
207203
*
208204
* Returns an async_cookie_t that may be used for checkpointing later.
209205
* Note: This function may be called from atomic or non-atomic contexts.
210206
*/
211-
async_cookie_t async_schedule(async_func_ptr *ptr, void *data)
207+
async_cookie_t async_schedule(async_func_t func, void *data)
212208
{
213-
return __async_schedule(ptr, data, &async_dfl_domain);
209+
return __async_schedule(func, data, &async_dfl_domain);
214210
}
215211
EXPORT_SYMBOL_GPL(async_schedule);
216212

217213
/**
218214
* async_schedule_domain - schedule a function for asynchronous execution within a certain domain
219-
* @ptr: function to execute asynchronously
215+
* @func: function to execute asynchronously
220216
* @data: data pointer to pass to the function
221217
* @domain: the domain
222218
*
@@ -226,10 +222,10 @@ EXPORT_SYMBOL_GPL(async_schedule);
226222
* synchronization domain is specified via @domain. Note: This function
227223
* may be called from atomic or non-atomic contexts.
228224
*/
229-
async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
225+
async_cookie_t async_schedule_domain(async_func_t func, void *data,
230226
struct async_domain *domain)
231227
{
232-
return __async_schedule(ptr, data, domain);
228+
return __async_schedule(func, data, domain);
233229
}
234230
EXPORT_SYMBOL_GPL(async_schedule_domain);
235231

0 commit comments

Comments
 (0)