Re: [PATCH 03/22] virtio_config: make transports implement accessors.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2013-03-21 at 08:29 +0000, Rusty Russell wrote:
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 1ba0d68..ad7f38f 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -178,6 +178,19 @@ static void vm_get(struct virtio_device *vdev, unsigned offset,
>                 ptr[i] = readb(vm_dev->base + VIRTIO_MMIO_CONFIG + offset + i);
>  }
> 
> +#define VM_GETx(bits)                                                  \
> +static u##bits vm_get##bits(struct virtio_device *vdev, unsigned int offset) \
> +{                                                                      \
> +       u##bits v;                                                      \
> +       vm_get(vdev, offset, &v, sizeof(v));                            \
> +       return v;                                                       \
> +}
> +
> +VM_GETx(8)
> +VM_GETx(16)
> +VM_GETx(32)
> +VM_GETx(64)
> +
>  static void vm_set(struct virtio_device *vdev, unsigned offset,
>                    const void *buf, unsigned len)
>  {
> @@ -189,6 +202,18 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>                 writeb(ptr[i], vm_dev->base + VIRTIO_MMIO_CONFIG + offset + i);
>  }
> 
> +#define VM_SETx(bits)                                                  \
> +static void vm_set##bits(struct virtio_device *vdev, unsigned int offset, \
> +                        u##bits v)                                     \
> +{                                                                      \
> +       vm_set(vdev, offset, &v, sizeof(v));                            \
> +}
> +
> +VM_SETx(8)
> +VM_SETx(16)
> +VM_SETx(32)
> +VM_SETx(64)
> +
>  static u8 vm_get_status(struct virtio_device *vdev)
>  {
>         struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> @@ -424,8 +449,14 @@ static const char *vm_bus_name(struct virtio_device *vdev)
>  }
> 
>  static const struct virtio_config_ops virtio_mmio_config_ops = {
> -       .get            = vm_get,
> -       .set            = vm_set,
> +       .get8           = vm_get8,
> +       .set8           = vm_set8,
> +       .get16          = vm_get16,
> +       .set16          = vm_set16,
> +       .get32          = vm_get32,
> +       .set32          = vm_set32,
> +       .get64          = vm_get64,
> +       .set64          = vm_set64,
>         .get_status     = vm_get_status,
>         .set_status     = vm_set_status,
>         .reset          = vm_reset,

The idea is by all means fine with me. I wouldn't write it like this,
but I see you're already toying with other alternatives. And I'll have
to make it LE only anyway, so I guess the implementation details don't
really matter right now.

Paweł


_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization





[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux