Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 335613
b: refs/heads/master
c: 946edc4
h: refs/heads/master
i:
  335611: 5abc148
v: v3
  • Loading branch information
Linus Torvalds committed Nov 13, 2012
1 parent 664d927 commit 075a93e
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 55 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3d930678034e756d0960d214412d344772b21109
refs/heads/master: 946edc47b6106e7fbacac667fdf26d858231c7c4
21 changes: 0 additions & 21 deletions trunk/drivers/leds/ledtrig-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
struct led_trigger_cpu {
char name[MAX_NAME_LEN];
struct led_trigger *_trig;
struct mutex lock;
int lock_is_inited;
};

static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig);
Expand All @@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
{
struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig);

/* mutex lock should be initialized before calling mutex_call() */
if (!trig->lock_is_inited)
return;

mutex_lock(&trig->lock);

/* Locate the correct CPU LED */
switch (ledevt) {
case CPU_LED_IDLE_END:
Expand All @@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
/* Will leave the LED as it is */
break;
}

mutex_unlock(&trig->lock);
}
EXPORT_SYMBOL(ledtrig_cpu);

Expand Down Expand Up @@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void)
for_each_possible_cpu(cpu) {
struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);

mutex_init(&trig->lock);

snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);

mutex_lock(&trig->lock);
led_trigger_register_simple(trig->name, &trig->_trig);
trig->lock_is_inited = 1;
mutex_unlock(&trig->lock);
}

register_syscore_ops(&ledtrig_cpu_syscore_ops);
Expand All @@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void)
for_each_possible_cpu(cpu) {
struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);

mutex_lock(&trig->lock);

led_trigger_unregister_simple(trig->_trig);
trig->_trig = NULL;
memset(trig->name, 0, MAX_NAME_LEN);
trig->lock_is_inited = 0;

mutex_unlock(&trig->lock);
mutex_destroy(&trig->lock);
}

