Commit 0737402f authored by Johannes Berg's avatar Johannes Berg Committed by Richard Weinberger

um: irq: Reduce irq_reg allocation

We don't need an array of 4 entries to capture three and the
name 'MAX_IRQ_TYPE' really gets confusing as well. Remove it
and add a correct NUM_IRQ_TYPES, and use that correctly.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 458e1f7d
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#define IRQ_READ 0 #define IRQ_READ 0
#define IRQ_WRITE 1 #define IRQ_WRITE 1
#define IRQ_NONE 2 #define IRQ_NONE 2
#define MAX_IRQ_TYPE (IRQ_NONE + 1) #define NUM_IRQ_TYPES (IRQ_NONE + 1)
struct siginfo; struct siginfo;
extern void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs); extern void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs);
......
...@@ -43,7 +43,7 @@ struct irq_reg { ...@@ -43,7 +43,7 @@ struct irq_reg {
struct irq_entry { struct irq_entry {
struct irq_entry *next; struct irq_entry *next;
int fd; int fd;
struct irq_reg *irq_array[MAX_IRQ_TYPE + 1]; struct irq_reg *irq_array[NUM_IRQ_TYPES];
}; };
static struct irq_entry *active_fds; static struct irq_entry *active_fds;
...@@ -101,7 +101,7 @@ void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs) ...@@ -101,7 +101,7 @@ void sigio_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
*/ */
irq_entry = (struct irq_entry *) irq_entry = (struct irq_entry *)
os_epoll_get_data_pointer(i); os_epoll_get_data_pointer(i);
for (j = 0; j < MAX_IRQ_TYPE ; j++) { for (j = 0; j < NUM_IRQ_TYPES ; j++) {
irq = irq_entry->irq_array[j]; irq = irq_entry->irq_array[j];
if (irq == NULL) if (irq == NULL)
continue; continue;
...@@ -124,7 +124,7 @@ static int assign_epoll_events_to_irq(struct irq_entry *irq_entry) ...@@ -124,7 +124,7 @@ static int assign_epoll_events_to_irq(struct irq_entry *irq_entry)
int events = 0; int events = 0;
struct irq_reg *irq; struct irq_reg *irq;
for (i = 0; i < MAX_IRQ_TYPE ; i++) { for (i = 0; i < NUM_IRQ_TYPES ; i++) {
irq = irq_entry->irq_array[i]; irq = irq_entry->irq_array[i];
if (irq != NULL) if (irq != NULL)
events = irq->events | events; events = irq->events | events;
...@@ -172,7 +172,7 @@ static int activate_fd(int irq, int fd, int type, void *dev_id) ...@@ -172,7 +172,7 @@ static int activate_fd(int irq, int fd, int type, void *dev_id)
goto out_unlock; goto out_unlock;
} }
irq_entry->fd = fd; irq_entry->fd = fd;
for (i = 0; i < MAX_IRQ_TYPE; i++) for (i = 0; i < NUM_IRQ_TYPES; i++)
irq_entry->irq_array[i] = NULL; irq_entry->irq_array[i] = NULL;
irq_entry->next = active_fds; irq_entry->next = active_fds;
active_fds = irq_entry; active_fds = irq_entry;
...@@ -244,7 +244,7 @@ static void garbage_collect_irq_entries(void) ...@@ -244,7 +244,7 @@ static void garbage_collect_irq_entries(void)
walk = active_fds; walk = active_fds;
while (walk != NULL) { while (walk != NULL) {
reap = true; reap = true;
for (i = 0; i < MAX_IRQ_TYPE ; i++) { for (i = 0; i < NUM_IRQ_TYPES ; i++) {
if (walk->irq_array[i] != NULL) { if (walk->irq_array[i] != NULL) {
reap = false; reap = false;
break; break;
...@@ -301,7 +301,7 @@ static void do_free_by_irq_and_dev( ...@@ -301,7 +301,7 @@ static void do_free_by_irq_and_dev(
int i; int i;
struct irq_reg *to_free; struct irq_reg *to_free;
for (i = 0; i < MAX_IRQ_TYPE ; i++) { for (i = 0; i < NUM_IRQ_TYPES ; i++) {
if (irq_entry->irq_array[i] != NULL) { if (irq_entry->irq_array[i] != NULL) {
if ( if (
((flags & IGNORE_IRQ) || ((flags & IGNORE_IRQ) ||
......
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