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

xen/events: reduce externally visible helper functions

get_evtchn_to_irq() has only one external user while irq_from_evtchn()
provides the same functionality and is exported for a wider user base.
Modify the only external user of get_evtchn_to_irq() to use
irq_from_evtchn() instead and make get_evtchn_to_irq() static.

evtchn_from_irq() and irq_from_virq() have a single external user and
can easily be combined to a new helper irq_evtchn_from_virq() allowing
to drop irq_from_virq() and to make evtchn_from_irq() static.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

+15 -11
+4 -4
drivers/xen/events/events_2l.c
··· 171 171 int i; 172 172 struct shared_info *s = HYPERVISOR_shared_info; 173 173 struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu); 174 + evtchn_port_t evtchn; 174 175 175 176 /* Timer interrupt has highest priority. */ 176 - irq = irq_from_virq(cpu, VIRQ_TIMER); 177 + irq = irq_evtchn_from_virq(cpu, VIRQ_TIMER, &evtchn); 177 178 if (irq != -1) { 178 - evtchn_port_t evtchn = evtchn_from_irq(irq); 179 179 word_idx = evtchn / BITS_PER_LONG; 180 180 bit_idx = evtchn % BITS_PER_LONG; 181 181 if (active_evtchns(cpu, s, word_idx) & (1ULL << bit_idx)) ··· 328 328 for (i = 0; i < EVTCHN_2L_NR_CHANNELS; i++) { 329 329 if (sync_test_bit(i, BM(sh->evtchn_pending))) { 330 330 int word_idx = i / BITS_PER_EVTCHN_WORD; 331 - printk(" %d: event %d -> irq %d%s%s%s\n", 331 + printk(" %d: event %d -> irq %u%s%s%s\n", 332 332 cpu_from_evtchn(i), i, 333 - get_evtchn_to_irq(i), 333 + irq_from_evtchn(i), 334 334 sync_test_bit(word_idx, BM(&v->evtchn_pending_sel)) 335 335 ? "" : " l2-clear", 336 336 !sync_test_bit(i, BM(sh->evtchn_mask))
+9 -4
drivers/xen/events/events_base.c
··· 248 248 return 0; 249 249 } 250 250 251 - int get_evtchn_to_irq(evtchn_port_t evtchn) 251 + static int get_evtchn_to_irq(evtchn_port_t evtchn) 252 252 { 253 253 if (evtchn >= xen_evtchn_max_channels()) 254 254 return -1; ··· 415 415 /* 416 416 * Accessors for packed IRQ information. 417 417 */ 418 - evtchn_port_t evtchn_from_irq(unsigned irq) 418 + static evtchn_port_t evtchn_from_irq(unsigned int irq) 419 419 { 420 420 const struct irq_info *info = NULL; 421 421 ··· 433 433 } 434 434 EXPORT_SYMBOL_GPL(irq_from_evtchn); 435 435 436 - int irq_from_virq(unsigned int cpu, unsigned int virq) 436 + int irq_evtchn_from_virq(unsigned int cpu, unsigned int virq, 437 + evtchn_port_t *evtchn) 437 438 { 438 - return per_cpu(virq_to_irq, cpu)[virq]; 439 + int irq = per_cpu(virq_to_irq, cpu)[virq]; 440 + 441 + *evtchn = evtchn_from_irq(irq); 442 + 443 + return irq; 439 444 } 440 445 441 446 static enum ipi_vector ipi_from_irq(unsigned irq)
-1
drivers/xen/events/events_internal.h
··· 33 33 34 34 extern const struct evtchn_ops *evtchn_ops; 35 35 36 - int get_evtchn_to_irq(evtchn_port_t evtchn); 37 36 void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl); 38 37 39 38 unsigned int cpu_from_evtchn(evtchn_port_t evtchn);
+2 -2
include/xen/events.h
··· 100 100 101 101 /* Determine the IRQ which is bound to an event channel */ 102 102 unsigned int irq_from_evtchn(evtchn_port_t evtchn); 103 - int irq_from_virq(unsigned int cpu, unsigned int virq); 104 - evtchn_port_t evtchn_from_irq(unsigned irq); 103 + int irq_evtchn_from_virq(unsigned int cpu, unsigned int virq, 104 + evtchn_port_t *evtchn); 105 105 106 106 int xen_set_callback_via(uint64_t via); 107 107 int xen_evtchn_do_upcall(void);