unregister_syscore_ops(&ledtrig_cpu_syscore_ops);
Expand Down
41 changes: 22 additions & 19 deletions trunk/kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static int futex_lock_pi_atomic(u32 __user *uaddr, struct futex_hash_bucket *hb,
struct futex_pi_state **ps,
struct task_struct *task, int set_waiters)
{
int lock_taken, ret, ownerdied = 0;
int lock_taken, ret, force_take = 0;
u32 uval, newval, curval, vpid = task_pid_vnr(task);

retry:
Expand Down Expand Up @@ -755,17 +755,15 @@ static int futex_lock_pi_atomic(u32 __user *uaddr, struct futex_hash_bucket *hb,
newval = curval | FUTEX_WAITERS;

/*
* There are two cases, where a futex might have no owner (the
* owner TID is 0): OWNER_DIED. We take over the futex in this
* case. We also do an unconditional take over, when the owner
* of the futex died.
*
* This is safe as we are protected by the hash bucket lock !
* Should we force take the futex? See below.
*/
if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) {
/* Keep the OWNER_DIED bit */
if (unlikely(force_take)) {
/*
* Keep the OWNER_DIED and the WAITERS bit and set the
* new TID value.
*/
newval = (curval & ~FUTEX_TID_MASK) | vpid;
ownerdied = 0;
force_take = 0;
lock_taken = 1;
}

Expand All @@ -775,7 +773,7 @@ static int futex_lock_pi_atomic(u32 __user *uaddr, struct futex_hash_bucket *hb,
goto retry;

/*
* We took the lock due to owner died take over.
* We took the lock due to forced take over.
*/
if (unlikely(lock_taken))
return 1;
Expand All @@ -790,20 +788,25 @@ static int futex_lock_pi_atomic(u32 __user *uaddr, struct futex_hash_bucket *hb,
switch (ret) {
case -ESRCH:
/*
* No owner found for this futex. Check if the
* OWNER_DIED bit is set to figure out whether
* this is a robust futex or not.
* We failed to find an owner for this
* futex. So we have no pi_state to block
* on. This can happen in two cases:
*
* 1) The owner died
* 2) A stale FUTEX_WAITERS bit
*
* Re-read the futex value.
*/
if (get_futex_value_locked(&curval, uaddr))
return -EFAULT;

/*
* We simply start over in case of a robust
* futex. The code above will take the futex
* and return happy.
* If the owner died or we have a stale
* WAITERS bit the owner TID in the user space
* futex is 0.
*/
if (curval & FUTEX_OWNER_DIED) {
ownerdied = 1;
if (!(curval & FUTEX_TID_MASK)) {
force_take = 1;
goto retry;
}
default:
Expand Down
5 changes: 2 additions & 3 deletions trunk/scripts/kconfig/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "C" {

#include <assert.h>
#include <stdio.h>
#include <sys/queue.h>
#include "list.h"
#ifndef __cplusplus
#include <stdbool.h>
#endif
Expand Down Expand Up @@ -175,12 +175,11 @@ struct menu {
#define MENU_ROOT 0x0002

struct jump_key {
CIRCLEQ_ENTRY(jump_key) entries;
struct list_head entries;
size_t offset;
struct menu *target;
int index;
};
CIRCLEQ_HEAD(jk_head, jump_key);

#define JUMP_NB 9

Expand Down
91 changes: 91 additions & 0 deletions trunk/scripts/kconfig/list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#ifndef LIST_H
#define LIST_H

/*
* Copied from include/linux/...
*/

#undef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)

/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})


struct list_head {
struct list_head *next, *prev;
};


#define LIST_HEAD_INIT(name) { &(name), &(name) }

#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)

/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)

/**
* list_for_each_entry - iterate over list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
static inline int list_empty(const struct list_head *head)
{
return head->next == head;
}

/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static inline void __list_add(struct list_head *_new,
struct list_head *prev,
struct list_head *next)
{
next->prev = _new;
_new->next = next;
_new->prev = prev;
prev->next = _new;
}

/**
* list_add_tail - add a new entry
* @new: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
static inline void list_add_tail(struct list_head *_new, struct list_head *head)
{
__list_add(_new, head->prev, head);
}

#endif
4 changes: 2 additions & 2 deletions trunk/scripts/kconfig/lkc_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
P(menu_has_help,bool,(struct menu *menu));
P(menu_get_help,const char *,(struct menu *menu));
P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head
P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
*head));
P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head
P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
*head));
P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));

Expand Down
6 changes: 3 additions & 3 deletions trunk/scripts/kconfig/mconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename)


struct search_data {
struct jk_head *head;
struct list_head *head;
struct menu **targets;
int *keys;
};
Expand All @@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data)
struct jump_key *pos;
int k = 0;

CIRCLEQ_FOREACH(pos, data->head, entries) {
list_for_each_entry(pos, data->head, entries) {
if (pos->offset >= start && pos->offset < end) {
char header[4];

Expand Down Expand Up @@ -375,7 +375,7 @@ static void search_conf(void)

sym_arr = sym_re_search(dialog_input);
do {
struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head);
LIST_HEAD(head);
struct menu *targets[JUMP_NB];
int keys[JUMP_NB + 1], i;
struct search_data data = {
Expand Down
14 changes: 8 additions & 6 deletions trunk/scripts/kconfig/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu)
}

static void get_prompt_str(struct gstr *r, struct property *prop,
struct jk_head *head)
struct list_head *head)
{
int i, j;
struct menu *submenu[8], *menu, *location = NULL;
Expand Down Expand Up @@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
} else
jump->target = location;

if (CIRCLEQ_EMPTY(head))
if (list_empty(head))
jump->index = 0;
else
jump->index = CIRCLEQ_LAST(head)->index + 1;
jump->index = list_entry(head->prev, struct jump_key,
entries)->index + 1;

CIRCLEQ_INSERT_TAIL(head, jump, entries);
list_add_tail(&jump->entries, head);
}

if (i > 0) {
Expand All @@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
/*
* head is optional and may be NULL
*/
void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
void get_symbol_str(struct gstr *r, struct symbol *sym,
struct list_head *head)
{
bool hit;
struct property *prop;
Expand Down Expand Up @@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
str_append(r, "\n\n");
}

struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head)
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
{
struct symbol *sym;
struct gstr res = str_new();
Expand Down

0 comments on commit 075a93e

Please sign in to comment.