Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

serial: 8250: use hashtable

Instead of open-coding the hash table, use the one provided by
hashtable.h. The semantics is the same, except the code needs not to
compute the hash bucket on its own.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250611100319.186924-33-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
0a6fb2dc 6529c88f

+8 -16
+8 -16
drivers/tty/serial/8250/8250_core.c
··· 13 13 */ 14 14 15 15 #include <linux/acpi.h> 16 + #include <linux/hashtable.h> 16 17 #include <linux/module.h> 17 18 #include <linux/moduleparam.h> 18 19 #include <linux/ioport.h> ··· 48 47 struct list_head *head; 49 48 }; 50 49 51 - #define NR_IRQ_HASH 32 /* Can be adjusted later */ 52 - static struct hlist_head irq_lists[NR_IRQ_HASH]; 50 + #define IRQ_HASH_BITS 5 /* Can be adjusted later */ 51 + static DEFINE_HASHTABLE(irq_lists, IRQ_HASH_BITS); 53 52 static DEFINE_MUTEX(hash_mutex); /* Used to walk the hash */ 54 53 55 54 /* ··· 76 75 77 76 l = i->head; 78 77 do { 79 - struct uart_8250_port *up; 80 - struct uart_port *port; 81 - 82 - up = list_entry(l, struct uart_8250_port, list); 83 - port = &up->port; 78 + struct uart_8250_port *up = list_entry(l, struct uart_8250_port, list); 79 + struct uart_port *port = &up->port; 84 80 85 81 if (port->handle_irq(port)) { 86 82 handled = 1; ··· 130 132 */ 131 133 static struct irq_info *serial_get_or_create_irq_info(const struct uart_8250_port *up) 132 134 { 133 - struct hlist_head *h; 134 135 struct irq_info *i; 135 136 136 137 mutex_lock(&hash_mutex); 137 138 138 - h = &irq_lists[up->port.irq % NR_IRQ_HASH]; 139 - 140 - hlist_for_each_entry(i, h, node) 139 + hash_for_each_possible(irq_lists, i, node, up->port.irq) 141 140 if (i->irq == up->port.irq) 142 141 goto unlock; 143 142 ··· 145 150 } 146 151 spin_lock_init(&i->lock); 147 152 i->irq = up->port.irq; 148 - hlist_add_head(&i->node, h); 153 + hash_add(irq_lists, &i->node, i->irq); 149 154 unlock: 150 155 mutex_unlock(&hash_mutex); 151 156 ··· 184 189 static void serial_unlink_irq_chain(struct uart_8250_port *up) 185 190 { 186 191 struct irq_info *i; 187 - struct hlist_head *h; 188 192 189 193 mutex_lock(&hash_mutex); 190 194 191 - h = &irq_lists[up->port.irq % NR_IRQ_HASH]; 192 - 193 - hlist_for_each_entry(i, h, node) 195 + hash_for_each_possible(irq_lists, i, node, up->port.irq) 194 196 if (i->irq == up->port.irq) 195 197 break; 196 198