aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/i8259.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/i8259.c')
-rw-r--r--arch/x86/kvm/i8259.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index 1ccb50c74f18..2520922282d5 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -444,10 +444,15 @@ static int picdev_in_range(struct kvm_io_device *this, gpa_t addr,
444 } 444 }
445} 445}
446 446
447static inline struct kvm_pic *to_pic(struct kvm_io_device *dev)
448{
449 return container_of(dev, struct kvm_pic, dev);
450}
451
447static void picdev_write(struct kvm_io_device *this, 452static void picdev_write(struct kvm_io_device *this,
448 gpa_t addr, int len, const void *val) 453 gpa_t addr, int len, const void *val)
449{ 454{
450 struct kvm_pic *s = this->private; 455 struct kvm_pic *s = to_pic(this);
451 unsigned char data = *(unsigned char *)val; 456 unsigned char data = *(unsigned char *)val;
452 457
453 if (len != 1) { 458 if (len != 1) {
@@ -474,7 +479,7 @@ static void picdev_write(struct kvm_io_device *this,
474static void picdev_read(struct kvm_io_device *this, 479static void picdev_read(struct kvm_io_device *this,
475 gpa_t addr, int len, void *val) 480 gpa_t addr, int len, void *val)
476{ 481{
477 struct kvm_pic *s = this->private; 482 struct kvm_pic *s = to_pic(this);
478 unsigned char data = 0; 483 unsigned char data = 0;
479 484
480 if (len != 1) { 485 if (len != 1) {
@@ -516,6 +521,12 @@ static void pic_irq_request(void *opaque, int level)
516 } 521 }
517} 522}
518 523
524static const struct kvm_io_device_ops picdev_ops = {
525 .read = picdev_read,
526 .write = picdev_write,
527 .in_range = picdev_in_range,
528};
529
519struct kvm_pic *kvm_create_pic(struct kvm *kvm) 530struct kvm_pic *kvm_create_pic(struct kvm *kvm)
520{ 531{
521 struct kvm_pic *s; 532 struct kvm_pic *s;
@@ -534,10 +545,7 @@ struct kvm_pic *kvm_create_pic(struct kvm *kvm)
534 /* 545 /*
535 * Initialize PIO device 546 * Initialize PIO device
536 */ 547 */
537 s->dev.read = picdev_read; 548 kvm_iodevice_init(&s->dev, &picdev_ops);
538 s->dev.write = picdev_write;
539 s->dev.in_range = picdev_in_range;
540 s->dev.private = s;
541 kvm_io_bus_register_dev(&kvm->pio_bus, &s->dev); 549 kvm_io_bus_register_dev(&kvm->pio_bus, &s->dev);
542 return s; 550 return s;
543} 551}