Skip to content

Commit 6864645

Browse files
committed
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 <[email protected]> Reviewed-by: Oleksandr Tyshchenko <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent f96c6c5 commit 6864645

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

drivers/xen/events/events_2l.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ static void evtchn_2l_handle_events(unsigned cpu, struct evtchn_loop_ctrl *ctrl)
171171
int i;
172172
struct shared_info *s = HYPERVISOR_shared_info;
173173
struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu);
174+
evtchn_port_t evtchn;
174175

175176
/* Timer interrupt has highest priority. */
176-
irq = irq_from_virq(cpu, VIRQ_TIMER);
177+
irq = irq_evtchn_from_virq(cpu, VIRQ_TIMER, &evtchn);
177178
if (irq != -1) {
178-
evtchn_port_t evtchn = evtchn_from_irq(irq);
179179
word_idx = evtchn / BITS_PER_LONG;
180180
bit_idx = evtchn % BITS_PER_LONG;
181181
if (active_evtchns(cpu, s, word_idx) & (1ULL << bit_idx))
@@ -328,9 +328,9 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
328328
for (i = 0; i < EVTCHN_2L_NR_CHANNELS; i++) {
329329
if (sync_test_bit(i, BM(sh->evtchn_pending))) {
330330
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",
332332
cpu_from_evtchn(i), i,
333-
get_evtchn_to_irq(i),
333+
irq_from_evtchn(i),
334334
sync_test_bit(word_idx, BM(&v->evtchn_pending_sel))
335335
? "" : " l2-clear",
336336
!sync_test_bit(i, BM(sh->evtchn_mask))

drivers/xen/events/events_base.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static int set_evtchn_to_irq(evtchn_port_t evtchn, unsigned int irq)
248248
return 0;
249249
}
250250

251-
int get_evtchn_to_irq(evtchn_port_t evtchn)
251+
static int get_evtchn_to_irq(evtchn_port_t evtchn)
252252
{
253253
if (evtchn >= xen_evtchn_max_channels())
254254
return -1;
@@ -415,7 +415,7 @@ static void xen_irq_info_cleanup(struct irq_info *info)
415415
/*
416416
* Accessors for packed IRQ information.
417417
*/
418-
evtchn_port_t evtchn_from_irq(unsigned irq)
418+
static evtchn_port_t evtchn_from_irq(unsigned int irq)
419419
{
420420
const struct irq_info *info = NULL;
421421

@@ -433,9 +433,14 @@ unsigned int irq_from_evtchn(evtchn_port_t evtchn)
433433
}
434434
EXPORT_SYMBOL_GPL(irq_from_evtchn);
435435

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)
437438
{
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;
439444
}
440445

441446
static enum ipi_vector ipi_from_irq(unsigned irq)

drivers/xen/events/events_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ struct evtchn_ops {
3333

3434
extern const struct evtchn_ops *evtchn_ops;
3535

36-
int get_evtchn_to_irq(evtchn_port_t evtchn);
3736
void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl);
3837

3938
unsigned int cpu_from_evtchn(evtchn_port_t evtchn);

include/xen/events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ void xen_poll_irq_timeout(int irq, u64 timeout);
100100

101101
/* Determine the IRQ which is bound to an event channel */
102102
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);
105105

106106
int xen_set_callback_via(uint64_t via);
107107
int xen_evtchn_do_upcall(void);

0 commit comments

Comments
 (0)