Skip to content

Commit

Permalink
genirq: Wrap the remaning IRQ_* flags
Browse files Browse the repository at this point in the history
Use wrappers to keep them away from the core code.

Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
KAGA-KOKO committed Feb 19, 2011
1 parent 876dbd4 commit 1ccb4e6
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 12 deletions.
4 changes: 2 additions & 2 deletions kernel/irq/autoprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ unsigned long probe_irq_on(void)
*/
for_each_irq_desc_reverse(i, desc) {
raw_spin_lock_irq(&desc->lock);
if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
if (!desc->action && irq_settings_can_probe(desc)) {
/*
* An old-style architecture might still have
* the handle_bad_irq handler there:
Expand Down Expand Up @@ -74,7 +74,7 @@ unsigned long probe_irq_on(void)
*/
for_each_irq_desc_reverse(i, desc) {
raw_spin_lock_irq(&desc->lock);
if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
if (!desc->action && irq_settings_can_probe(desc)) {
desc->istate |= IRQS_AUTODETECT | IRQS_WAITING;
if (irq_startup(desc)) {
irq_compat_set_pending(desc);
Expand Down
3 changes: 2 additions & 1 deletion kernel/irq/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
desc->name = name;

if (handle != handle_bad_irq && is_chained) {
desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
irq_settings_set_noprobe(desc);
irq_settings_set_norequest(desc);
irq_startup(desc);
}
raw_spin_unlock_irqrestore(&desc->lock, flags);
Expand Down
14 changes: 7 additions & 7 deletions kernel/irq/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void irq_set_thread_affinity(struct irq_desc *desc)
#ifdef CONFIG_GENERIC_PENDING_IRQ
static inline bool irq_can_move_pcntxt(struct irq_desc *desc)
{
return desc->status & IRQ_MOVE_PCNTXT;
return irq_settings_can_move_pcntxt(desc);
}
static inline bool irq_move_pending(struct irq_desc *desc)
{
Expand Down Expand Up @@ -411,7 +411,7 @@ void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume)
if (desc->istate & IRQS_SUSPENDED)
goto err_out;
/* Prevent probing on this irq: */
desc->status |= IRQ_NOPROBE;
irq_settings_set_noprobe(desc);
irq_enable(desc);
check_irq_resend(desc, irq);
/* fall-through */
Expand Down Expand Up @@ -526,7 +526,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
if (!desc)
return 0;

if (desc->status & IRQ_NOREQUEST)
if (!irq_settings_can_request(desc))
return 0;

raw_spin_lock_irqsave(&desc->lock, flags);
Expand Down Expand Up @@ -820,7 +820,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
* Check whether the interrupt nests into another interrupt
* thread.
*/
nested = desc->status & IRQ_NESTED_THREAD;
nested = irq_settings_is_nested_thread(desc);
if (nested) {
if (!new->thread_fn)
return -EINVAL;
Expand Down Expand Up @@ -917,7 +917,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
if (new->flags & IRQF_ONESHOT)
desc->istate |= IRQS_ONESHOT;

if (!(desc->status & IRQ_NOAUTOEN))
if (irq_settings_can_autoenable(desc))
irq_startup(desc);
else
/* Undo nested disables: */
Expand Down Expand Up @@ -1217,7 +1217,7 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler,
if (!desc)
return -EINVAL;

if (desc->status & IRQ_NOREQUEST)
if (!irq_settings_can_request(desc))
return -EINVAL;

if (!handler) {
Expand Down Expand Up @@ -1292,7 +1292,7 @@ int request_any_context_irq(unsigned int irq, irq_handler_t handler,
if (!desc)
return -EINVAL;

if (desc->status & IRQ_NESTED_THREAD) {
if (irq_settings_is_nested_thread(desc)) {
ret = request_threaded_irq(irq, NULL, handler,
flags, name, dev_id);
return !ret ? IRQC_IS_NESTED : ret;
Expand Down
58 changes: 58 additions & 0 deletions kernel/irq/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ enum {
_IRQ_DEFAULT_INIT_FLAGS = IRQ_DEFAULT_INIT_FLAGS,
_IRQ_PER_CPU = IRQ_PER_CPU,
_IRQ_LEVEL = IRQ_LEVEL,
_IRQ_NOPROBE = IRQ_NOPROBE,
_IRQ_NOREQUEST = IRQ_NOREQUEST,
_IRQ_NOAUTOEN = IRQ_NOAUTOEN,
_IRQ_MOVE_PCNTXT = IRQ_MOVE_PCNTXT,
_IRQ_NO_BALANCING = IRQ_NO_BALANCING,
_IRQ_NESTED_THREAD = IRQ_NESTED_THREAD,
_IRQF_MODIFY_MASK = IRQF_MODIFY_MASK,
};

Expand Down Expand Up @@ -34,6 +39,14 @@ enum {
#define IRQ_AFFINITY_SET GOT_YOU_MORON
#undef IRQ_LEVEL
#define IRQ_LEVEL GOT_YOU_MORON
#undef IRQ_NOPROBE
#define IRQ_NOPROBE GOT_YOU_MORON
#undef IRQ_NOREQUEST
#define IRQ_NOREQUEST GOT_YOU_MORON
#undef IRQ_NOAUTOEN
#define IRQ_NOAUTOEN GOT_YOU_MORON
#undef IRQ_NESTED_THREAD
#define IRQ_NESTED_THREAD GOT_YOU_MORON
#undef IRQF_MODIFY_MASK
#define IRQF_MODIFY_MASK GOT_YOU_MORON

Expand Down Expand Up @@ -90,3 +103,48 @@ static inline void irq_settings_set_level(struct irq_desc *desc)
{
desc->status |= _IRQ_LEVEL;
}

static inline bool irq_settings_can_request(struct irq_desc *desc)
{
return !(desc->status & _IRQ_NOREQUEST);
}

static inline void irq_settings_clr_norequest(struct irq_desc *desc)
{
desc->status &= ~_IRQ_NOREQUEST;
}

static inline void irq_settings_set_norequest(struct irq_desc *desc)
{
desc->status |= _IRQ_NOREQUEST;
}

static inline bool irq_settings_can_probe(struct irq_desc *desc)
{
return !(desc->status & _IRQ_NOPROBE);
}

static inline void irq_settings_clr_noprobe(struct irq_desc *desc)
{
desc->status &= ~_IRQ_NOPROBE;
}

static inline void irq_settings_set_noprobe(struct irq_desc *desc)
{
desc->status |= _IRQ_NOPROBE;
}

static inline bool irq_settings_can_move_pcntxt(struct irq_desc *desc)
{
return desc->status & _IRQ_MOVE_PCNTXT;
}

static inline bool irq_settings_can_autoenable(struct irq_desc *desc)
{
return !(desc->status & _IRQ_NOAUTOEN);
}

static inline bool irq_settings_is_nested_thread(struct irq_desc *desc)
{
return desc->status & _IRQ_NESTED_THREAD;
}
3 changes: 1 addition & 2 deletions kernel/irq/spurious.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ static int try_one_irq(int irq, struct irq_desc *desc, bool force)
raw_spin_lock(&desc->lock);

/* PER_CPU and nested thread interrupts are never polled */
if (irq_settings_is_per_cpu(desc) ||
(desc->status & IRQ_NESTED_THREAD))
if (irq_settings_is_per_cpu(desc) || irq_settings_is_nested_thread(desc))
goto out;

/*
Expand Down

0 comments on commit 1ccb4e6

Please sign in to comment.