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.

vdpa_sim: add set_config callback in vdpasim_dev_attr

The set_config callback can be used by the device to parse the
config structure modified by the driver.

The callback will be invoked, if set, in vdpasim_set_config() after
copying bytes from caller buffer into vdpasim->config buffer.

Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-14-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Stefano Garzarella and committed by
Michael S. Tsirkin
c124a95e 65b70958

+10 -1
+10 -1
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 78 78 79 79 work_func_t work_fn; 80 80 void (*get_config)(struct vdpasim *vdpasim, void *config); 81 + void (*set_config)(struct vdpasim *vdpasim, const void *config); 81 82 }; 82 83 83 84 /* State of each vdpasim device */ ··· 607 606 static void vdpasim_set_config(struct vdpa_device *vdpa, unsigned int offset, 608 607 const void *buf, unsigned int len) 609 608 { 610 - /* No writable config supportted by vdpasim */ 609 + struct vdpasim *vdpasim = vdpa_to_sim(vdpa); 610 + 611 + if (offset + len > vdpasim->dev_attr.config_size) 612 + return; 613 + 614 + memcpy(vdpasim->config + offset, buf, len); 615 + 616 + if (vdpasim->dev_attr.set_config) 617 + vdpasim->dev_attr.set_config(vdpasim, vdpasim->config); 611 618 } 612 619 613 620 static u32 vdpasim_get_generation(struct vdpa_device *vdpa)